2 Replies Latest reply on Feb 24, 2008 7:19 PM by Newsgroup_User

    Actionscript is wrong?

      Below is a piece of working script I found on the internet:

      on (release) {

      This code means that 'When the corresponding button is released, the following happens:'. This code works fine.

      However, if one selects 'onRelease (Button)' from the actionscript menu, they are presented with this:

      not_set_yet.onRelease = function() {

      It's not even vaguely reminiscient of the previous script. This script is also found in the help file under 'onRelease'. This script does not work; no matter what you do to it (Short of editing it so much that it is identical to the other script) the script just gives you an error alert. Now, what's going on here? Firstly, why did Macromedia add this phony code to their actionscript library? Where did it come from? Surely it must have originated from somewhere. Secondly, why has Adobe not fixed this problem in Flash 9, where the same problem still exists!? Were there no reports of this? I find that hard to believe.

      If this code truly is correct, and I'm somehow using it wrongly despite following the exact tutorial of the help file, then why does the code at the top of this post work as well? If the one in the actionscript library works, why is there a much simpler line of code that performs the same function perfectly?

      I will say, hats off to whomever first managed to create the working script.

      I'm not sure what responce I'm hoping to get on this, it just confuses me. Can anyone shed any light on this?
        • 1. Re: Actionscript is wrong?
          kglad Adobe Community Professional & MVP
          the 2nd code works perfectly well and has significant advantages over the code you're attaching directly to your button/movieclip. you just need to use something meaningful instead of "not_set_yet" which was chosen to prompt you to realize you still needed to do something.
          • 2. Re: Actionscript is wrong?
            Level 7

            kglad nailed it:

            > the 2nd code works perfectly well and has significant advantages
            > over the code you're attaching directly to your button/movieclip.

            The on() and onClipEvent() approaches require direct attachment of code,
            in which case the intended recipient of your instructions is obvious. If
            you're using the dot notation approach, code goes into a keyframe instead,
            so Flash needs a way to know which object you're talking about. That
            "not_set_yet" reference, as kglad pointed out, means that you haven't yet
            associated the event handler -- here, onRelease -- with an object, such as a
            button or movie clip. To make that association, you need to give your
            object a unique instance name. One way to do that is to select the object
            and look at the Property inspector. You'll see the instance name input
            field in the upper left corner.

            Here are a few additional notes on making this switch, which, just so
            you know, becomes required in ActionScript 3.0.


            David Stiller
            Co-author, Foundation Flash CS3 for Designers
            "Luck is the residue of good design."