This site is optimised for Firefox 2.0 or Internet Explorer 7.

Skipping Frames Q...

jjdelv has no avatar
jjdelv
 
Post Count: 55
Joined: Tue Jan 20, 2009 12:57 pm
Flash Version: Adobe Flash CS3

Skipping Frames Q...

Postby jjdelv on Mon Mar 09, 2009 6:45 pm

So...

I have a page which has an intro animation which lasts 314 frames and finishes with a button. When you click the button it takes you to a separate html page with a scrolling photogallery. When I click the 'back' button in the photogallery it takes me back to the first html page with the intro animation.

How do I make sure that when I click the back button it skips the first 314 frames (bearing in mind I am returning from a separate html page)?

Whoever answers this is a total star...

jschertz has no avatar
jschertz
 
Post Count: 8
Joined: Mon Mar 09, 2009 6:27 pm
Location: Chicago
Flash Version: Adobe Flash CS4

Re: Skipping Frames Q...

Postby jschertz on Mon Mar 09, 2009 7:20 pm

You'll have to use FlashVars. Here's some background information straight from Adobe's site: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16417

Essentially, FlashVars are name/value pairs you set in the Embed tag of a swf. The name/values you set are then available on the root timeline of the swf. Now, here's the kicker, your example requires an additional step. When you click on the back button in the photogallery you're going to have to append a name/value pair to the url. (i.e. http://www.google.com?skip=true). Then, you'll have to use a javascript function that pulls the name/value pair in the url and changes the FlashVar you have set on your first page from one value to another (i.e. skip=true vs. skip=false).

Here's a recap:

1. add FlashVar to first swf Embed
2. add javascript function to first swf html page that will look for name/value pairs in the url, and change the FlashVar
3. on the back button press, append name/value pair to the url (you'll want to read up on navigateToURL() in its entirety here: [url]http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/[/url hint: flash.net.navigateToURL])
4. On frame 1 on your first page animation, throw code there to tell the movie to go to the last frame if skip == true

This is the simplist example I can think of. I'm sure there are other ways, maybe someone else can weigh in?
Follow me on twitter: @jschertz
or go to my site: God Save The Tween

jjdelv has no avatar
jjdelv
 
Post Count: 55
Joined: Tue Jan 20, 2009 12:57 pm
Flash Version: Adobe Flash CS3

Re: Skipping Frames Q...

Postby jjdelv on Tue Mar 10, 2009 12:58 am

jschertz,

I got an answer which seems a little simpler but has one one minor (or major... I can't decide) flaw.
Once I implement this code and the cookie is planted I can no longer see the intro... EVER again.
I thought i'd throw it down just in case anyone knew a way to circumvent this problem...
I'm going to try your method if I can manage to wrap my head round it...

Thanks so much for your help so far,

j

Code: Select all
var so:SharedObject = SharedObject.getLocal("introSettings");
if (so.size == 0)
{
    // Shared object doesn't exist.
    so.data.seenIntro = false;
}
if (so.data.seenIntro == true)
{
   gotoAndPlay(314);
}



In frame 313 (it actually would still work in frame 314), place the following code:
Code:

Code: Select all
so.data.seenIntro = true; //This data won't be written to the cookies until you use the command below
so.flush();


jschertz has no avatar
jschertz
 
Post Count: 8
Joined: Mon Mar 09, 2009 6:27 pm
Location: Chicago
Flash Version: Adobe Flash CS4

Re: Skipping Frames Q...

Postby jschertz on Tue Mar 10, 2009 2:02 am

Yeah the problem with SharedObjects is they're great for storing and saving user data, but lack flexibility for multiple saved states. For instance, YouTube uses SharedObjects for the volume slider in their video player. Every time a user changes the volume, that new volume becomes the default on any youtube video opened on that computer. On the SharedObject side, the object is saved over and over and over.

It's not the best possible solution for your situation. It does indeed work, but as you said, it only works once. The user will never see the intro again unless they go in and delete the .sol file themselves or right click on the flash movie, go to "settings" then "advanced" and then the "Website Storage Settings Panel" and clear the SharedObject out themselves.

I did a bit of reading in the AS3 Language Reference and found the LocalConnection class in the flash.net package. It allows two swfs to communicate with each other even if they're on separate domains. However, I haven't tested it myself, and I can only speculate. I'm not sure if both swfs have to be loaded at the same time in order for it to work. In your example, you're unloading the old html page and loading a new one, so at first glance LocalConnection may not be your solution, but it may be worth a look.
Follow me on twitter: @jschertz
or go to my site: God Save The Tween

jjdelv has no avatar
jjdelv
 
Post Count: 55
Joined: Tue Jan 20, 2009 12:57 pm
Flash Version: Adobe Flash CS3

Re: Skipping Frames Q...

Postby jjdelv on Wed Mar 11, 2009 1:30 pm

Thanks for your help j!

Im going to look into it (and I think someone suggested a similar thing on another forum). I'm currently on a tight deadline for another project so I am going to focus on that for the moment and then send you the outcome. The world is just going to have to take in my intro animation on first view!


Return to Actionscript 3.0

Who is online

Users browsing this forum: awesomelin and 2 guests