Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Is It Possible To Dynamically Set The Height Of A Textfield According To Text Amount?



is it possible to dynamically set the height of a textfield according to the amount of text that's been externally loaded?
say if I only have a line of text to load in to a textfield, then that textfield could adjust is height to only the height of a line of text.
and if it is a paragraph, then the textfield will load the text with lenthened height.
is it possible to achieve that? to have a text field adjust its height according to amount of text loaded?



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 12-06-2008, 02:23 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

The Height Of A Dynamically Created Textfield
Hi, hello and everything else...

If I'd have a variable with some html-text and I'd want to put it into a textfield created by actionscript, how can I find out what the height of the textfield should be?

I was thinking of roughly counting the text with a for-loop, like increasing some variable a lot when a "<br>" is detected and ignoring other brackets and stuff, but I figured there might be an easier way to achieve this...right??

Thanks for all your time - Ruben

[textfield] How To Check If Input Text Is More Than Textfield Height?
Hi guys, Is there a way to check if the text that has been input into the textfield is more than the height of the textfield.

I have set the scrollbar hidden and it will become unhidden once the text is greater the the textfield height.

I did try to count the input text and set the visiblity of the scrollbar against that count. Unfortunatly this is unreliable.

Anyone got a better idea?

Cheers
Paul

[textfield] How To Check If Input Text Is More Than Textfield Height?
Hi guys, Is there a way to check if the text that has been input into the textfield is more than the height of the textfield.

I have set the scrollbar hidden and it will become unhidden once the text is greater the the textfield height.

I did try to count the input text and set the visiblity of the scrollbar against that count. Unfortunatly this is unreliable.

Anyone got a better idea?

Cheers
Paul

Loading Txt Files Dynamically, Is The Amount Of Text Limited?
Hello,

I've been using a scrolling list of gigs for a website, the text is loaded from a txt file and formatted with html (the font is embedded).

Here* is just the page on its own

(scroller on the right) This has been working fine up until now, I've been required to add more dates to the list.... Only about quarter of it is cut off the bottom, and it is always in the same place which would suggest that there is a limit to the amount of text this can hold !! Is this the case? If so does anyone have any suggestions as to what I can do about it?

Thanks in advance!

Pat

Positioning The Text Based On TextField Height
Hi All,

I wanted to position the TextField based on the height of the text in the text field. Not able to figure where I am doing wrong. The Y position does not leave 25 pixels after the last line of text. Textfield1 and Textfield2 kind of overlap.

_totalDistractors = 4

for(var i:int = 0; i < _totalDistractors ; i++) {
var taradioButtoni:TextArea = new TextArea();
taradioButtoni.text = answerChoices[i]; // Text Comes from array
taradioButtoni.width = 380;
taradioButtoni.height = taradioButtoni.textHeight + 10;

taradioButtoni.y = i*(taradioButtoni.height + 25);// Need to refine this line of code

taradioButtoni.wordWrap= true ;
}

Determining The Height A Text Box Will Need To Be Dynamically
I want to populate a dynamic text box and then scroll this.
Is there anyway of determining how large the text area's height needs to be given the width and the text I want to populate it with?

Hope that makes sense. If not please shout!

Many Thanks,
Daf

Changing The Height Dynamically Of A Dynamic Text Box
I'm trying to load text from a text file into a dynamic text box that's inside a ScrollPane component. If the text in the file exceeds the size of the dynamic text box, the text box doesn't change it's height automatically, so I'm trying to do that dynamically. This is the code I have right now.

events.html=true;
eventsLoadVar = new LoadVars ();
eventsLoadVar.load("documents/events.txt");
eventsLoadVar.onLoad = function (success){
if (success == true) {
events._height=eventsLoadVar.eventsheight;
events.htmlText=eventsLoadVar.eventstext;
}
}

It seems to be working properly, but not on the first time the page loads. I have to refresh the page for the height to actually take effect.

Does anyone know how I can get the height to change on the first load, or is there a better way to be doing all of this?

Getting And Setting The Width And Height Of Text Tool Dynamically
What I am trying to do is set the text of a text tool at runtime, which I was able to do. The problem is how can I determine if the text exceeds the size of the text tool and how to resize it at runtime.

Dynamically Generated Text Fields - Height/Spacing
Could some kind soul point me in the right direction - I know I must be missing something simple -

- I am generating a list of clips in a scrollPane, each clip displays some text via an array which has extracted the data from a loaded XML file, so far so good, my problem is I cannot seem to generate the right code that records the _height of the previous clip and then asigns the new clips _y axis based on that value - at the moment I have a static value, var spacing - which I'd like to be fluid based on how high the prev text field was, in order that each of the clips display their text in full - have tried various variables such as newY = (this.post_mc._height * 20) but no joy. Would someone mind clearing the air for me please?! been going great guns so far for a simple designer but this bit has me stumped


Here's my code;


ActionScript Code:
function makeThread(posts, userPost, userID, maxPosts){
threadList_sp.vScrollPolicy = "off";
var spacing:Number = 100;
// Loop through each post
    var name_str:String = "post" + (posts) + "_mc";
    var depth:Number = posts * 10;
// Create post clip
    var post_mc:MovieClip = threadList_sp.content.attachMovie("post_mc", name_str, depth);
// Format clip
    post_mc._y = (posts * spacing);
    post_mc.userName_txt.text = "Posted by " + (userID);
    post_mc.userName_txt.autoSize = "left";
    post_mc.userPost_txt.text = userPost;
    post_mc.userPost_txt.autoSize = "left";
// Check if this is the last clip
    if((posts + 1) == maxPosts){
        //trace("function Fired");
        threadList_sp.vScrollPolicy = "on";
    }
}
function init(){
    var threadArray:Array = new Array();
    //Loop through each post
    for(var posts:Number = 0; posts < this.firstChild.childNodes.length; posts++){
    threadArray[posts] = new Object();
    threadArray[posts].userID = this.firstChild.childNodes[posts].attributes.userID;
    threadArray[posts].postDate = this.firstChild.childNodes[posts].attributes.postDate;
    threadArray[posts].userPost = this.firstChild.childNodes[posts].childNodes[0];
    //trace(this.firstChild.childNodes.length);
    //trace(userID);
    //trace(maxPosts);
    //trace(userPost);
    trace(posts);
    var maxPosts:Number = this.firstChild.childNodes.length;
    var userID:String = threadArray[posts].userID;
    var postDate:String = threadArray[posts].postDate;
    var userPost:String = threadArray[posts].userPost;
    makeThread(posts, userPost, userID, maxPosts);
    }
}
var threadListXML:XML = new XML();
threadListXML.ignoreWhite = true;
threadListXML.onLoad = init;
threadListXML.load("threadlist.xml")

Finding Line Height Of Dynamically Generated Text Into A Variable ?
Hello,

I made a site with news flashes that are dynamically pulled from text files. They are placed about an inch apart from each other. The problem is that when a news flash is only one sentence long, there is a large gap between it and the news flash under it. Also, different browsers and platforms display fonts differently... the same 12pt font fills the area differently depending upon your browser/platform.

Is there any way to figure out information about not only how many characters is being pulled into a variable, but also the line height... or maybe the overall height of the text field. If I could find that information, then I could dynamically place another news flash under it always keeping the distance between the flashes consistent no matter what browser/platform is used.

Any suggestions would be appreciated

thanks,
Janet

Total Amount Of Lines In Textfield?
Im i being a spoon here?is there a way you can find out how many lines of text there are in a dynamic textfield?I would like to display some buttons to scroll up and down but only if there is an overflow on my textfield.Is this pos?
Thanks

Center Text In TextField Dynamically
How on earth do you center text within a text field dynamically....e.g. textField.align = "center" or textField.autoSize = "center" ....nothing works?

BTW...is it just me or is the adobe site just plain slow and almost unusable to everyone else too. It has to be one of the slowest loading sites I visit and the menu at top takes forever to load completely also, Has there been discussion on that?

Counting Dynamically In A Specified Amount Of Time
Hi everyone!

I have searched high and low for a script in flash i can use that counts up to whatever number i set in a specific amount of time that I specify. I have found scripts that count down and up acutally but they are not easy to edit or specify the number to stop at and in what amount of time. Could someone please help?

Quick example would be the counter counts from 1 to 280,000 in 20 seconds.

I would really appreciate the help!

Oh, using flash mx 2004, btw.

Thanks,
shines

Dynamically Preload X Amount Of Sounds
HI, I'm having a hard time getting help with this thing.
I'm loading items from a database which will populate a scene. The items and their placement is given by the values in the database.

So each item must play a sound when moused over. These sounds will be given by the database also.
I need to preload all the sounds when the scene opens, and have the sounds play instantly when you mouse over an item.

How would I do this??? I can't use


Code:
mySound = new Sound()
Since I need to give Ids to the sound items, like Sound1, Sound2 etc. Since I don't know how many of these there will be, and the related button should be able to trigger it with it's similar ID...

Thanks for any help in advance

Create Textfield And Load Text Dynamically ... Why Does Not This Work?
Hi Flashgurus!

I've written a function on the first frame of my movie. Like this:

--------------------------------
function makeText() {
createTextfield("textBox", 2, 4, 3, 371, 43);
textBox.background = true;
textBox.border = true;
textBox.backgroundColor = 0xFFFFFF;
textBox.borderColor = 0x000000;
textBox.multiline = true;
textBox.wordWrap = true;
textBox.autoSize = true;
textBox.variable = "txt";
// formatering
myFormat = new TextFormat();
myFormat.font = "Impact";
myFormat.size = 15;
myFormat.color = 0x666666;

textBox.setNewTextFormat(myFormat);
}
--------------------------------

I made this function to make it simple to edit the formating of the textfields I want to create.

In my movie I load different MC:s using a random script. In every MC I load, I call the function in the first frame:

--------------------------------
_root.makeText(this);
--------------------------------

And the textfield is created, it works ...

Now I want to put text in my textfields:
The different MC:s I load contains an empty MC (controller)that is supposed to load texts from an external textfile, dynamically, and put the text in the textfield created with my function. The empty MC has the following code

--------------------------------
onClipEvent (load) {
this.loadVariables("texts/1.txt");
}
onClipEvent (data) {
_parent.txt = intro;
}
--------------------------------

This thing does not work. It works perfect when I create the textfield manually, but as there are about 40 MC:s I'd really like to use a function to create the textfields.

I surely cannot see where the fault is. I've tried to put the controller in a frame after the textfield is created, in the frame before the textfield is created, but nothing works. The textfield is created but the text does not get loaded. I can't understad why it works when I create the textfield manually and not with this function.

I'm afraid the answer is simple, but I cannot figure it out ...

Can YOU help me? Please ...

Change Size Of TextField Dynamically According To The Text It Displays
Hi everyone:


I have a text field on the stage. It is in a single-line mode. I need to set it's width according to the text it will display. Is there any way to do it dynamically?

HTML Formatted Dynamic Textfield - Limit To Amount Of Characters?
I've got a dynamic textfield that's set up to import HTML formatted text. I've run into a strange problem though... it seems as though the textfield will only allow a certain number of characters (around 620).

Is there some way around this? Or am I missing something?

Thanks

Cant Get Textfield Height From AutoSized Textfield
Afternoon guys.

I am creating a new nwe3s blogger. Instead of relying on a scrollbar to scroll the news story i thought i would use
code: textField.autosize="left"
This works fine...
At present i am loading x amount of news into flash at any one time. I am placing the news story underneath each other using
code:
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
nextY += Math.ceil (holder['news' + i]._height) + 2;

this is fine...
But when i use
code: textField.autosize="left"
nextY retains it's orginal height even though some of the news stories have made for higher textfields.

I thought i could pull the height from the previuosly created news holder
code:
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}

But this still returns the intial height

Here is the complete code
code:
for (i = 0; i < this.newsCount; i++) {
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
holder['news' + i].newsTitle.text = this['news' + i + 'newsTitle'];
holder['news' + i].newsDate.text = "Submitted: " + this['news' + i + 'newsDate'];
holder['news' + i].newsStory.htmlText = this['news' + i + 'newsStory'];
nextY += Math.ceil (holder['news' + i]._height) + 2;
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}
}
unloadMovie (dtLoader);
viser._visible = 0;
}

Cant Get Textfield Height From AutoSized Textfield
Afternoon guys.

I am creating a new nwe3s blogger. Instead of relying on a scrollbar to scroll the news story i thought i would use

ActionScript Code:
textField.autosize="left"
This works fine...
At present i am loading x amount of news into flash at any one time. I am placing the news story underneath each other using

ActionScript Code:
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
nextY += Math.ceil (holder['news' + i]._height) + 2;
this is fine...
But when i use

ActionScript Code:
textField.autosize="left"
nextY retains it's orginal height even though some of the news stories have made for higher textfields.

I thought i could pull the height from the previuosly created news holder

ActionScript Code:
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}
But this still returns the intial height

Here is the complete code

ActionScript Code:
for (i = 0; i < this.newsCount; i++) {
    holder.attachMovie ("newsMc", "news" + i, i);
    holder['news' + i]._y = nextY;
    holder['news' + i].newsTitle.text = this['news' + i + 'newsTitle'];
    holder['news' + i].newsDate.text = "Submitted: " + this['news' + i + 'newsDate'];
    holder['news' + i].newsStory.htmlText = this['news' + i + 'newsStory'];
    nextY += Math.ceil (holder['news' + i]._height) + 2;
    if (i > 0) {
        j = i - 1;
        trace (j + " text height=" + holder['news' + j].newsStory._height);
        if (holder['news' + j].newsStory._height > 184) {
            nextY += Math.ceil (holder['news' + j]._height) + 2;
        } else {
            nextY += Math.ceil (holder['news' + j]._height) + 2;
            trace ("nextY=" + nextY);
        }
    }
    unloadMovie (dtLoader);
    viser._visible = 0;
}

Cant Get Textfield Height From AutoSized Textfield
Afternoon guys.
I am creating a new nwe3s blogger. Instead of relying on a scrollbar to scroll the news story i thought i would use

ActionScript Code:
textField.autosize="left"



This works fine...
At present i am loading x amount of news into flash at any one time. I am placing the news story underneath each other using

ActionScript Code:
</p>
<p>holder.attachMovie ("newsMc", "news" + i, i);</p>
<p>holder['news' + i]._y = nextY;</p>
<p>nextY += Math.ceil (holder['news' + i]._height) + 2;</p>
<p>



this is fine...
But when i use

ActionScript Code:
textField.autosize="left"



nextY retains it's orginal height even though some of the news stories have made for higher textfields.
I thought i could pull the height from the previuosly created news holder

ActionScript Code:
</p>
<p>if (i > 0) {</p>
<p>j = i - 1;</p>
<p>trace (j + " text height=" + holder['news' + j].newsStory._height);</p>
<p>if (holder['news' + j].newsStory._height > 184) {</p>
<p>nextY += Math.ceil (holder['news' + j]._height) + 2;</p>
<p>} else {</p>
<p>nextY += Math.ceil (holder['news' + j]._height) + 2;</p>
<p>trace ("nextY=" + nextY);</p>
<p>}</p>
<p>



But this still returns the intial height
Here is the complete code

ActionScript Code:
</p>
<p>for (i = 0; i < this.newsCount; i++) {</p>
<p> holder.attachMovie ("newsMc", "news" + i, i);</p>
<p> holder['news' + i]._y = nextY;</p>
<p> holder['news' + i].newsTitle.text = this['news' + i + 'newsTitle'];</p>
<p> holder['news' + i].newsDate.text = "Submitted: " + this['news' + i + 'newsDate'];</p>
<p> holder['news' + i].newsStory.htmlText = this['news' + i + 'newsStory'];</p>
<p> nextY += Math.ceil (holder['news' + i]._height) + 2;</p>
<p> if (i > 0) {</p>
<p> j = i - 1;</p>
<p> trace (j + " text height=" + holder['news' + j].newsStory._height);</p>
<p> if (holder['news' + j].newsStory._height > 184) {</p>
<p> nextY += Math.ceil (holder['news' + j]._height) + 2;</p>
<p> } else {</p>
<p> nextY += Math.ceil (holder['news' + j]._height) + 2;</p>
<p> trace ("nextY=" + nextY);</p>
<p> }</p>
<p> }</p>
<p> unloadMovie (dtLoader);</p>
<p> viser._visible = 0;</p>
<p>}</p>
<p>

Cant Get Textfield Height From AutoSized Textfield
Afternoon guys.

I am creating a new nwe3s blogger. Instead of relying on a scrollbar to scroll the news story i thought i would use

ActionScript Code:
textField.autosize="left"

This works fine...
At present i am loading x amount of news into flash at any one time. I am placing the news story underneath each other using

ActionScript Code:
holder.attachMovie ("newsMc", "news" + i, i);
holder['news' + i]._y = nextY;
nextY += Math.ceil (holder['news' + i]._height) + 2;

this is fine...
But when i use

ActionScript Code:
textField.autosize="left"

nextY retains it's orginal height even though some of the news stories have made for higher textfields.

I thought i could pull the height from the previuosly created news holder

ActionScript Code:
if (i > 0) {
j = i - 1;
trace (j + " text height=" + holder['news' + j].newsStory._height);
if (holder['news' + j].newsStory._height > 184) {
nextY += Math.ceil (holder['news' + j]._height) + 2;
} else {
nextY += Math.ceil (holder['news' + j]._height) + 2;
trace ("nextY=" + nextY);
}

But this still returns the intial height

Here is the complete code

ActionScript Code:
for (i = 0; i < this.newsCount; i++) {
    holder.attachMovie ("newsMc", "news" + i, i);
    holder['news' + i]._y = nextY;
    holder['news' + i].newsTitle.text = this['news' + i + 'newsTitle'];
    holder['news' + i].newsDate.text = "Submitted: " + this['news' + i + 'newsDate'];
    holder['news' + i].newsStory.htmlText = this['news' + i + 'newsStory'];
    nextY += Math.ceil (holder['news' + i]._height) + 2;
    if (i > 0) {
        j = i - 1;
        trace (j + " text height=" + holder['news' + j].newsStory._height);
        if (holder['news' + j].newsStory._height > 184) {
            nextY += Math.ceil (holder['news' + j]._height) + 2;
        } else {
            nextY += Math.ceil (holder['news' + j]._height) + 2;
            trace ("nextY=" + nextY);
        }
    }
    unloadMovie (dtLoader);
    viser._visible = 0;
}

Set Height Of Mc Same As Textfield
Hi all,

I'm working on a dynamic menu that automaticly generate the items and is easy to customize.

Now i've got a little problem and i don't see why it won't work?!

This is my code:

Code:
//Stylesheet
css_button = new TextFormat();
css_button.bold = bold;
css_button.font = "Cottingley";
css_button.size = 12;
css_button.color = "0xFF0000";

//menu items
total = 7;
text1 = "Werken bij United Restart";
text2 = "Persberichten";
text3 = "Aanvraag financieel jaarverslag USG";
text4 = "United Service Group";
text5 = "Plaatsings-percentage en doorlooptijden";
text6 = "Downloads";
text7 = "Privacy regelement";
stop();

//initialize main menu
for (i=1; i<=_root.total; ++i) {

//duplicate movie clip
menuMC.duplicateMovieClip("menuMC"+i, i);

//create a dynamic textfield
this["menuMC"+i].createTextField("txtf", 1, 15, 0, 128, 19.6);

//Add stylesheet to button texts
this["menuMC"+i].txtf.setNewTextFormat (_root.css_button);

this["menuMC"+i].txtf.text = eval("_root.text" + i);

//Textfield specs
this["menuMC"+i].txtf.autoSize = true;
this["menuMC"+i].txtf.wordWrap = true;
this["menuMC"+i].txtf.multiline = true;

//Change Depths so hitarea is on top of the generated textField
this["menuMC"+i].hitarea.swapDepths(2);

//set Height Menu items same as height of the item's texts
this["menuMC"+i].bg_button._height = this["menuMC"+i].txtf._height;

//set Height hitarea same as height of the item's texts
this["menuMC"+i].hitarea._height = this["menuMC"+i].txtf._height;

//set new position
this["menuMC"+i]._y = this["menuMC"+(i-1)]._y + this["menuMC"+(i-1)]._height+2;
this["menuMC"+i].choice = i;
}
The bold part is what is causing me a headache. I want to set the height of the hitarea (like i did with the background of the menu items) the same as the textfield height, but somehow this doen't work?!?

I've traced it and then the output gives just all 0's (zero's).

Anybody can help me out here, because i've no idea why this is causing a problem.

Thanx in advance!

Textfield Height With Xml
Hi,

I am trying to create a Textfield, pulling the height out of an xml file:

Code:
System.useCodepage =true;
var me = this;
var my_config = new XML();
my_config.ignoreWhite = true;
my_config.onLoad = function(success) {
if (success) {
trace("data loaded");
var outputHeight:Number = this.firstChild.childNodes[0].childNodes;
trace(outputHeight);//traces 292
me.createTextField("output", 1, 7, 31, 402, outputHeight);
output.multiline = true;
output.type = "dynamic";
output.border = true;
output.borderColor = 0xFFFFFF;
output.background = true;
output.backgroundColor = 0xFFFFFF;
output.selectable = false;
output.setNewTextFormat(my_fmt1);
}
};
my_config.load("config.xml");
XML:


Code:
<?xml version='1.0' encoding='UTF-8'?>
<config>
<outputveld><292</outputveld>
</config>
or:

Code:
<?xml version='1.0' encoding='UTF-8'?>
<config>
<outputveld><![CDATA[292]]></outputveld>
</config>
but the height of the Textfield stays zero when I compile.

How come??

Thanks,

Jerryj.

Can't Get TextField Height...
Yes, I know... try textHeight... that didn't work either. I just keep getting one line worth of height. It's not registering the wordWrap as part of the height. I even tried putting a delay in it (in the hopes that a compute cycle hadn't caught up)... no luck.

Here is what the trace in the code yields:
97
112
112

Here's the code:








Attach Code

function popText(panelID){

//if moving the panels into place is done, draw the content...
if (mainPanel[panelID].isTweening() == false){
clearInterval(popPanText[panelID]);
var TextVar = "mainPanelText[" + panelID + "]";
var captVar = "mainPanelCaption[" + panelID + "]";
var headVar = "mainPanelHeader[" + i + "]";
//movie clip to contain all the text
mainPanelText[panelID] = mainPanel[panelID].createEmptyMovieClip(TextVar, mainPanel[panelID].getNextHighestDepth());

//set up the header
mainPanelHeader[panelID] = mainPanelText[panelID].createTextField(headVar, mainPanelText[panelID].getNextHighestDepth(), 10,0, 280, 0);
mainPanelHeader[panelID].multiline = true;
mainPanelHeader[panelID].wordWrap = true;
mainPanelHeader[panelID].autoSize = "left";
mainPanelHeader[panelID].text = panelHeader[panelID];
mainPanelHeader[panelID].setTextFormat(PanelHeaderStyle);

//set up the caption
mainPanelCaption[panelID] = mainPanelText[panelID].createTextField(captVar, mainPanelText[panelID].getNextHighestDepth(), 10, 0, 280, 0);
mainPanelCaption[panelID].html = true;
mainPanelCaption[panelID].wordWrap = true;
mainPanelCaption[panelID].multiline = true;
mainPanelCaption[panelID].autoSize = "left";
mainPanelCaption[panelID].htmlText = panelIntro[panelID];
mainPanelCaption[panelID].setTextFormat(PanelCaptionStyle);

//lower the caption under the header.
mainPanelCaption[panelID]._y = mainPanelHeader[panelID]._height;

trace(mainPanelText[panelID]._height);


//mainPanelCaption[panelID]._y = 320 - mainPanelCaption[panelID]._height;
//mainPanelHeader[panelID]._y = mainPanelCaption[panelID]._y - mainPanelHeader[panelID]._height;
}
}

[AS3] TextField Height
How do I predict the TextField height? When I initiate one, it comes with 100 height, but I want to set it to the fonts height.

I have tried the autoSize, but some times it shrinks the text field to a very tiny one, and some times it stays at fonts height, but I can't set its width anymore...

Is there a solution to this problem?

Thanks,
Ian Liu.

[AS] Textfield Height Bug?
I just ran into a problem with textfields and MX2k4. Has anyone noticed that the actual height of a standard, wordwrapped text field does not give the same height if you do a trace(myTXT._height)

For example take a look at this file:
temp.fla

Notice the actual height value then preview the fla. The trace will give a completely different number. 600 vs 675.

Normally this wouldnt be a problem but my scrollbar script uses the height of the textfield to calculate how much to scroll. Since the number is incorrect so is the scrolling. This can be fixed by breaking apart my textfield, but that makes updating the text a real pain.

Is there a way to get the actual value of the textfield height without using the myTXT._height? (I also used the myTXT.textHeight command, but it only works for dynamic text not static)

Any help would be greatly appreciated.

Thanks!

Textfield Height ?
Hi everybody...

Allright, i load text from a external txt file in a textfield.
I use the ' maxscroll ' function to give the number of line text there is now in my textfield.

My questions to everybody is:

can you resize a textfield (height) depending on the number of line of text that it contain.

exemple:
3 lines of text = 30 pixel
10 lines of text = 100 pixels

Thanx

Height Of A Textfield
I'm loading some text from a database into a textfield. I would like to know how I can attach a mc directly under that text.. The thing is the random text loaded is between 2 and 10 rows.

Another thing I also need help with is how to get the last value of an array. I couldn't get it to work...

Thanks!

Dynamic Textfield Height
i have a dynamic textfield which is to load a pretty long text file. however, this dynamic textfield height appears to be not long enough for it to show the full length of the text file. is there a way where the height of the dynamic textfield will increase itself when the length of the textfield is long? this is because once i reaches 3000height, i cant increase during design time anymore as i will get an error saying invalid height.
thanks

Getting Height Of Dynamic Textfield
A rather simple problem.

The main MC duplicates the container MC which has a dynamic textfield. Each one of the container MCs must be placed under the previous one with 20px distance. The problem is that the variable of the main MC which should calculate (getProperty) the final height of the dynamic textfield is not working.

Help Me Figure Out The Height Of The TextField Please
I'm going crazy here! Can't figure out why it won't give me the height of the textField that I dynamically create.


Code:
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "Arial";
my_fmt.color = 0x000000;
my_fmt.size= 11;
my_fmt.bold = false
temp2=this._parent.getNextHighestDepth();
this._parent.createTextField("the_text", temp2, tempx+5, tempy-8, 192, undefined);
this._parent.the_text.multiline = true;
this._parent.the_text.html = false;
this._parent.the_text.wordWrap = true;
this._parent.the_text.text=this.description;
this._parent.the_text.setTextFormat(my_fmt);
this._parent.the_text.autoSize = true;
box_height=this._parent.the_text._height;
trace(box_height);
Can anyone see what's wrong?

Height Of Dynamic Textfield?
Hey everyone

Very simple: I have a dynamic textfield inside a MC. This MC is duplicated below eachother, like any other news-pages. I have to check the height of the dynamic movieclip to know where the next clip has to be, but when reading the height, it reads the height before the text is loaded inside the clip...

I have read something about this before, but I can't figure out how to make it work...

Please :-)

[F8] Can't Adjust Textfield Height
I have a dynamic text field that I want to change the height. I use text._height = new_height. But trace of the _height is a totally different number. Why is that? I have spent hours trying to make it work. I really need some help:-(

Here is the sample project.
http://www.gotomyhome.com/temp/test.fla

Thanks

Dynamic Textfield Height
Hey everyone

I have this problem again, again. I Have a loop, where I attach several movieclips to the stage, load som xml text into them, and position them under eachother according to the previous clips height.

The problem is, that the height I'm getting is the height of the movieclip BEFORE the text has loaded into it - and not the actual height that I want. This is offcourse because the text takes a little time to pe put into the clip (I have preloaded the XML, so the xml loading is not an issue).

How can I solve this?

This is my code:


Code:

/******************************************************
FIND LIVE IN XML AND PUT IN ARRAY
******************************************************/
// Make array with all XML inside root-tag
var nodes:Array = _root.xml.firstChild.childNodes;
// Loop through them
for(i=0;i < nodes.length; i++)
{
// If we have the news tag
if(nodes[i].nodeName == 'news')
{
// Put all childnodes into new array
var newsNodes:Array = nodes[i].childNodes;
}
}

/******************************************************
DUPLICATE NEWSCLIP AND PUT TEXT INTO
******************************************************/
var currY:Number = 0;

// loop through all the news
for(i=0; i<newsNodes.length; i++)
{
// Create empty MovieClip
var holder:MovieClip = textclip.createEmptyMovieClip("newsholder"+i, textclip.getNextHighestDepth());
// Attach newsclip to the new movieclip
var s:MovieClip = holder.attachMovie("newsclip", "newsclip"+i, textclip.getNextHighestDepth());
// Put text into
s.overskrift.text = newsNodes[i].attributes.overskrift;
s.date.text = newsNodes[i].attributes.date;
s.tekst.text = newsNodes[i].firstChild.firstChild.nodeValue;

// Set X & Y for the movieclip
s._x = 0;
s._y = currY;
// update variable with the Y for the next clip + distance between
currY += s._height + 5;
}

TextField AutoSize And Height
A bit perplexed about something...

I'd like to have a fixed-width, multiline textfield, but one where the height auto-adjusts.

i.e. - in the example below, where forceWidth is a Number vs. null, the TextField has the default height of a newly created TextField, rather than the else statement, where the TextField's height is the same as its content.

I want the height of the TextField to always be that of the content.


Code:
var label:TextField = new TextField();
label.background = true;
label.border = true;

if (forceWidth) {
label.width = forceWidth;
label.wordWrap = true;
} else {
label.autoSize = TextFieldAutoSize.LEFT;
}

label.defaultTextFormat = format;
label.text = txt;

Textfield Height Limit?
I am working a project that require me to pull large amounts of text onto stage and make it scrollable. So I have, but I have encountered a problem in 3 different files that when the textfield's height is more than about 1400, 1500 pixels it starts to cut off text.

I checked to see if it's a character limit and it's not that. I've made the scroller myself but I can't see how that is causing the problem. It works for all my other fields.

Is there a bug within flash, or maybe CS3? I'm working in AS2 in CS3.

Any help or insight on this problem would be much appreciated.

Can't Adjust Textfield Height
I have a dynamic text field that I want to change the height. I use text._height = new_height. But trace of the _height is a totally different number. Why is that? I have spent hours trying to make it work. I really need some help:-(

Here is the sample project.
http://www.gotomyhome.com/temp/test.fla

Thanks

Get Dynamic Textfield Height?
How do i get the height of a dynamic textfield? I need this to place the textfield relative from the bottom.


ActionScript Code:
//footer mcvar footer_mc:MovieClipvar footer:TextField;var contentWebWidth = contentWeb._width;var footerWidth:Number = contentWebWidth -50;var offSet:Number = (contentWebWidth - footerWidth) /2;var footerX:Number =  -(contentWebWidth /2) + offSet ;var footerHeight = (contentWeb.footer_mc.footer._height);var footerY:Number = (contentWeb._height /2) - footerHeight;contentWeb.footer_mc.footer._width = footerWidth ;contentWeb.footer_mc.footer.wordWrap = true;contentWeb.footer_mc.footer.multiline = true;contentWeb.footer_mc.footer.autoSize = true;contentWeb.footer_mc._x = footerX;contentWeb.footer_mc._y = footerY;trace ("Height: "+footerHeight);


My footer textfield is multiline but it doesn't give me the corresponding textfield height??

Any tips?

TextField Line Height
Hi guys.


Is there anyway to get the font line height of a TextField? I can't find anything in the Flash Help docs but I may have missed something.


Cheers.
Si ++

TextField Height - Transform
Hi,

I have a textfield thats created on a canvas mc (createTextField). If i after that set the height and width of the canvas AND the textfield to say 200 they get totalt different size ... The textfields becomes much smaller. SHouldn't they both be 200 wide and high? What i'm i missing? Do the have different reference points or something? I've tried localTpGlobal a bit but that haven't helped me.

I'd love som help.

Thanks

Richard

TextField Height Not Available Initially
Hello all,

Lets say I have a dynamic text field with autoSize = true on it. and I have a MovieClip behind it that I want to be the same size as the text field.

If I fill the text field with 10 lines or whatever of text, then try and do something like myMovieClip._mc._height = myTextField._height; it will never work....it always displays the initial height of the text field (22 in this case)...I guess because it has not been drawn yet. Is there any way around this?

Cheers,
E

How To Restrict Height On A Dynamic Textfield
I have a textfield with autoSize = true;

I load text into it using XML and want to restrict the amount of content it can load in so it does scale out of a certain height

Any ideas how I can do this?

Dynamic Textfield-height And Content
I'm working on a webiste, and I'm creating textboxes with scrollbars. To make the scrollbars, I need to determine the height of the textfield I create. The textfields will load in text from a variable, so how do I now what height to set on the dynamic textfields.

thanks

Does Textfield Have A Maximum Height Limit?
I am loading html formated text into a dynamic textfield but it seems that

3360 is my maxmimum textfield height

Autofilling Dynamic TextField Height?
So I need the text to scroll with the text field object RATHER than inside the dynamic text field box.

to do so I need the textfield box to auto fill a height based on how many lines it has, is there any way to do this or should I draw a static text field instead?

Thanks~

Loading Img From Xml, Textfield.height, Scrollbar
Hi,
I am loading xml and using Colin Moock's scrollbar as he desrcibes it in Essential Actionscript 3.0. It all worked fine until I tried to put a link to a jpg inside the xml.
Where other html tags give no problem, the img seems to mess with the textfield height. I gave the textfield a fixed height but when I try to scroll the field with the image, and trace the textfield height, it increases more and more when I scroll down, messing up the scrollbar.
the img tag looks like this (and it loads fine into the textfield):

Code:
<IMG ALIGN= "left" SRC='pics/portret.jpg' WIDTH="200" HEIGHT="207" HSPACE='0' VSPACE='10' />
The slightly adapted scrollbar class looks like this (I gave the scrolltrack a fixed height and tried to give t.height a fixed height too within this class but tracing t.height keeps showing that it is increasing while scrolling down):

Code:
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.utils.*;
import flash.geom.*;

public class ScrollBar extends Sprite {
private var t:TextField;
private var tHeight:Number;
private var scrollTrack:ScrollTrack;
private var scrollThumb:ScrollThumb;
private var dragging:Boolean = false;
// A flag indicating whether the scrollbar should be redrawn at the next
// scheduled screen update
private var changed:Boolean = false;
private static const SPACING: uint=3;
private var scrollThumbMaxY:Number;
private var scrollThumbY:Number;
private static const SCROLLTRACK_HEIGHT=395;

public function ScrollBar (textfield:TextField,page:uint) {
t = textfield;
tHeight = t.height;

scrollTrack = new ScrollTrack();
addChild(scrollTrack);

scrollThumb = new ScrollThumb();
addChild(scrollThumb);
scrollThumb.buttonMode=true;

t.addEventListener(Event.SCROLL, scrollListener);
scrollThumb.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownListener);

var stageDetector:StageDetector = new StageDetector(this);
stageDetector.addEventListener(StageDetector.ADDED_TO_STAGE,
addedToStageListener);
stageDetector.addEventListener(StageDetector.REMOVED_FROM_STAGE,
removedFromStageListener);

addEventListener(Event.ENTER_FRAME, enterFrameListener);
changed = true;
}

private function addedToStageListener (e:Event):void {
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener);
}
private function removedFromStageListener (e:Event):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener);
}
private function enterFrameListener (e:Event):void {
if (t.height != tHeight) {
changed = true;
tHeight = t.height;
if (dragging) {
scrollThumb.stopDrag();
dragging = false;
}
}
if (changed) {
updateScrollbar();
changed = false;
}
}
private function scrollListener (e:Event):void {
if (t.scrollV > t.maxScrollV) {
return;
}
if (!dragging) {
changed = true;
}
}
public function updateScrollbar ():void {
scrollTrack.x = t.x + t.width+SPACING;
scrollTrack.y = t.y;
scrollTrack.height =395;
var numVisibleLines:int = t.bottomScrollV - (t.scrollV-1);
if (numVisibleLines < t.numLines) {
scrollThumb.visible = true;
scrollTrack.visible = true;

scrollThumb.x = t.x + t.width+SPACING-0.6;
scrollThumb.y = t.y + (scrollTrack.height-scrollThumb.height)
* ((t.scrollV-1)/(t.maxScrollV-1));
} else {

scrollThumb.visible = false;
scrollTrack.visible = false;
}

}

public function synchTextToScrollThumb ():void {
scrollThumbMaxY = t.height-scrollThumb.height -15;
scrollThumbY = scrollThumb.y-t.y;
t.scrollV = Math.round(t.maxScrollV
* (scrollThumbY/scrollThumbMaxY));
trace(tHeight);
}
private function mouseDownListener (e:MouseEvent):void {
var bounds:Rectangle = new Rectangle(t.x + t.width+SPACING-0.6,
t.y,
0,
t.height-scrollThumb.height-15);
scrollThumb.startDrag(false, bounds);
//MainMenu.MainMenuRoot._symbolHolder.updatePosition();

dragging = true;
}
private function mouseUpListener (e:MouseEvent):void {
if (dragging) {
synchTextToScrollThumb();
scrollThumb.stopDrag();
//MainMenu.MainMenuRoot._symbolHolder.pauseTweener();
dragging = false;
}
}
private function mouseMoveListener (e:MouseEvent):void {
if (dragging) {
synchTextToScrollThumb();

}
}
}
}
So I think that the code or flash doesn't handle the img very well, but i could be on the wrong (scroll)track. Getting pretty desperate here :confused: , so any iseas are very welcome!
Thanks,
Jerryj.

Line Height With Css For A Flash Textfield?
Hi there,

How can i set the line height of a flash textfield which is created like

Code:
function showTextContent(txtContent, x, y, w, h) {
this.createTextField("content_txt", 1, x, y, w, h);
css = new StyleSheet();
css.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
content_txt.embedFonts = true;
content_txt.border = true;
content_txt.html =true;
content_txt.multiline = true;
content_txt.wordWrap = true;
content_txt.styleSheet = css;
content_txt.htmlText = paginator.getPage(0);
}
};
css.load("_style.css");

}
anyone?

Get Back The Height Of A Dynamic Textfield
hello folks,

how can i get back the size of a textfield after i loaded a external text into it and resized it with my_txt.autoSize=true?

i have several texts loading dynamicly into this single textfield when be clicked. now i want to resize zhis textfield to the lenght of the text, but ift the text is to long the height is set to a maximum of 75 and a scroller should apear.

hopefully one of you could helt me to find a solution...

so long
jörgosan

AS3 - TextField AutoSize - Height Not Updating
Hi

Can anyone tell me if there is something wrong with my code?
I followed a tutorial word for word on Lynda.com to create a dynamic text field and scroll some text in it. The tutorial on Lynda.com works 'fine and dandy' but mine doesn't.

I have attached my code and accompanying files.

Basically I load some text and apply a stylesheet.
I then load this into the dynamic textfield (external_txt) which lives within text_mc.
I then perform some calculations and attempt to scroll.
I am certain the calculations are correct. It is just that when the textfield doesnt resize the values end up wrong and the results is th text scrolls in the wrong direction.


There is a line of code that says:
text_mc.external_txt.autoSize = TextFieldAutoSize.LEFT;

However, when I trace the height of text_mc (within the textLoaded function) the height has shrunk rather than autosized to a bigger value.

The result of this is that my text scrolls in the wrong direction when I use the drggable scroller (scroller_mc).

Can anyone advise?

Many Thanks

















Attached Files

Copyright © 2005-08 www.BigResource.com, All rights reserved