View Full Version : controlling a loaded movie
Alber Kidd
August 21st, 2008, 08:47 AM
I am loading external swfs with loader
var myRequest:URLRequest = new URLRequest("main.swf");
var myLoader:Loader = new Loader();
myLoader.load(myRequest);
The problem is I need to do two things.
(i) control the timeline of my loaded swf things like gotoframe(10), play stop etc.
(ii) determine what frame it is currently on.
I suppose I need to turn my loading swf into a MC then do some on the other things.
Help would be much appreciated.
fexii
August 21st, 2008, 10:54 AM
Yes you're right, to perform operations you should cast the loaded object to a MovieClip. To do that, you have to attach an event listener to the loader's contextLoaderInfo that listens for Event.COMPLETE, which occurs whenever the loading of the .swf is done.
loader.contextLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);
In order to convert the asset to a MovieClip, your event handling function might look something like:
function loadComplete(e:Event):void
{
var loader:Loader = e.target.loader;
var movie:MovieClip = loader.content as MovieClip;
doSomething(movie);
}
Now you'll be able to access all the movie's properties, including currentFrame and gotoAndPlay.
maikl
August 23rd, 2008, 11:56 AM
What about the same problem but using AS2?
jensou
November 2nd, 2008, 04:17 PM
I'd really like to know this using AS2 as well. :puzzle:
stringy
November 2nd, 2008, 05:00 PM
I'd really like to know this using AS2 as well. :puzzle:
You just have to wait until it loads basically the same
var mc:MovieClip = this.createEmptyMovieClip("mc", 1);
mc._alpha = 0;
mc.loadMovie("http://www.kirupa.com/developer/mx2004/pg/kresge.jpg");
f();
function f() {
}
onEnterFrame =function (){if(mc.getBytesLoaded>=mc.getBytesTotal){;
fade();
};
};
};
function fade() {
mc._alpha += 5;
if (mc._alpha>=100) {
mc._alpha = 100;
delete this.onEnterFrame;
trace("done");
}
}
could also use MovieClipLoader.loadClip() and onLoadInit ()in the same way
numediaweb
December 25th, 2008, 10:15 AM
...the loader's contextLoaderInfo that listens...
you mean .contentLoaderInfo C:-)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.