A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [MX] Functions and parentheses

  1. #1
    Junior Member
    Join Date
    Jun 2003
    Location
    New York City
    Posts
    14

    [MX] Functions and parentheses

    Sorry to ask what may be a dumb question, but I've looked around and I cannot find any documentation on this: What's the deal with functions and parentheses in actionscript? Maybe it's because I'm primarily a PHP guy, but I find the behavior strange. For example, I tried:

    mc_name.onRelease = function_name(parameter);

    And the movie wouldn't wait for any clicking or releasing, it would execute the function immediately. After trying many things for many hours, I finally tried:

    mc_name.onRelease = function_name; //no parentheses

    And this works. (I figured out a work-around for passing parameters.)

    Is this well-known, stable, ordinary Flash behavior? Or have I somehow landed in a slippery, weird universe full of unpredictabilities and mirages?

    Thanks for any comments that may shed light and decrease angst.

  2. #2
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Alas, this how it's always worked, for one reason or another. I've never been able to figure out either why it doesn't work the way you initially tried. If you have a function without parameters you can assign them directly to event handlers, but if you need to pass parameters, i've found the simplest way is this.

    PHP Code:
    mc_name.onRelease = function(){ function_name(param1,param2); } 
    Not too much extra work.

  3. #3
    Junior Member
    Join Date
    Jun 2003
    Location
    New York City
    Posts
    14
    Nice workaround. Many thanks for that and the sanity check!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center