I don't think you can create dynamic functions.. even if you could, I
don't see the need to.

use your arguments to make your functions all-purpose.

Ex.

function onBtnPress(n:Number):Void
{
 trace(n + " was pressed.");
}

button0.onRelease = Delegate.create(this, onBtnPress, 0);
button1.onRelease = Delegate.create(this, onBtnPress, 1);

On 8/12/06, Bbt Lists <[EMAIL PROTECTED]> wrote:
Hi there....

Can you write dynamic methods in a class?


for example

for (var i:Number = 0; i < 11; i++)
{
    function onBtnPress + i()
    {
       trace("Button number: " + i + "was pressed");
    }
}

So then that would essentially create 10 methods (onBtnPress0 to
onBtnPress9) to be used by various onPress events.

Is this possible? Then at the same time you could write the delegate and
create the buttons and so one as well.

Then continuing on my thought - could you then over-write the onBtnPress
functions with new values (say for example the trace would be:

trace("Button number: " + i + "was pressed with the currValue of " +
externalVariable);

instead of the original:

trace("Button number: " + i + "was pressed");


I am a hobby AS coder, and I am probably way off here. All I am trying
to do is build a thumbnail nav for a gallery.

Thanks in advance!

--
dnk

--
Ramon Miguel M. Tayag
_______________________________________________
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