Solved

Trying to return to menu after video ends

Posted on 2010-08-22
2
274 Views
Last Modified: 2013-11-11
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

0
Comment
Question by:Steve Brame
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
IqAndreas earned 500 total points
ID: 33496099
First of all, if you debug by pressing "CTRL+SHIFT+ENTER", Flash will tell you the EXACT line that your error is at, which will make debugging a lot easier.

Second, the error is likely caused because you are trying to access a MovieClip or video from a different frame than the one you are on. Sadly, Flash only allows you to access items that are on the same frame as you, so you either need to move the conflicting lines of ActionScript to those lines where the items are on the stage.

Or you need to create those MovieClips manually inside of AS3. The second method is more difficult if you don't have previous experience with creating classes, which can be a bit difficult for beginning Flash users.


If that still doesn't solve the issue, copy and paste the exact error message you get by pressing "CTRL+SHIFT+ENTER" to debug.
0
 

Author Closing Comment

by:Steve Brame
ID: 33496172
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!
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question