-1

In as3 on click I have 2 buttons A and B, in a MovieClip when user click on button movie is playing , now I want when if user click on button A movie should play and when it reach the frame number 59 run getURL(abcd.html) and if user click button B it reach fram 59 and getURL(xyz.html) both URLs will be different

Vipul
  • 414
  • 3
  • 14

2 Answers2

0

on enter frame check if movieclipA.currentFrame is 59 execute code and do same for movieclipB also

Urosan
  • 321
  • 1
  • 11
0

Create a variable to hold the result of the button that was clicked. Something like...

int buttonClicked = -1;
// assuming the movie clip is called 'moviePlayerMovieClip'
moviePlayerMovieClip.stop();

Then on your buttons set the value of said variable, something like

moviePlayerMovieClip.button1.addEventListener(MouseEvent.CLICK, onButtonClicked);
moviePlayerMovieClip.button2.addEventListener(MouseEvent.CLICK, onButtonClicked);

function onButtonClicked(event:MouseEvent):void {
    if(event.target == moviePlayerMovieClip.button1)
    {
        buttonClicked = 1;
    }
    else
    {
        buttonClicked = 2;
    }
    // let the movie clip play
    moviePlayerMovieClip.play();
}

The movie clip should have an on enter frame handler, something like…

moviePlayerMovieClip.addEventListener(Event.ENTER_FRAME,onEnterFrame);

function onEnterFrame(event:Event) {
    if(moviePlayerMovieClip.currentFrame == 59)
    {
        if(buttonClicked == 1)
        {
            flash.net.navigateToURL('abcd.html', "_self");
        }
        else if(buttonClicked == 2)
        {
            flash.net.navigateToURL('xyz.html', "_self");
        }
    }
}