ActionScript Issue - gotoAndPlay() Behavior

Posted on May 27, 2005

Ok, let me preface this by saying that I am by no means a Flash or ActionScript expert...in fact I probably know enough to just get by, but I was encountering what appeared to be an odd behavior in my ActionScript for a game I was helping to develop. Basically, I had a movie clip functioning as a button inside another movie clip that when pressed called "_root.gotoAndPlay(6)". Yet, every time the button was pressed, it started the movie over. It did not matter what frame number I placed or if it called a gotoAndStop(6)...it always went to frame 1. Why?!?? The same behavior on a button in the root worked. Am I missing some nugget of ActionScript knowledge? Anyway, I got it to work in the end by adding a label to the frame and then calling it as "_root.gotoAndPlay('theFrameLabel')"...but if someone can share the reason the other fomat did not work, I would love to know.

Comments

Dennis I would suggest staying away from using _root in the first place. I also use dot syntax to develop since it is much more easy to port code from app to app and between movieclips.

The bug itself is hard to diagnose without seeing the code and the setup of the movie, but could very well have been something you missed.

I would have suggested a label as well.

Posted By Dennis / Posted on 06/06/2005 at 8:21 AM


Write your comment



(it will not be displayed)





About

My name is Brian Rinaldi and I am the Web Community Manager for Flash Platform at Adobe. I am a regular blogger, speaker and author. I also founded RIA Unleashed conference in Boston. The views expressed on this site are my own & not those of my employer.