Solved

Trying to return to menu after video ends

Posted on 2010-08-22
2
267 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:sebrame
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:sebrame
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now