[CS3] AS2 Funcion calling in a Function with Variables

Hi,

I’m trying to get this one function to be able to call many functions (not at once, but call many possible ones)

In other words, I’m trying to get this variable to be named as a function. That way, this one variable can create multiple functions.

example:


class Thing extends MovieClip
{
    var funcvar;
    var othervar;
    function onLoad()
    {
        funcvar = "YYY";
        othervar = "ZZZ";    
    }
    function onEnterFrame()
    {
        if(Key.isDown(Key.SPACE))
        {
            trace("1a: "+_root.thing.funcvar+"////b: "+_root.thing.othervar)
            // XXX is a function 
            //and funcvar is a variable (that wants to be called as a function) 
            //and othervar is the other variable
            XXX(funcvar,othervar) //if you change funcvar to YYY it will work
        }
        if(Key.isDown(Key.CONTROL))
        {
            if(funcvar == "YYY")
            {
                funcvar = "AAA";
                othervar = "BBB";
            }
            else
            {
                funcvar = "YYY";
                othervar = "ZZZ";
            }
            trace("CHANGED!: "+_root.thing.funcvar+"////b: "+_root.thing.othervar);
        }
        function XXX(newfunc,newvar)
        {
            trace("2a: "+_root.thing.funcvar+"////b: "+_root.thing.othervar)
            newfunc(newvar);
        }
        function YYY(newvar)
        {
            trace("3a: "+_root.thing.funcvar+"////b: "+_root.thing.othervar)
            if(newvar == "ZZZ")
            {
                trace("FUNCTION Y: good job!");
            }
        }
        function AAA(newvar)
        {
            trace("FUNCTION A: how did you do it?");
        }
    }
}

I think the reason this doesnt work is because the value of funcvar is in a text format while YYY is not. This is why -> if(newvar == “ZZZ”) is still true because newvar is in a text format (and so is the variable othervar)

But if you know a way to get around this, any suggestion is appreciated.
Thanks