PDA

View Full Version : Stop added Child swf movieClip


Vudrok
06-10-2008, 02:49 PM
Hi, okay I got an issue with my imported SWF files, i got a project were i'm using multiple swf files being managed by a main swf file that import into itself the other swf files, my problem is that I cannot control the imported swf files, i can't figure out how to target them and control them, the thing is that i got an intro animation for each swf, and while loading these animation will start playing and when my loading method finished loading it will addChild the swf and it will not display the starting animation cause this animation played already while loading, i'll add the code of my method and comment out what would i like to do on it, i hope someone can help me.



var someLoaded:Boolean = false;

function swfLoader(whichSWF:String, addTo:MovieClip):void {

if(someLoaded) {
//trace("the current MovieClip is: "+swfLoadit.name)
//trace("the loader has been unloaded");
addTo.removeChildAt(1);
//trace("the current MovieClip is: "+swfLoadit.name);
//trace("the child has been remove");
someLoaded = false;
}

var swfSource:URLRequest = new URLRequest(whichSWF);
var swfLoadit:Loader = new Loader();
swfLoadit.load(swfSource);

swfLoadit.contentLoaderInfo.addEventListener(Progr essEvent.PROGRESS, onProgress);
swfLoadit.contentLoaderInfo.addEventListener(Event .COMPLETE, onComplete);

function onProgress(e:ProgressEvent):void {
var prebytesTotal:Number = e.bytesTotal;
var prebytesLoaded:Number = e.bytesLoaded;
var percent:Number = Math.round((prebytesLoaded/prebytesTotal)*100);
loader_mc.visible = true;
loader_mc.percent.text = percent + "%";
//imported SWF.stop(); this is what i want to do... but how??
}
function onComplete(event:Event):void {
loader_mc.visible = false;
swfLoadit.contentLoaderInfo.removeEventListener(Pr ogressEvent.PROGRESS, onProgress);
swfLoadit.contentLoaderInfo.removeEventListener(Ev ent.COMPLETE, onComplete);
addTo.addChild(swfLoadit);
//imported SWF.play(); this is what i want to do... but how??
someLoaded = true;
}
}


Please all help will be highly appreciate it!! xD

Vudrok
06-10-2008, 03:38 PM
Okay I've been trying to find a work around my problem, and I manage to modify my onComplete function this way

function onComplete(e:Event):void {
loader_mc.visible = false;
swfLoadit.contentLoaderInfo.removeEventListener(Pr ogressEvent.PROGRESS, onProgress);
swfLoadit.contentLoaderInfo.removeEventListener(Ev ent.COMPLETE, onComplete);
someLoaded = true;
var loaderInfo:LoaderInfo = e.target as LoaderInfo;
var swf:Object = loaderInfo.content;
addTo.addChild(swfLoadit);
swf.alpha = .2;
swf.gotoAndPlay(1);
}

the alpha will actually change for the value I'm calling but the "gotoAndPlay(1)" or any timeline control will not work, it doesn't throw an error or anything, does anyone has the knowledge to help me?? please help :confused:

Vudrok
06-10-2008, 04:28 PM
Okay the correct way to do it is how I did it with the loaderInfo Object, the thing is that i was using a movieClip to create the intro animation and it was starting to play so I couldn't control it, now i reset it behavior and it works fine.

tommi
08-20-2008, 10:29 AM
Hi it appears you found the solution, but its not clear to me what it was.. :(

Can you please post your solution to stop() issue?



Here is my function but loaded video never stops.. :(

private function completeHandler(event:Event):void {
var loader:Loader = Loader(event.target.loader);
var im1:MovieClip = MovieClip(loader.content);

im1.stop();
addChild(im1);

}