Link to home
Start Free TrialLog in
Avatar of Steve Brame
Steve BrameFlag for United States of America

asked on

Trying to return to menu after video ends

I have a very simple bit of AS3 that I can't get to work. I have 4 FLVPlayBack's on 4 frames, buttons on a menu to go to the frames to play the videos, and I need to return to the menu's frame after the videos end. Here's what I have. The buttons to play the videos work, but the function to return to the menu isn't firing. I'm also getting this error as the program starts. Not sure if this has anything to do with it.

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

iimport fl.video.VideoEvent;
stop();

//button listeners

btn_tour.addEventListener(MouseEvent.CLICK, tourClick);
btn_history.addEventListener(MouseEvent.CLICK, historyClick);
btn_quality.addEventListener(MouseEvent.CLICK, qualityClick);
btn_song.addEventListener(MouseEvent.CLICK, songClick);

//video end listeners

tourVideo.addEventListener(VideoEvent.COMPLETE, backtomenu);
historyVideo.addEventListener(VideoEvent.COMPLETE, backtomenu);
qualityVideo.addEventListener(VideoEvent.COMPLETE, backtomenu);
songVideo.addEventListener(VideoEvent.COMPLETE, backtomenu);

//button functions

function tourClick(event:MouseEvent):void{ gotoAndStop("tour"); };
function historyClick(event:MouseEvent):void{ gotoAndStop("history"); };
function qualityClick(event:MouseEvent):void{ gotoAndStop("quality"); };
function songClick(event:MouseEvent):void{ gotoAndStop("song"); };

//head back to menu function

backtomenu(){
    trace ("Video ended!");
   gotoAndStop("menu");
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of IqAndreas
IqAndreas
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve Brame

ASKER

Sleep deprivation = stupid code errors.

Yeah, I'd had a revelation about an hour ago that the functions needed to be on the frames that held the FLVPlayBacks. This was after an all-nighter. It's a wonder I can even read at this point.

Everything's working now. Thanks a lot!