bdavey311
08-06-2008, 05:01 AM
I'm setting up my first AS3 navigation menu all inside 1 swf and when I click on the link, I want it to go to the main timeline and gotoandPlay the respective label that I tell it to go to. Obviously a "root" and "parent" issue.
I looked around and I found something to the effect of using:
function onClickHandler(event:MouseEvent) {
MovieClip(this.parent.parent).gotoAndPlay("KnowledgePAGE");
}
Then I get the error message that says:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@2d52f99 to flash.display.MovieClip.
at unityrings_fla::Menu_3/onClickHandler()
With that being said - Here is all the code:
stop();
import flash.display.MovieClip;
import flash.events.MouseEvent;
knowledgeMC.addEventListener(MouseEvent.ROLL_OVER, overHandler);
knowledgeMC.addEventListener(MouseEvent.ROLL_OUT, outHandler);
knowledgeMC.addEventListener(MouseEvent.CLICK, onClickHandler);
// if you want a hand cursor
knowledgeMC.buttonMode = true;
knowledgeMC.useHandCursor = true;
function overHandler(event:MouseEvent) {
knowledgeMC.gotoAndPlay("over");
}
function outHandler(event:MouseEvent) {
knowledgeMC.gotoAndPlay("out");
}
function onClickHandler(event:MouseEvent) {
MovieClip(this.parent.parent).gotoAndPlay("KnowledgePAGE");
}
AS3 is certainly not a walk in the park. I need a long learning session considering that I was just feeling comfortable with AS2.
Thanks in advance!
Brian
I looked around and I found something to the effect of using:
function onClickHandler(event:MouseEvent) {
MovieClip(this.parent.parent).gotoAndPlay("KnowledgePAGE");
}
Then I get the error message that says:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@2d52f99 to flash.display.MovieClip.
at unityrings_fla::Menu_3/onClickHandler()
With that being said - Here is all the code:
stop();
import flash.display.MovieClip;
import flash.events.MouseEvent;
knowledgeMC.addEventListener(MouseEvent.ROLL_OVER, overHandler);
knowledgeMC.addEventListener(MouseEvent.ROLL_OUT, outHandler);
knowledgeMC.addEventListener(MouseEvent.CLICK, onClickHandler);
// if you want a hand cursor
knowledgeMC.buttonMode = true;
knowledgeMC.useHandCursor = true;
function overHandler(event:MouseEvent) {
knowledgeMC.gotoAndPlay("over");
}
function outHandler(event:MouseEvent) {
knowledgeMC.gotoAndPlay("out");
}
function onClickHandler(event:MouseEvent) {
MovieClip(this.parent.parent).gotoAndPlay("KnowledgePAGE");
}
AS3 is certainly not a walk in the park. I need a long learning session considering that I was just feeling comfortable with AS2.
Thanks in advance!
Brian