Go down
Clovis15
Clovis15
Spritan
Spritan
Age : 42
Number of posts : 261
Registration date : 2011-01-16

Our Friends, the Flags! Empty Our Friends, the Flags!

11/20/2011, 12:45 am
(NOTE: The following may only apply to AS2, although I think the code I use here is universal to later versions also)

A while back I noticed some people telling people they could use the gotoAndPlay(); command to effect jumping around a film. While this is true, the disturbing part is that they were suggesting people input straight frame numbers when you use this. So long as you're only going to first frame of a scene, this isn't entirely whack advice. After all, frame 1 of a scene is always going to be the first frame. However, what if you want to go some other frame in a scene... what then?

If you ever go back and edit any of the animation in that scene - perhaps because you were unhappy with it, or maybe just felt like being difficult to yourself - then suddenly every gotoAndPlay(); command could potentially be pointing to the wrong frames and all have to be fixed by hand. Sure, you could wait to program stuff like this until the entire movie was done, but some kinds of interactive content can't even be tested without the jumping functionality already in place. You'd be a somewhat poor animator if you didn't look anything over even once until the 11th hour!

Are you doomed to suffer the yoke of never modifying anything so that the links don't break, or fixing them all by hand each and every time you modify something?

NO! NEVER FEAR, FOR OUR FRIENDS THE FLAGS ARE HERE!
Our Friends, the Flags! Example1
Yes, that's me running Flash 6 on a Windows 7 machine... just ignore that fact...

Anyways, as indicated by circle 1, you may notice that various frames have a flag on them with a name next to it. No, this doesn't mean that I've found a way to play minesweeper inside of flash, although that would be an interesting thing to try and do. It actually means that there is a way to break free of the shackles of having to use specific frame numbers when I use the gotoAndPlay(); command.

When you have a frame selected on the time line, and have the properties panel open, you can find an option - as shown by circle 2 - to give that frame a name. Don't worry, even your much newer - less ghettofied - versions of Flash will also have this highly useful feature. When you input a name down here, that frame up above will be flagged in the timeline with a flag of the same name. From now on you may reference that frame by the flag's name, rather than the frame number itself, and all references done this way will remain valid no matter how much you juggle things around.

If I were to, using the example above, type out the command: gotoAndPlay("window2"); then it would always go to the right frame, whether that was frame 42 or frame 1337. If I wanted to got to a flagged frame in a diifferent scene, then I'd just use gotoAndPlay("scene_name", "flag_name"); and I'd still get the desired result. Remember, you must now use quotations marks in the command as you're using a reference title for the frame instead of the actual number itself.

I may not often animate; but when I do, I use sprites...
Stay pixelated, my friends!


PREVIOUS TUTORIALS:

Clovis15 Tutorial-1: Easy Dynamic Sound Control With Resume
Clovis15 Tutorial-2: How to Live Life Without V-Cam
Clovis15 Tutorial-3: Dynamic Animation, and Subtitle Toggles


Last edited by Clovis15 on 11/20/2011, 11:58 pm; edited 1 time in total
avatar
Patt
Administrator
Administrator
Age : 28
Number of posts : 13124
Registration date : 2009-03-28

Our Friends, the Flags! Empty Re: Our Friends, the Flags!

11/20/2011, 12:53 am
Oooh, that is nice, I never though of doing it in that way. : o
Clovis15
Clovis15
Spritan
Spritan
Age : 42
Number of posts : 261
Registration date : 2011-01-16

Our Friends, the Flags! Empty Re: Our Friends, the Flags!

11/20/2011, 1:02 am
NOTE: Before anyone asks, Frame 2 is actually labelled Buttons. There just wasn't enough room on the timeline to show the full name.
avatar
Patt
Administrator
Administrator
Age : 28
Number of posts : 13124
Registration date : 2009-03-28

Our Friends, the Flags! Empty Re: Our Friends, the Flags!

11/20/2011, 1:03 am
No dude that is definitely named butt, you dirty man you.
Leo
Leo
Administrator
Administrator
Age : 26
Number of posts : 9153
Registration date : 2009-05-23
Location : Brazil

Our Friends, the Flags! Empty Re: Our Friends, the Flags!

11/20/2011, 4:18 am
^ lol

Well I knew about these already, they are mentioned in various tutorials and Flash books I had.

But nice tutorial, man. Your tutorials are always clear and straightforward.
Ping
Ping
Spritan
Spritan
Age : 28
Number of posts : 20149
Registration date : 2010-09-15
Location : Madison Wisconsin

Our Friends, the Flags! Empty Re: Our Friends, the Flags!

12/1/2011, 12:12 pm
Happy day, Clovis. Thank you.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum