Groups | Blog | Home
all groups > flash actionscript > may 2006 >

flash actionscript : mc._height based off .maxScroll



halcyon32
5/1/2006 8:09:30 PM
Hi All,
I'm having a little problem with maxscroll. I am using the total number of
text lines(maxscroll) multiplied by 14 to give me the _height of a movie clip
called entryBackMiddle... Seems to work until I look closer... it appears that
some of my clips are sized to long and other clips are to short... Originally I
was using .textHeight but that keeps giving me undefined so I switch over to
maxscroll...

What I think might be the problem is:
var maxScrollHeight:Number = this.entry_text.maxscroll;

I have also included a file and the entire code of how I'm looping thought my
xml and attaching my clip in case its something else is wrong.

Any and all help will be greatly appreciated :-)
Thanks in advance
Scott

//My size code:
//-------------Text Size------------//
var maxScrollHeight:Number = this["entry_clip" + h + "" +
i].entry_text.maxscroll;
//var theTextHeight:Number = this["entry_clip" + h + "" +
i].entry_text.textHeight;
trace(theTextHeight);
trace(maxScrollHeight);
//
//var maxTextHeight:Number = theTextHeight*60;
var maxTextHeight:Number = maxScrollHeight * 14;
var maxTextBottomY:Number = maxTextHeight;
trace (theTextHeight);
//
if (this["entry_clip" + h + "" + i].entry_text.maxscroll > 1) {
this["entry_clip" + h + "" + i].textBoxBack.entryBackMiddle._height =
maxTextHeight;
this["entry_clip" + h + "" + i].textBoxBack.entryBackMiddle._y = 0;
this["entry_clip" + h + "" + i].textBoxBack.entryBackBottom._y =
maxTextBottomY - 10;
this["entry_clip" + h + "" + i].textBoxshadow.entryBackMiddle._height =
maxTextHeight;
this["entry_clip" + h + "" + i].textBoxshadow.entryBackMiddle._y = 0;
this["entry_clip" + h + "" + i].textBoxshadow.entryBackBottom._y =
maxTextBottomY - 10;
//
//trace("The field is more than one line");

} else {
trace ("It's only one line");
}
//-------------Text Size------------//


// My code in it's entirety:
//It loops thought the xml just fine.
/***** LOAD EXTERNAL XML ****/
var timeLineXMLConn:XML = new XML ();
this.timeLineXMLConn.ignoreWhite = true;
this.timeLineXMLConn.load ("CompleteTimelines.xml");
this.timeLineXMLConn.trigger ();
trace ("this is = " + this);
this.timeLineXMLConn.onLoad = function (success:Boolean):Void {
if (success) {
//trace("this is Loaded = "+this);
eval ("entry_clip" + i).entry_text.text = timeLineXMLConn;
this.timelineXML.onload = processXML (timeLineXMLConn);
} else {
trace ("error loading XML file");
}
};
/***** LOAD XML ****/

function processXML (xml:XML) {
trace ("processXML = " + "Called");
// the y value of our entries,
// ie how far above the line they are
root_element = timeLineXMLConn.firstChild;
// loop through the XML
for (h = 0; h < root_element.childNodes.length; h++) {
trace ("--------- h = " + h + " -------- ");
element = root_element.childNodes[h];
// pulling out the data as we go
for (i = 0; i < element.childNodes.length; i++) {
entry_text =
root_element.childNodes[h].childNodes[i].firstChild.nextSibling.nextSibling.firs
tChild.nodeValue;


var newPlot = this.attachMovie ("entry_clip", "entry_clip" + h + "" + i,
this.getNextHighestDepth ());
this["entry_clip" + h + "" + i]._x = Math.round(Math.random()* 800)+ 20;
this["entry_clip" + h + "" + i]._y = Math.round(Math.random()* 600)+ 20;
this["entry_clip" + h + "" + i].entry_text.autoSize = true;
//this["plot" + h + "" + i].entry_clip.entry_text.wordWrap = true;
this["entry_clip" + h + "" + i].entry_text.multiline = true;
this["entry_clip" + h + "" + i].entry_text = entry_text.toString ();

//this.timelines_MC["plot"+h+""+i].entry_clip.entry_text.setTextFormat(this.m
yformat);
//

//-------------Text Size------------//
var maxScrollHeight:Number = this["entry_clip" + h + "" +
i].entry_text.maxscroll;
trace(theTextHeight);
trace(maxScrollHeight);
//
//var maxTextHeight:Number = theTextHeight*60;
var maxTextHeight:Number = maxScrollHeight * 14;
var maxTextBottomY:Number = maxTextHeight;
trace (theTextHeight);
//
if (this["entry_clip" + h + "" + i].entry_text.maxscroll > 1) {
this["entry_clip" + h + "" + i].textBoxBack.entryBackMiddle._height =
maxTextHeight;
this["entry_clip" + h + "" + i].textBoxBack.entryBackMiddle._y = 0;
this["entry_clip" + h + "" + i].textBoxBack.entryBackBottom._y =
maxTextBottomY - 10;
this["entry_clip" + h + "" + i].textBoxshadow.entryBackMiddle._height =
maxTextHeight;
this["entry_clip" + h + "" + i].textBoxshadow.entryBackMiddle._y = 0;
this["entry_clip" + h + "" + i].textBoxshadow.entryBackBottom._y =
maxTextBottomY - 10;
//
//trace("The field is more than one line");

} else {
trace ("It's only one line");
}
//-------------Text Size------------//
}

}
}
shyaway
5/1/2006 10:38:11 PM
not quite sure what to make of your question...

if you want the textField to resize to fit to the content. use the property to
do it,
my_txt.autoSize = true;
this will resize your textField automatically to fit it, if it's
multiline/word wrap are enabled. the height will get resized. if single line,
the width will get resized.
you can then get your height/width using my_txt._height and my_txt._width.
halcyon32
5/2/2006 12:00:00 AM
Hi shyaway,
Thanks for the reply.

I'm using autoSize = true here:
this.entry_text.autoSize = true;

I then get the number of text lines with maxscroll here:
var TextHeight:Number = this.timelines_MC.entry_clip.entry_text.maxscroll;

what I am tyring to do is size a movie clip behind my text box based off the
maxscroll of the same text box. So if I have say, 4 lines of text * 14 that
gives me 56 I then go and size my movieclip to 56 pixels. this seems to give me
wrong numbers for some of my text boxes...

when I try to get text._height I get undefined
var TextHeight:Number = this.timelines_MC.entry_clip.entry_text._height;

Or when I try to get entry_text.textHeight I get undefined
var TextHeight:Number = this.timelines_MC.entry_clip.entry_text.textHeight;

The only thing that gives me back a number is maxscroll but its not the right
number for every clip...

could it be something to do with embedded fonts, or dynamic text?


Any and all help will be greatly appreciated :-)
Thanks in advance
Scott
halcyon32
5/2/2006 12:00:00 AM
Hi shyaway,
Thanks for the reply.

I'm using autoSize = true here:
this.entry_text.autoSize = true;

I then get the number of text lines with maxscroll here:
var TextHeight:Number = this.timelines_MC.entry_clip.entry_text.maxscroll;

what I am tyring to do is size a movie clip behind my text box based off the
maxscroll of the same text box. So if I have say, 4 lines of text * 14 that
gives me 56 I then go and size my movieclip to 56 pixels. this seems to give me
wrong numbers for some of my text boxes...

when I try to get text._height I get undefined
var TextHeight:Number = this.timelines_MC.entry_clip.entry_text._height;

Or when I try to get entry_text.textHeight I get undefined
var TextHeight:Number = this.timelines_MC.entry_clip.entry_text.textHeight;

The only thing that gives me back a number is maxscroll but its not the right
number for every clip...

could it be something to do with embedded fonts, or dynamic text?


Any and all help will be greatly appreciated :-)
Thanks in advance
Scott
halcyon32
5/2/2006 6:53:51 PM
Ok so apperntly flash dosn't like deprecated code :D
here is my fix..

//-------------Text Size------------//
this.timelines_MC.entry_clip.my_entry_text.autoSize = true;
this.entry_clip.my_entry_text.wordWrap = true;
this.timelines_MC.entry_clip.my_entry_text.multiline = true;
this.timelines_MC.entry_clip.my_entry_text.htmlText = entry_text;
//this.timelines_MC.entry_clip.my_entry_text.setTextFormat(this.myformat);
//

var TextHeight:Number =
this.timelines_MC.entry_clip.my_entry_text.textHeight;

var maxTextHeight:Number = Math.ceil(TextHeight);
trace("TextHeight-------"+TextHeight);
trace("maxTextHeight-------"+maxTextHeight);
//

//
this.timelines_MC.entry_clip.textBoxBack.entryBackFull._height =
maxTextHeight + 35;
this.timelines_MC.entry_clip.textBoxBack.gradient._height = maxTextHeight +
35;
this.timelines_MC.entry_clip.textBoxshadow._height = maxTextHeight + 35;
//-------------Text Size------------//

Thanks
Scott
AddThis Social Bookmark Button