I just created three textfields on the stage and named them fieldClip, fieldClip1 and fieldClip2. The following rewritten code of yours worked fine. Is this what you were trying to accomplish?

Gerry

<code>
function setTextColor(formatName, fieldClip, col, align) {
        formatName = new TextFormat();
       formatName.color = col;
       formatName.align = align;
        fieldClip.setTextFormat(formatName);
}
fieldClip.text = "testing color";
fieldClip1.text = "testing color 1";
fieldClip2.text = "testing color 2";
_root.onLoad = function(){
        setTextColor(myColor,fieldClip1,0x990000,left);
        
}
</code>

On May 22, 2006, at 11:04 AM, Brandon Krakowsky/MTC wrote:

Hello all. This is probably very simple. I'm trying to pass the instance
name of a textfield to a "setTextColor" function which applies a
TextFormat.  The function takes 4 parameters, the new format name, the
textfield instance name, the textfield color, and the textfield alignment. Everything is passed correctly except for the textfield instance name.
The absolute path is passed, which means "_level0." is appended to the
beginning of the full path.

So for instance, I pass "leftInfoClip.topLeftTabs.leftTab.tabTitle", where "tabTitle" is the actual textfield. when I pass it to the "setTextColor" function and trace it, "_level0.leftInfoClip.topLeftTabs.leftTab.tabTitle" is returned. This would be fine except for when I try and evaluate the
variable inside the function with _root[var], it fails.  See below:

setTextColor("topLeftTab",leftInfoClip.topLeftTabs.leftTab.tabTitle, 0x000000,"left");


function setTextColor(formatName, fieldClip, col, align) {

        _root[formatName] = new TextFormat();
        _root[formatName].color = col;
        _root[formatName].align = align;

//this is the problem here. I can't remove "_root", because that
is bad syntax.  "this" also doesn't work.  so I'm left with "_root." +
"_level0.leftInfoClip.topLeftTabs.leftTab.tabTitle".
        _root[fieldClip].setTextFormat(_root[formatName]);
}

Thanks,
Brandon Lee
_______________________________________________
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

_______________________________________________
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