PDA

View Full Version : Binding function names to array elements?


freon22
09-16-2009, 11:08 AM
Okay I have a quandry and I'm not sure if I'm doing this correctly.

I have a canvas that upon creationComplete goes through an effect. For instance I have a zoom effect when it comes onto the stage now.

I also have 5 other custom effects I've coded from which I'd like to choose from randomly when the canvas hits creationComplete.

I was thinking if I could bind the functions to array elements and create another function to generate one of them from the array upon creationComplete, but I'm not sure how I would go about this.

I'm not sure if I would be going about this the right way. If anyone has any suggestions I would love to hear them, or any advice on how I should randomize these functions, I would truly appreciate it.

wvxvw
09-16-2009, 02:25 PM
function a():void { trace("a"); }
function b():void { trace("b"); }
function c():void { trace("c"); }
var array:Array = [a, b, c];
array[2]();

freon22
09-17-2009, 02:07 AM
function a():void { trace("a"); }
function b():void { trace("b"); }
function c():void { trace("c"); }
var array:Array = [a, b, c];
array[2]();


Ahh see I forgot to trace the the function names at the end. Seriously thank you for the help I really appreciate it.