ActionScripting tips
One of our Component Support Specialists, Meng, sent this out to the creative services team. I think this is something helpful for all AdWonder users, check it out:
The differences between on (release) and mybutton_btn.onRelease() = function
When we code something as a FRAME actionscript such as:
var clicked = false;
mybutton_btn.onRelease () = function() {
clicked = true;
}
This code snippet will perform the follow task: set the value of the Boolean variable clicked to true
But in ActionScript, there’s always two ways to accomplish the same task using different ways, such as a CLIP ActionScript (the script is on the _btn)
on (release) {
clicked = true;
}
This code snippet will “seem” to perform the same task as above, but in practice, because it’s embedded in a on (release) handler, the scope of the function is now WITHIN the button object, so clicked = true; only creates a local variable named clicked and names it to true, instead of setting the _root.clicked to true. The correct code should be _root.clicked = true;
on (press) vs. on (release)
on the surface it’s the same, a mouse click event capture function, but the other than the major difference of on(press) will trigger upon mouse button “down” and on (release) will only fire with the mouse button “up” action, in practice they induce very different effects.
For example:
on (press) { EW.clickThru(“clickTag1”, “button click”); } //This will be caught with a variety of browser’s popup blocker
on (release) { EW.clickThru(“clickTag1”, “button click”); } //This is much safer and usually will not be blocked
