The disadvantage of the Loadmovie method is that it is not possible to set the properties of the MC that import movie directly after the statement, which provides a practical method.
The class files are as follows:
Import Mx.events.EventDispatcher;
Class Myloadmovie {
public Var addeventlistener:function;
public Var removeeventlistener:function;
private Var dispatchevent:function;
private static var _mixin1 = Eventdispatcher.initialize (Myloadmovie.prototype);
function Myloadmovie () {
}
Public Function GetAt (url:string, mc:movieclip): void{
var onwer:object = this;
Mc.loadmovie (URL);
var myload:movieclip = _root.createemptymovieclip ("Myload", 10);
Myload.onenterframe = function () {
var tb:number = Mc.getbytestotal ();
var lb:number = mc.getbytesloaded ();
var percent:number = Math.Round (lb/tb*100);
if (percent = = and lb>1000 and tb>1000 and mc._width>0 and mc._height>0) {
Onwer.dispatchevent ({type: "onloaded", TARGET:MC});
Delete This.onenterframe;
}
}
}
}
This file should be put together with your FLA file.
How to use:
Import Myloadmovie;
var Mi:myloadmovie = new Myloadmovie ();
Mi. GetAt ("Mm.jpeg", MC);
var obj:object = new Object ();
Obj.onloaded=function (eventobj:object): void{
var thismc:movieclip = Eventobj.target;
thismc._x=300;
thismc._y=100;
Thismc._alpha = 50;
}
Mi.addeventlistener ("onloaded", obj);
Note: Mi. The MC in GetAt ("Mm.jpeg", MC) is the name of the movie clip on the stage or dynamically established. Which is the MC you want to Loadmovie.