i’ve got this code inside the MC that i’m attaching to the stage:
this.onLoad=function(){
//myName=this._name;
//trace(myName);
myColor = new Color(this);
myColor.setRGB(0xff0000);
}
this.onLoad();
this.onEnterFrame=function(){
myColor.setRGB(0x0000aa);
}
why doesnt’ this work? is it not seeing the vars named in onLoad because they’re name inside a function? i’m still fuzzy on this part of MX…
thanks in advance,
-mojo
system
February 9, 2003, 9:14pm
2
You are using two onLoads. you only need one.
You actually don’t need the onLoad
myColor = new Color(this);
myColor.setRGB(0xff0000);
this.onEnterFrame = function() {
myColor.setRGB(0x0000aa);
};
Also… why are you defining one color constantly onEnterFrame? you should just set that as the original color…
myColor = new Color(this);
myColor.setRGB(0x0000AA);
system
February 9, 2003, 9:27pm
3
so you just declare the new colors in AS and don’t need them in onLoad to init them? if this is so, why use onLoad at all? like i said, i’m still trying to figure the MX method out…
the reason for the enterFrame is that i’ll be changing the color dynamically, having it get its value from an array that i’m generating.
one thing i haven’t been able to figure out are listeners and how to subscribe events to variables–could you please explain this?
thx,
-mojo
system
February 9, 2003, 11:26pm
4
onLoad is when you are loading things in dynamically usually.
Things like loadVars(), XML(), etc use it to detect if the file is loaded.
And you don’t need an onEnterFrame to dynamically change a color. You can just define a function that gets called on when the color is changed.
Check my attachment to see my babbling in action.
system
February 9, 2003, 11:37pm
5
er…when i try to download it, my system reads it as ‘attachment.php’ and can’t grok the filetype (i’m running explorer on osx.2)???
system
February 9, 2003, 11:45pm
6
Ok, I .zipped it then. It should work now.
And as for Listeners… I learned about them from the AS dictionary…
http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/
Just look for addListener, next to that they will tell you how to use listeners with these methods…
FStyleFormat.addListener, Key.addListener, Mouse.addListener, Selection.addListener, Stage.addListener, TextField.addListener.
system
February 10, 2003, 12:11am
7
got it…thanks for the pointers :goatee:
system
February 10, 2003, 3:53am
8
No problem I hope they help you out
system
February 10, 2003, 8:24am
9
One thing: onLoad doesn’t work so well. There’s a fix in the Best Of Kirupa forum. But as Lost said, you don’t need it here
system
February 10, 2003, 8:33am
10
Oh wow, I didn’t know there was a bug with onLoad, thanks for pointing that thread out Ilyas, definitely taught me something