Return to Snippet

Revision: 19425
at October 23, 2009 10:30 by weavermedia


Updated Code
// you might want to call a function but you have the function name as a string, this is how to do it
// Create new :Function var and give it the string using this[]

for(i=0; i<4; i++)
{
  var funcName:Function = this["func"+i];
  funcName(param1, param2);
}

function func0(p1, p2)
{

}

function func1(p1, p2)
{

}

function func2(p1, p2)
{

}

function func3(p1, p2)
{

}

Revision: 19424
at October 23, 2009 10:29 by weavermedia


Updated Code
// you might want to call a function but you have the function name as a string, this is how

for(i=0; i<4; i++)
{
  var funcName:Function = this["func"+i];
  funcName(param1, param2);
}

function func0(p1, p2)
{

}

function func1(p1, p2)
{

}

function func2(p1, p2)
{

}

function func3(p1, p2)
{

}

Revision: 19423
at October 23, 2009 10:28 by weavermedia


Initial Code
for(i=0; i<4; i++)
{
  var funcName:Function = this["func"+i];
  funcName(param1, param2);
}

function func0(p1, p2)
{

}

function func1(p1, p2)
{

}

function func2(p1, p2)
{

}

function func3(p1, p2)
{

}

Initial URL


Initial Description


Initial Title
AS3 Converting a String to a Function name

Initial Tags


Initial Language
ActionScript 3