Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AS3 - getBounds....how to pull out h= ?

Status
Not open for further replies.

fedtrain

Instructor
Jun 23, 2004
142
US
Ok
I have a text field that I will be adding text to as people enter info. That field will grow each time.
I also have this cursor animation that I want to place at the end of the text field each time data is added.

So I am trying to use getBounds to find the height, which I will use on the y coordinate of the cursor.

How do I just pull the 'h=' out of getBounds?

This is all I have at moment:
Code:
	transcript_txt.getBounds(this)
	
	trace (cursor.y - ( ))
	
	trace (transcript_txt.getBounds(this))
	trace (e.currentTarget.text)

The trace for getBounds give me this ... (x=12, y=94, w=170, h=100)

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Ah...ok. I need to look for height, even though the trace shows 'h'.

Code:
var moveCursor:Number = transcript_txt.getBounds(this).height

This worked to get the height of the rectangle.


ps...the tip came from a page I found on Google cache as it no longer exists....

I was converting an older script from ActionScript 2.0 to ActionScript 3.0 this morning when I ran into a problem. My output window was filled with this reference error.

ReferenceError: Error #1069: Property xMax not found on flash.geom.Rectangle and there is no default value

The problem was with box_mc.getBounds(this).xMax. In actionScript 2.0 getBounds returns an object like this.

{ xMin, xMax, yMin, yMax }

In actionScript 3.0 get bounds returns a different object like this.

{ x, y, w, h }

This is how I corrected my code, let me know if you have a better solution.

xMin = box_mc.getBounds().x;
xMax = box_mc.getBounds().x + box_mc.getBounds().width;




"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top