Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-13-2012, 10:13 PM   #1
arpeejajo
Registered User
 
Join Date: Mar 2011
Location: Woodbridge, ON
Posts: 7
Default Error with stopping sound

I want the video to stop the sound once it enters a certain frame. This is the code I used.

myChannel4.stop();

This is the error I get.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at RyuvsKenPrologue_fla::MainTimeline/frame6202()[RyuvsKenPrologue_fla.MainTimeline::frame6202:1]
arpeejajo is offline   Reply With Quote
Old 04-13-2012, 11:13 PM   #2
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,426
Default

Keyframes are essentially like sealed boxes of objects and code, similar to a MovieClip or Sprite class.
When you move the main playhead to a new keyframe, the data from the previous keyframe is no longer accessible.
This is one the problems with using the timeline for application states (or pages).

One solution is to build your application states within a MovieClip on frame1 of the main timeline and write your code on frame1 of the main timeline.
Since the main playhead never moves, the connection to the MovieClip is never broken.
The main code can be reached from the MovieClip via AS3 Event flow.

Another option is to write your main AS3 code on a layer that extends to the last frame of the main timeline.
ie: you would have 2 layers of code; a layer with keyframes for each page and a "global" layer accessible to the entire project from which you could access and control the music player. This approach usually results in decentralized "spaghetti-code" and a long main timeline that is tedious to edit and extend.

Personally, I find both of the preceding approaches to be less appealing than adding/removing movieclips or swf files, or just using structured classes to define the entire project. The timeline is for building animations.
[afz]snickelfitz is offline   Reply With Quote
Old 04-14-2012, 02:58 AM   #3
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

When working with frames you often have to do whatever you need to do prior to moving to the next frame and not after.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 04-14-2012, 03:29 AM   #4
arpeejajo
Registered User
 
Join Date: Mar 2011
Location: Woodbridge, ON
Posts: 7
Default

Thanks, for clearing that up. I got it to work now.
arpeejajo is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:08 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.