> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Alistair Colling > Sent: 03 May 2007 15:27 > To: flashcoders@chattyfig.figleaf.com > Subject: [Flashcoders] Syntax for dynamically calling a function > > 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()
Nearly right: this._parent[label]() Danny _______________________________________________ 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