Solved

Trying to return to menu after video ends

Posted on 2010-08-22
2
273 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Action Script commands 5 250
Failed download 57 592
What process can I use to achieve this? 5 130
High definition conversion videos in YouTube 12 301
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

739 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