You could do something like this:

class Something
{
   method1();
   method2(a_number:Number);
}

Somewhere else:
var method_str:String = "method1";
var sm:Something = new Something();

sm[method_str](); // Will call method1 class method
sm["method2"](0x09F911029D74E35BD84156C5635688C0); // Also works ;-)

Ciao,
Rob.

Alistair Colling wrote:
Hi there, I want to call a function but want to able to call it dynamically so a string that is passed will determine which function is called. My reason for this is I have an interface with a number of buttons that have different labels but that look the same and need to call different functions. I was going to make one button and duplicate it then name it so it will call a function depending on what it's name is. My code would go something like this:

///////inside 'button' MC named 'pictures'
var label:String = this._name

this.onPress = function(){
//want to call function from here, dictated by the name of the MC, not sure of this sytanx
    this._parent.label()
}
////////////////main timeline
function pictures(){
//to be called from pictures button onPress event
}
///////////
Any suggestions much appreciated!
Ali





_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


--No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.6.2/781 - Release Date: 4/30/2007 9:14 AM



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to