Share Posted September 11, 2012 Hello, I'm working on a project that consists of a VideoLoader that when paused loads a SWF on top. I need to dispatch removal of the SWFLoader and resume the video beneath. I have my play/pause working with the Video Loader and I even have the SWFLoader appearing, but I'm not sure how to clear it and return to the video. I've created a "removeStill" mouse event with the following code: if (previousCuePointFired=="cue2") { trace("LOAD Cue2 SWF"); stillSWF = new SWFLoader("assets/stills/a1.swf", {name:"pannerSWF", container:this, x:0, y:0, onInit:initHandler, estimatedBytes:20480}); stillSWF.load(); setChildIndex(loader.content, 0); } } function initHandler(event:LoaderEvent):void { //fade the swf in as soon as it inits TweenLite.from(event.target.content, 1, {alpha:0}); swfBTN.visible = true; swfBTN.addEventListener(MouseEvent.CLICK, removeStill); } function removeStill(e:MouseEvent):void { swfBTN.visible = false; stillSWF.dispose(); resume(); } My error is: Error #1010: A term is undefined and has no properties. at pages::ProductAPage/removeStill() I have been successfully clearing audio and video assets with dispose();, but now I'm stuck. Not sure if this is the most efficient way to build my project, but here is the full code if interested: package pages { import com.gaiaframework.templates.AbstractPage; import com.gaiaframework.events.*; import com.gaiaframework.debug.*; import com.gaiaframework.api.*; import flash.display.*; import flash.events.*; import com.greensock.TweenMax; import com.greensock.*; import com.greensock.loading.*; import com.greensock.loading.display.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.VideoLoader public class ProductAPage extends AbstractPage { public var pauseBTN; public var playBTN; public var swfBTN; public var mainVideo; public var videoFlash; public var bgAudio; public var filmAudio; public var stillSWF; //create a var to track the name of each cuePoint as it is fired public var previousCuePointFired:String; public function ProductAPage() { super(); alpha = 0; } override public function transitionIn():void { super.transitionIn(); TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete}); pauseBTN.buttonMode = true; pauseBTN.useHandCursor = true; playBTN.buttonMode = true; playBTN.useHandCursor = true; swfBTN.buttonMode = true; swfBTN.useHandCursor = true; pauseBTN.addEventListener(MouseEvent.CLICK, onPause); playBTN.addEventListener(MouseEvent.CLICK, onPlay); swfBTN.visible = false; initVideo(); //Begin listening for cuepoints and store them with the following onCue function mainVideo.addEventListener(VideoLoader.VIDEO_CUE_POINT, onCue); } function onCue(e:LoaderEvent):void { trace("cuepoint fired: " + e.data.name); //store your cue point name to be recalled as "previousCuePointFired" previousCuePointFired = e.data.name; } function initVideo():void { //create a VideoLoader mainVideo = new VideoLoader("assets/Liberation.f4v", { name:"mainVideo", container:this, bgColor:0x000000, scaleMode:"proportionalInside", autoPlay:true} ); //Loading video and set to bottom of display stack mainVideo.load(); setChildIndex(mainVideo.content, 0); } function onPause(e:MouseEvent):void { pauseBTN.visible = false; playBTN.visible = true; //tween the video volume down to 0 over 1 second with onComplete call for pause TweenLite.to(mainVideo, .5, {volume:0, onComplete: soundFadeComplete}); //Launch next functions initFlashFX(); } function soundFadeComplete():void { mainVideo.pauseVideo(); //Call last cuepoint if paused and check for which swf to load if(mainVideo.pauseVideo) { trace("previousCuePointFired = " + previousCuePointFired); initCue(); } //Load background audio (-1 loops indefinitely) bgAudio = new MP3Loader("assets/bg_loop.mp3", {autoPlay:true, volume:.6, repeat:-1} ); bgAudio.load(); } //--------------------------------Call to load based on last/current cuepoit--------------------------------// function initCue():void { if (previousCuePointFired=="cue1") { trace("LOAD Cue1 SWF"); var loader:SWFLoader = new SWFLoader("assets/stills/a1.swf", {name:"pannerSWF", container:this, x:0, y:0, onInit:initHandler, estimatedBytes:20480}); loader.load(); setChildIndex(loader.content, 0); } if (previousCuePointFired=="cue2") { trace("LOAD Cue2 SWF"); stillSWF = new SWFLoader("assets/stills/a1.swf", {name:"pannerSWF", container:this, x:0, y:0, onInit:initHandler, estimatedBytes:20480}); stillSWF.load(); setChildIndex(loader.content, 0); } } function initHandler(event:LoaderEvent):void { //fade the swf in as soon as it inits TweenLite.from(event.target.content, 1, {alpha:0}); swfBTN.visible = true; swfBTN.addEventListener(MouseEvent.CLICK, removeStill); } function removeStill(e:MouseEvent):void { swfBTN.visible = false; stillSWF.dispose(); resume(); } //Fancy pause screen flash function initFlashFX():void { videoFlash = new VideoLoader("assets/Flash_1.flv", { name:"vidFlash", container:this, scaleMode:"proportionalInside", autoPlay:true} ); //start loading and set to bottom of display stack videoFlash.load(); setChildIndex(videoFlash.content, 1); TweenMax.to(this, 1, {onComplete:flashComplete}); filmAudio = new MP3Loader("assets/filmSound.mp3", {autoPlay:true, volume:.8, repeat:0} ); filmAudio.load(); } //Clean up screen flash child... might not need this function flashComplete():void { removeChildAt(1); filmAudio.dispose(); } function onPlay(e:MouseEvent):void { pauseBTN.visible = true; playBTN.visible = false; mainVideo.playVideo(); //Fade volume in over 1 second to 100% (1) TweenLite.to(mainVideo, 1, {volume:1}); //Remove backgound audio bgAudio.dispose(); } function resume():void { mainVideo.playVideo(); //Fade volume in over 1 second to 100% (1) TweenLite.to(mainVideo, 1, {volume:1}); //Remove backgound audio bgAudio.dispose(); } override public function transitionOut():void { super.transitionOut(); TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete}); } } } Link to comment Share on other sites More sharing options...
Share Posted September 11, 2012 Not really sure. It looks like you are calling bgAudio.dispose() twice; once in onPlay() and again in resume() Once something is disposed, it doesn't exist and can't be disposed again. That's the only thing that jumps out at me, and its possible I am misunderstanding how everything is supposed to work. Link to comment Share on other sites More sharing options...
Author Share Posted September 11, 2012 Hi Carl, I have the resume(); function and the onPlay() function because the SWFLoader only appears when the video is paused at a certain cue point. When it's paused without the SWFLoader, onPlay(); works just fine, but once I load the SWF, I have a separate function resume() to try and clear the SWF and then get us back to the video again. Everytime the video is paused, the bgaudio plays, so I'm calling bgAudio.dispose() anytime the video is "un-paused". Again, this all works until the SWF is loaded, then I'm not sure how to remove it. Would that normally be dispose like any other loader? Link to comment Share on other sites More sharing options...
Share Posted September 13, 2012 If you are going to be using the audio more than once, you shouldn't be dispose()-ing it. When you dispose() something it gets rid of it. I think you just need to pauseSound(null) instead of dispose(). You reported having an error in the removeStill() method because a term was undefined. In order to get past that error I would suggest adding some traces in that function. function removeStill(e:MouseEvent):void { trace("swfBTN = " + swfBTN); trace("stillSWF = " + stillSWF); swfBTN.visible = false; stillSWF.dispose(); resume(); } that should help figure out which object is causing the error. Again, if bgAudio() has previously been disposed, I imagine that is what is wrong. -c Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now