all groups > flash actionscript > january 2007 >
You're in the

flash actionscript

group:

loadVariables issue


loadVariables issue SymTsb
1/31/2007 11:31:19 PM
flash actionscript:
I have a text field i created. I am using loadVariables to load the file i
want to show inside this text field. After loading my new file, the formatting
rules i applied to the box when it was created (tested that they were being
applied already - success), are being replaced by default crap text in all
black. Why?
Re: loadVariables issue SymTsb
2/1/2007 7:58:13 PM
Thought I'd post the answer here now that I've found it since it will no doubt
help countless others.

don't use loadVariables lol...

I rewrote my File handling function to use LoadVars and used the onLoad method
to make sure my text was loaded before applying the change. It's the same type
of problem as exists with LoadMovie etc. My final function looks like this....



public function windowFile( tFile:String, target_mc:MovieClip, tColor:Number,
cColor:Number) {

// Load a new file

var newFile = new LoadVars();

newFile.onLoad = function(){
target_mc.title_txt.text = this.title;
target_mc.content_txt.text = this.content;

// Re-Apply formatting rules (title)
var ttl_fmt:TextFormat = new TextFormat();
ttl_fmt.color = tColor;
trace(tColor);
ttl_fmt.font = "Tahoma";
target_mc.title_txt.setTextFormat(ttl_fmt);

// Re-Apply formatting rules (content)
var cont_fmt:TextFormat = new TextFormat();
cont_fmt.color = cColor;
trace(cColor);
cont_fmt.font = "Tahoma";
target_mc.content_txt.setTextFormat(cont_fmt);
}

newFile.load(tFile);

}
AddThis Social Bookmark Button