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
Solved

Trying to return to menu after video ends

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SCCM 2012 - Deploy Flash 16 7,024
Removing Flash from Website 6 69
HTML 5 video and audio or Flash 1 60
Can't enable Flash on Chrome 32 Windows 7 any more 2 24
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

839 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