Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-23-2012, 08:22 AM   #1
kench928
Registered User
 
Join Date: Sep 2011
Location: Hong Kong
Posts: 13
Default Passing multiple parameters to function

Is it possible to pass more than one variable to a function?
As an array or anything else?

The variables may sometimes only one, sometimes more than three, etc.

Would very appreciate if someone can modify the code, thanks a lot!

ActionScript Code:
disableKey("key1", "key2", "key3") function disableKey(target:Array){        for(var i=0; i<target.length; i++){             target[0].doSth;        } }
kench928 is offline   Reply With Quote
Old 06-23-2012, 09:46 AM   #2
www.creative-geeks.com
Registered User
 
Join Date: Jun 2012
Location: http://www.creative-geeks.com
Posts: 3
Exclamation

Hi Kench,

Please see below on the best approach
You basically had the right idea on solving your issue.
You just have to pass 1 variable to the function, an Array with the controls.

Code:
// pass one variable to the function : an Array with the controls you want to adress
disableKey(["key1", "key2", "key3"])

function disableKey(target:Array){
       for(var i=0; i<target.length - 1; i++){ // Array is 0 based, so loop the length minus 1
            doSomeThins(target[0] as DisplayObject);
       }
}

private function doSomeThins(control:DisplayObject):void{
      trace('do something with control : ' + control);
}
www.creative-geeks.com is offline   Reply With Quote
Old 06-23-2012, 02:05 PM   #3
kench928
Registered User
 
Join Date: Sep 2011
Location: Hong Kong
Posts: 13
Default

Thank you so much!
kench928 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:14 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.