2

I'm doing a little animation using Actionscript 3.0 but I'm having a few problems (I'm new with AS3) when I want to play a movie clip in reverse and, then, return to frame 1(main).

Here is my code:

B6_btn.addEventListener(MouseEvent.CLICK, onClickReverse6);

function onClickReverse6(event:MouseEvent):void{
    m6_mc.addEventListener(Event.ENTER_FRAME, playReverse6, false, 0, true);
}

function playReverse6(event:Event):void{
    if(m6_mc.currentFrame == 1){
        if(playMusic){
            playMusic.stop();
        }
        gotoAndStop(1);
    }else{
        m6_mc.prevFrame();
    }
}

The error I get is with the line

"if(m6_mc.currentFrame == 1)" - ERROR #1009: Cannot access a property or method of a null object reference

If I remove the command gotoAndStop(1), no error is presented.

Can anyone, please, help me with my code?

Rich
  • 970
  • 2
  • 16
  • 42

2 Answers2

0

As far as I can see, you are calling gotoAndStop some other MovieClip (it's actually whatever this is in your case). But at this time you are checking the currentFrame property fo the m6_mc.

I think there might be some error with that. If you switch this to frame 1, is there a m6_mc instance (if you're not keeping it in a variable)?

Andrey Popov
  • 7,362
  • 4
  • 38
  • 58
0

I have this code on frame 1, regarding the code presented before:

function onClick6(event:MouseEvent):void{
 musicLoader = new URLRequest("music/GABRIEL.mp3");
 music = new Sound();
 music.load(musicLoader);
 playMusic = music.play(0,4);
 gotoAndStop(7);
 m6_mc.gotoAndPlay(1);}