Self-writing Myloadmovie to remedy the ills of Loadmovie methods

Source: Internet
Author: User

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.