-
Obsolete Vernacular
Post textfield.autosize height variable?
With a dynamic textfield that has been autosized (in this case, autosize = "center"), is it possible to retrieve the *new* height of the text field? It appears that the script uses the original height of the textfield as specified on the stage, not the height assigned after the script executes.
PHP Code:
this.textfield.autoSize = "center";
loadVariables("announcements.txt", "_root.announcements.boxcontent");
// The line that's giving me trouble...
this.bg._height = this.textfield.textHeight + 14;
stop();
I've also tried...
PHP Code:
this.bg._height = this.textfield._height + 14;
And had no luck there either. I Googled (Flashkit's search function isn't working for me - is anyone else having that problem?) and found another guy with the same problem, but the thread was inconclusive.
-
Obsolete Vernacular
-
Hi,
I think your problem may stem from the fact that the information your loading into your field from the textfile has not loaded prior to setting the height of the bounding box for the field.
Try using the LoadVars object, you will be able to load in your textfile and when it's done loading the onLoad event will fire so you can then set the text to the field and then size your bounding box according to the height of the textfield. Example:
flash:
Code:
var lv = new LoadVars();
lv.onLoad = function(success) {
if(success){
resizeMe(this);
}else{
trace("file not found");
}
}
lv.load("textfile.txt");
function resizeMe(str){
var buffer = 15;
tfield.autoSize = true;
tfield.text = str.myvar;
bg._height = tfield._height + buffer;
}
textfile.txt
&myvar=Lorem ipsum dolor sit amet.....&
there's more info on the loadVars object in the helpfiles if you want to read up on it some more.
hope this helps some,
Dunc
-
Senior Member
I'm experiencing this very same problem.
I have a loop which duplicates MCs that contain dynamic textfields that autosize. With each new clip duped, I am checking the height and positioning accordingly so the end result is one long "list" of these clips.
I am getting the same problem. The height detected is equal to only 1 line of text, even though many of these clips contain several lines of text.
I think the problem is the Flash does not update the clip properties until it "exits" the frame (ie: completes a frame refresh). So I think the solution is to wait one frame refresh and then go through and re-position everything. Problem is there will be a very brief flicker of badly formatted content in the second before it gets reformatted...
-
Yea that's a little annoying, try grabbing the textfield.textHeight of each text field in your loop after you set the text, you'll probably need to set a buffer of 5 pixels or something inbetween beyond that but i've found this works best and you don't have to wait a frame.
-
Senior Member
I found a work-around.
Instead of working with MovieClips that contain a textfield, I am now using "createTextField()". The problem does not exist if you use this method.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|