actionscript 3 - as3 get URL on click -
in as3 on click have 2 buttons , b, in movieclip when user click on button movie playing , want when if user click on button movie should play , when reach frame number 59 run geturl(abcd.html) , if user click button b reach fram 59 , geturl(xyz.html) both urls different
create variable hold result of button clicked. like...
int buttonclicked = -1; // assuming movie clip called 'movieplayermovieclip' movieplayermovieclip.stop();
then on buttons set value of said variable, 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 movie clip play movieplayermovieclip.play(); }
the movie clip should have on enter frame handler, 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"); } } }
Comments
Post a Comment