Hi there
I’m having trouble with a function and an onRelease event handler that calls it.
The code goes like this:
function setAlpha(clip, value){
_root.clip._alpha = value;
}
Then the function gets called like this:
_root.chp1_btn.onRollOver = setAlpha(chp1_mc, 50);
What I am finding is that the function is not working properly. THe function sort of executes without waiting for the event handler to trigger it.
If I put a trace(“hello”); command in the function, it traces instantly when I test the movie. I want the function to wait until I rollover chp1_btn instance.
Any clues as to what I am missing would be greatly appreciated.
BOngoMan
bongoman:
Change your code:
_root.chp1_btn.onRollOver = setAlpha(chp1_mc, 50);
to:
chp1_btn.onRollOver = function() {
setAlpha(chp1_mc, 50);
}
Hope it helps! :thumb:
Cheers!
Thank you - that worked!
But why? I’m trying to really understand actionscript: why was my earlier code wrong?
Cheers
Bongoman
I am new to Flash MX but as far as I am concerned and understood, InstanceName.onRollover, or InstanceName.onEnterframe, etc. are reserved commands that works the same as onClipEvent… err… hehehe… hope i’m right… Therefore, instead of using onClipEvent command, you use in one frame:
_root.instanceName.onEnterframe = function() {
… your commands…
}
_root.instanceName.onRollover = function() {
… your commnds…
}
etc…
Hope it helps. Hehehe… 