Reference Parent in ActionScripting 3.0
Referencing parent movie clip in ActionScripting 3.0 is slightly different than ActionScripting 2.0.
In 2.0, the child object can access its parent by the following code of "_parent.yourObject"
In 3.0, _parent has been replaced by "parent" without the underscore and it requires the parent to be casted as movieClip. In the above example, the buttons had been converted to a movie clip and controlling the parent frame. I will just be looking at the code. Please download to view the structure of the file. Enjoy!
// Copyright by CreativeReform
// Note that these lines of code reside within the movieClip
//Most important line is casting the parent as MovieClip object and pass into a variable.
//From then one, it's just a matter of interacting with the variable
var myvar = ( this.parent as MovieClip);
mbtn. addEventListener( MouseEvent.CLICK, moveStage);
mbtn2. addEventListener( MouseEvent.CLICK, moveStage2);
mbtn3. addEventListener( MouseEvent.CLICK, moveStage3);
function moveStage(e:Event):void{
myvar.gotoAndStop(1);
}
function moveStage2(e:Event):void{
myvar.gotoAndStop(2);
}
function moveStage3(e:Event):void{
myvar.gotoAndStop(3);
}