Hey guys!
I have a movie clip on a scene with a button inside. How can I make this button to go to play frames on the scene but not inside the movie clip in AS3.0?
Thanks a lot!
Printable View
Hey guys!
I have a movie clip on a scene with a button inside. How can I make this button to go to play frames on the scene but not inside the movie clip in AS3.0?
Thanks a lot!
add a listener to the button from the scene timeline
on the scene timeline add the following:
PHP Code:import flash.event.MouseEvent;
function playTimeline(evt:MouseEvent){
gotoAndPlay("myFrame")
}
movieClip.button.addEventListener(MouseEvent.Click, playTimeline);
Thank you, I appreciate your help! :) However, is there another way? Because it seems that the code you given me always looks at the last frame of the scene, and if the movie clip name or buttons do not exist in the last frame of the scene, I get an access of undefined property error...
I was hoping for something more along the lines of root.frameName, is there any code for that?
Thanks! :)
the code always looks at the frame where it is placed.
If you want to add the event listener on a different frame from the code, just put the addEventListener line into its own function and call that when the button exists:
PHP Code:import flash.event.MouseEvent;
import flash.display.DisplayObject;
function playTimeline(evt:MouseEvent){
gotoAndPlay("myFrame")
}
function listenTo(target:DisplayObject):void{
target.addEventListener(MouseEvent.Click, playTimeline, false, 0, true);
}
//place the listenTo call on the scene timeline when the button exists
listenTo(movieClip.button);
Hi, sorry for the bump.
I want to know how am 9 able to go to the next scene smoothly from the moment my preloader stops playing, using code.
Help? :confused: