Hi everbody,
I created a simple loader and converted it to a component.
I can place it in a timeline, and in the actions layer write this code:
this.onMouseUp=function(){
loader_mc.the_mcl.loadClip("image.jpg", loader_mc._parent.holder_mc);
}
But if I try to do the same without the onMouseUp, as below, it does not work:
loader_mc.the_mcl.loadClip("image.jpg", loader_mc._parent.holder_mc);
I am using a MovieClipLoader object inside the loader.
Could anyone please help me figuring out what I amsoing wrong?
Thanks
The code in your component executes after that in your root timeline unless you use:
[LIST=a]
[]a compiler directive (#initclip and #endinitclip) to have the code compiled before the movie starts
[]an AS2 class which is exported before the first frame by default[/LIST]So my question is, have you used one of the above methods?
I don’t know how to use any of those ways…
Do you know of any tutorial on how to do it?
Thanks,
Here are some tutorials, but since you don’t know what either of those methods are I’m assuming that maybe you haven’t set up your component in the way where they would work/be needed. Maybe you should post your FLA.
http://www.kirupa.com/developer/oop/index.htm
http://www.kirupa.com/developer/oop2/AS2OOPindex.htm
Unfortunately you component isn’t object-oriented because it isn’t structured around a MovieClip subclass so there is nothing you can really do except wait a frame for the code to be executed OR read those tutorials I posted and start OOP.
Here’s the quick fix which is actually very un-OO but gets the job done and allows you to read those tutorials fix it up yourself - it also allows me to do less work :hugegrin:
#initclip
LoaderClass = function () {
this.the_mcl = new MovieClipLoader();
this.the_listener = new Object();
the_mcl.addListener(the_listener);
the_listener.onLoadError = function(mc) {
percent_txt.text = "Error";
};
//
the_listener.onLoadProgress = function(mc, loadedBytes, totalBytes) {
var nPercent:Number = Math.round((loadedBytes / totalBytes) * 100);
percentBar_mc._width = nPercent;
percent_txt.text = nPercent + "%";
};
//
the_listener.onLoadStart = function(mc) {
mc._alpha = 0;
};
//
the_listener.onLoadComplete = function(mc) {
showLoadedInt = setInterval(showLoaded, 50, mc);
};
};
LoaderClass.prototype = new MovieClip();
Object.registerClass("tabs_loader6", LoaderClass);
LoaderClass.prototype.showLoaded = function(mc) {
trace("cojones");
mc._alpha += 10;
_root.loader_mc._alpha -= 10;
if (mc._alpha >= 100) {
mc._alpha = 100;
clearInterval(showLoadedInt);
message_txt.text = "";
}
updateAfterEvent();
};
#endinitclip
Wow, thanks a lot, I will study those tutorials. I am still learning…