A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] triggering a function via...

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    18

    resolved [RESOLVED] triggering a function via...

    Is it bad to trigger a function via code like this:

    myfunctio(null);

    If it it bad, why is it bad. This could be very handy for me.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    If myfunctio handles null gracefully, then there's no reason not to do that. Why would you think it would be a problem?

    If myfunctio is an event listener, then instead of this:
    Code:
    function myfunctio(e:Event):void{
      //code which doesn't use e
    }
    you might want to do this:
    Code:
    funciton myfunctio(e:Event = null):void{
      //code which does not use e
    }
    Which would let you call myfunctio like this:
    Code:
    myfunctio();

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    18
    Cool, thanks for that. It just seems like I read somewhere that coding like that was bad form or something. Just wanted to be sure I wasn't going down a bad road before I got too deep. Thanks again.

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