Playing multiple conditions in an if statement

I have a button that I want to play first one frame label in a movie\rclip, and then another, depending on a variable.\r\rThe problem that I am having is that the movie does not wait for the first\rpart to finish before jumping to the next.\r\rI’m really tired so I hope I’m explaining this well.\r\rHere is an example of the code\r\ron (release) {\rif (_root.busMove.bus == 2) {\r_root.busMove.gotoAndStop (“A2beg”);\r_root.busMove.gotoAndPlay (“Bbeg”) ;\r}\r}\r\rIt goes right to Bbeg, flickering briefly over A2beg which will not do!\r\rI’m a newcomer to actionscript so any advice will be received gratefully.\r\r\r

I see 2 solutionq there : either “A2beg” is always followed by “B2beg”, and in that case you can take out your last line and put at the end of the “A2beg” part gotoAndPlay(“B2beg”).\rOr, if it’s not the case, you can initialize a variable “finished=1” and wait in your main clip for that variable to get to 1.\r\rI’m tired too, sorry. Just tell me if something is not clear.\r\rpom 0]

Completly normal your movie behaves like that, actionscript executes really fast, so by the time A is reached, the next line of the button script has already told the clip to go to B where it then shows…\rIf say you have a 10 frame anim’ starting at A you want to play before going to B, keep the first line, and use an if test before sending it on to B. \rIn the last frame of the A part, set go=1 (or true, it’s equivalent); \rbefore your button action “go B”, add the if (go) test \r// if (go) is the same as if (go==true)//\rHope you can figure this out, everybody’s tired, so 'm I…

Thanks for translating, Eyez… I’m so tired, just got out of my exams… 2 more to go.\rpom 0]

Thanks for the suggestions!\r\rHow would I go about adding an if statement in the middle of another if statement? Should i make a function and stick it in?\r\rWhat I’m doing is I have a bus that will be traveling on different routes depending on which location it was last (bus var), and where its destination is (button that was pressed). So I have a road system like an X. I made eight tweens that I can add together in different combinations to direct the bus around.\r\r \r\r

Show me.\rAm mean, is it working ? And if it’s not, you’ll have to be a little bit more precise, post your code, the swf, the fla, something, I don’t know.\r\rpom 0]

Everything was already done except getting the two gotoAndPlays to play one after the other, which I am working on now with what you suggested doing earlier.\r\rI was just wondering about putting an if statement in the middle of another if statement and how that would be worded, but I’ve figured something else out now. \r\rThanks

hmm… yes… in the case you posted above, two if statements in one place just doesn’t make any sense. If you want it to place first, and the go to another place and stop, you would do this.\r\ron the button you have this.\r\ron (release) {\rif (_root.busMove.bus == 2) {\r_root.busMove.gotoAndPlay (“Bbeg”) ;\r}\r}\r\rthen it will goto “Bbeg” and start playing. When it gets to the point where you want it to goto the “A2beg” and stop, you have a keyframe with the following action in it\r\r_root.busMove.gotoAndStop (“A2beg”);\r\rwith the second one you don’t need it attached to the button at all.\r----------------------------\rFor your question about two if statements there are a couple of ways of doing that for logic flow.\r\rA) you can use && to require two different “if’s” be met. like so\r\ron(release){\rif(a==b&&c==d){\r_root.gotoAndPlay(1);\r}\r}\r\rin this case it will only goto and play if a is equal to b AND c is equal to d… otherwise it will do nothing.\r\rB)\r\ron(release){\r if(a==b){\r if(c==d){\r _root.gotoAndPlay(1);\r }\r }\r}\r\rin this case it first looks to see if a equals b, and then if that is true, then it looks to see if c is equal to d. The structure is a little different, and therefore will end up having slightly different results.\r\rThere is also the “if else” option which works slightly differently again.

It works perfectly now. I always come in these flash forums when I’m stuck and end up figuring it out before anyone replies!\r\rthanks though.

Glad to have been of no help. I’ll be glad not to help you anytime. :smiley: \r\rpom 0]

roflmao…