Confusion about initializing variables...HELP me plzzzz

hiyaa…\r\rhow does this work? :\r\rI have a flash movie consisting of 3 layers each with one frame only…\r(1) On the firstkeyframe of layer 1 , i have initialized a variable :\r\rrotation=0;\r\r(2) on the firstkeyframe of layer 2 i have a button with the following actionscript:\r\ron(release){\rrotation+=10;\r}\r\r(3) on the firstkeyframe of layer 3 i have a movieclip with the following actionscript\r\ronClipEvent(enterFrame){\rsetProperty(this,_rotation,_root.rotation)\r}\r\r\rnow the thing is all this code works fine in rotating the movie clip everytime i click the button.\r\rwhat i DONT understand is when the movie is playing when it loops, how come it doesnt set the rotation variable back to 0, as in the first layer we set rotation=0;??? wont the variable be reinitialized to 0 again?\r\rthis is confusing me a bit… why does it take the value of rotation to be the value the button set it to and not what the frame set it to?\r\rany ideas? any help would be appreciated…\r\rcheers\rZain\r\r\r\r

Hello, Zain.\r\rI think the problem lies here:\r\rYour MC on layer is looping, not the frame in layer 1.\r\rThis means that the value of _root.rotation has already been set, and unless you reload your movie, it won’t be back to zero.\r\rSolution:\r\rA few different ways. Here are two:\r\rin the last frame of your movie clip: \r\r_root.rotation=0;\r\ror, you could declare the variable in the button:\r\ron(release){\r_root.rotation=0;\r}\r\rof course this means the value is reset everytime you press the button.\r\ror…\ryou could declare the variable in the MC.\r\rHope this helps. Good luck!

Thanks for ur reply Iammontoya,\r\rBut doesnt a flash movie automatically loop whether or not it contains any movie clips?\r\rso if i have a flash movie with just one frame, isnt it automatically looping again and again over the same frame? ( only because it is so fast -12fps we dont notice it is actually looping?)

not quite.\r\rif you only have one frame on the main timeline, it will not loop.\r\rif you’d like to verify, try this simple exercise.\r\rnew movie\rframe1 of the main timeline, put the following code:\r\rrotation=0;\rtrace(rotation);\r\rtest your movie.\r\rSee? the value is only given once.\r\rNow, add a frame on frame2…\r\rtest your movie.\r\rIt will loop and continue to give zeroes…\r\r;) \r\r

yep ur right!!! thanks a lot…its cleared a lot if questions up…\rthanks :slight_smile: