Pregunta

I've got a simple AS3 script that jumps to a new frame when a button (mc_rollbutton) is moused over:

mc_rollbutton.addEventListener(MouseEvent.MOUSE_OVER, fl_ClickToGoToWebPage3);

function fl_ClickToGoToWebPage3(event:MouseEvent):void
{
MovieClip(root).gotoAndPlay(134);
}

When I play the movie, it's outputting this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at bc_comp_03_fla::MainTimeline/frame1()

Do I have the MovieClip(root) syntax wrong? Frame 134 is on the main timeline and I get the same error if I omit MovieClip(root) and just use gotoAndPlay(134);.

Thanks for any help you can throw my way!

Joe

¿Fue útil?

Solución 2

As noted in the comment above, I discovered that the error occurred when my movie clip was not on the first frame of the movie, where the main ActionScript code was. I copied the MC to frame 1, turned off the Visible option and it all worked. Hope this helps someone else.

  • Joe

Otros consejos

I had that problem a few times. I have searched my notes, but i cant find the right thing now so i will just state few options. But again if anything is not working pls reply and i will search my other notes when i woke up, becouse i know i have writen that case somewhere.

For now try with with:

function fl_ClickToGoToWebPage3(event:MouseEvent):void
{
    //option 1
    MovieClip(this.root).gotoAndPlay(134);
    //option 2
    MovieClip(parent).gotoAndPlay(134);
    //option 3
    var mc:MovieClip = this.parent as MovieClip;
    mc.gotoAndPlay(134);
}

well i hope something will help, didn't open flash for a year now so fingers crossed (:

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top