all groups > flash actionscript > may 2007 >
You're in the

flash actionscript

group:

set property after loadClip


set property after loadClip jgomula
5/31/2007 7:54:49 PM
flash actionscript:
Hi Community!

I am trying to use loadClip to randomly load in an external SWF (this part
works great) and then to adjust the alpha of the loaded clip (ultimately I'll
have the alpha adjusted according to the level the clip loads on, so different
clips will have different alphas). Can't seem to change any property of the
loaded clip, please help!

Thanks!!

:grin;



////////////////////////// loading movies and randomness
var levelNumberCamera = Number;
levelNumberCamera = 10;
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
//do something
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
//do something
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
this._alpha = 40;
};
var myMCL2:MovieClipLoader = new MovieClipLoader();
myMCL2.addListener(mclListener);


var cameraOn = function(){
levelNumberCamera += 1;
load_which_one = Math.round((Math.random()*15));
load_this_one = "camera-trigger" + load_which_one + ".swf";
myMCL2.loadClip(load_this_one,levelNumberCamera);
};


/////////////////////button trigger
myButton.onRelease = function() {
cameraOn();
};
Re: set property after loadClip Rothrock
5/31/2007 10:51:14 PM
Well you made it over the first hurdle! The alpha won't work in the
onLoadComplete, so it is good that you have it in the onLoadInit.

But look at how you've done this. You say this._alpha, but if you add this
line:

trace("current scope is: "+this);

You will see that this isn't refering to what you think it is.

Instead you want to use the target_mc returned by the event. So

target_mc._alpha=40;

should do the trick!
Re: set property after loadClip jgomula
6/1/2007 12:21:41 AM
AddThis Social Bookmark Button