ledzep Posted December 12, 2004 Share Posted December 12, 2004 I'm working on a project for a class in which I am basically supposed to make a flash movie, basically I have two questions: 1. Is there anyway to make a loop that only loops x number of times and then keeps going? 2.Is there anyway to make an x number of loops that play the same thing at first and then play different things? (for example that they all begin say with the same animation of a guy walking and then go to different animations) thanks. Quote Link to comment Share on other sites More sharing options...
Guest imported_El Mamerro Posted December 12, 2004 Share Posted December 12, 2004 In the simplest of terms: 1) Declare a variable on the first frame of the timeline: var timesLooped = 0; 2) Start your loop animation on the second frame of the timeline. Name it "begin". On that very frame, write: timesLooped = timesLooped + 1; 3) On the last frame of your loop animation, write: if (timesLooped >= x) { gotoAndPlay ("continue"); else gotoAndPlay ("begin"); } ^In there, x will be the number of times you want it to loop. Every time the movie gets sent back to the beginning for looping, the variable will be incremented by one. Once it reaches the desired number (or higher), the code will tell the movie to go to a frame called "continue", which is where you will begin the remainder of your animation (next step). 4) Create said frame after the last frame of the animation loop, and drop in the remainder of your animation. Ta daa. I'm not sure what it is you're trying to do with your second problem. more details? Quote Link to comment Share on other sites More sharing options...
ledzep Posted December 12, 2004 Author Share Posted December 12, 2004 ok the basic idea with the second problem is that I want to make one animation that can branch off into differnt alternate endings. what i want to do is basically: a dude walks and then either he hunts a mastadon, he hunts an armadillo, or he hunts a bird, depending on what the viewer chooses. the order is basically: dude walks viewer chooses which prey he hunts dude walks then: if viewer chooses prey1 he hunts prey1 if viewer chooses prey3 he hunts prey2 and so forth. sorry its kind of hard to explain this way, if you still dont get what im sayin just forget it. Quote Link to comment Share on other sites More sharing options...
Guest imported_El Mamerro Posted December 12, 2004 Share Posted December 12, 2004 Oh, OK, that's simple. I didn't know there was gonna be user interaction. Make different starting frames on the timeline with specific names for each "outcome". Then make buttons that show up at the end of the first animation that, when clicked, send the playhead to the starting frame of choice. If you want the guy to do the same walk AFTER the viewer has chosen, then you wanna do the whole variable schtick again... I can't be more specific right now, cause I gotta go watch the Klitschko fight. And I can't tomorrow cause I'm gonna be drinking on a boat all day. This isn't for Monday, is it? Maybe the heavyLox monster can help you out in the meantime. Sorry. Quote Link to comment Share on other sites More sharing options...
ledzep Posted December 12, 2004 Author Share Posted December 12, 2004 nah this isnt due until friday, Im having difficulty getting the first loop thing you said to work, it says that its missing an 'if' for the 'else'. thanks anyways, if anything I'll just have to copy paste the animations (which even though its a waste of time and memory, at least I'll have it done). Quote Link to comment Share on other sites More sharing options...
AngerCMKill Posted December 13, 2004 Share Posted December 13, 2004 Originally posted by Armenhammer@Dec 11 2004, 08:07 PM if anything I'll just have to copy paste the animations (which even though its a waste of time and memory, at least I'll have it done). Quoted post what up ArmenHammer... this project must be a school favorite. i did a project similar to this... cept with an eyeball who got to either shoot or stab the rival red eyeball, or just try and run home..... El Mamerro pretty much got you all the info there for the animation... take your layer of the timeline, break off 3 seperate animations on that layer. label the seperate animation start frames "prey1", "prey2", or "prey3" make that whole animation including your ending that you'll have. make sure you put a "stop()" action at the end of each respective animation. or if you'll have them all end at the same ending do a gotoAndPlay ("ending"); with ending labeled "ending".... i just put my two cents in.... maybe i can get some help on a flash project i have due today... i need some quick code to make my character shoot projectiles..... someone, anyone? Quote Link to comment Share on other sites More sharing options...
Guest imported_El Mamerro Posted December 13, 2004 Share Posted December 13, 2004 Sorry, my syntax was fucked. Here you go: if (timesLooped >= x) { gotoAndPlay ("continue"); } else { gotoAndPlay ("begin"); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.