Copy link to clipboard
Copied
Hello
I am using ‘gotoandplay’ scene by scene link using this code. If I use this in the same time line (internal), it’s working properly but when I use this code in as a class, I got this error
Call to a possibly undefined method MovieClip.
I use this code in time timeline
b_enter.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_enter1);
function fl_ClickToGoToScene_enter1(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay("p menu", "Menu");
}
I use this code in class
package {
import flash.display.SimpleButton;
public class next extends SimpleButton {
public function next() {
// constructor code
MovieClip(this.root).gotoAndStop("p2", "page2")
}
}
}
u can download the flash file using this link
1 Correct answer
:
package {
import flash.display.SimpleButton;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
public class np extends SimpleButton {
var _root:MovieClip;
public function np() {
this.addEventListener(Event.ADDED_TO_STAGE,init);
this.addEventListener(MouseEvent.CLICK,nextF);
}
private function init(e:Event):void{
_root = MovieClip(this.root);
}
private functi
...Copy link to clipboard
Copied
that's not the code being used by flash. you need to save that file, then test.
Copy link to clipboard
Copied
thx boss. its working
Copy link to clipboard
Copied
you're welcome.


-
- 1
- 2