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




GetBounds Will It Ever Work Right For Me?



Hello, if there is someone who could give me a good insight to the getBounds action i would appreciate it greatly. I have struggled to make it work correctly in my game for a while now.



FlashKit > Flash Help > Flash ActionScript
Posted on: 07-16-2002, 11:55 AM


View Complete Forum Thread with Replies

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

Canīt Get GetBounds To Work
I tried a few ways but I canīt get it to work. I have this mc "pulkan" that you can move around on the srcreen but I donīt wonīt outside the screen.
Anyone seeing whats wrong?

-----


onClipEvent (load) {
speed = 10;
display = "press arrows";
//get Bounds of the mc "backen" so that the mc//
//"pulka" canīt move outside//
var ytan = _root.backen.getBounds(_root);
if (_root.pulka.yMax<ytan.yMin){
this._y = ytan.yMax;
}
if (_root.pulka.yMin>ytan.yMax){
this._y = ytan.yMin;
}
if (_root.pulka.xMax<ytan.xMin){
this._x = ytan.yMax;
}
if (_root.pulka.xMin>ytan.xMax){
this._x = ytan.yMin;
}
}
onClipEvent (keyDown) {
if (Key.getCode() == 39) {
_x = _x+speed;
} else if (Key.getCode() == 37) {
_x = _x-speed;
} else if (Key.getCode() == 38) {
_y = _y-speed;
} else if (Key.getCode() == 40) {
_y = _y+speed;
}
display = Key.getCode();
}

----------

GetBounds
Im busy building a Gannt Chart in Flash.

Im loading variables(_x and duration) into arrays in my movie. A MC duplicates a number of times accoring to the number of tasks and converts the strings to integers.

Then I must access the arrays and find the first value and move it to the relation to the root's _X axis. It's moving it, but in relation to the MC's X-axis.

I was told I must use getBounds to fix this, but it just fries my brain could anybody help?

Code:
-----------------
// Duplicate _root.Task according to number of tasks (numtasks) and moves it
vertmove = 30;
vertcount = 1;
counter = 1;
for (numtasks; counter<=numtasks; counter++) {
duplicateMovieClip (Task, "Task" add counter, counter);
setProperty ("Task"+counter, _y, 50+vertmove*vertcount);
setProperty ("Task"+counter, _width, (this["Task" add counter add "Array"])[1]);
setProperty ("Task"+counter, _x, this["Task" add counter add "Array"][0]);
test = getBounds("Task"+counter);
vertcount++;
}
//test = Background.getBounds(_root);
setProperty (Task, _visible, false);
stop ();
---------------

GetBounds
I've got a movieClip that moves randomly around the stage. I only want it to be able to move in a certain area of the screen. I was trying to use the getBounds property of another movieClip, but didn't seem to work.

Any suggestions

Thanx

Nick

Getbounds
How does this get bounds work and what does it do. Does it sort of ristrict a movie clip or something. Because I have a car game and I want the arrow controled car to only be ristricted to the road, and thought getbounds is what I am after. So could someone tell me how get bounds works, and if its not what I want then how could I restrict the car?

Thanks...

GetBounds
If you would happen to know anything about the getBounds command, I would greatly appreciate your knowledge. I am trying to confine a movie clip to a restricted section of the main scene and when I move my mouse out from over that movie clip I want the movie to stop playing. A perfect example of what I am trying to figure out would be the navigation menu at http://www.celsiusdesign.com

Thanks
[Edited by blindgren on 12-21-2001 at 02:39 AM]

GetBounds Help
i can not seem to make thiswork properly in my game. Sometimes it does not even work at all a second after it just worked. Can anyone give me some insight to help me understand this better?

Getbounds?
how is this done.
I want to make game that has walls that are invisble MC so my hero MC
will not walk through them.
I was told getbounds was the way to go. Thing is i cant seem to figure this out. my games fla is hosted here http://24.98.190.46/beta.fla

GetBounds?
I have a draggable MC on the main stage. I do not want to be able to drag it off of the stage. How do I constrain the boundries?

thx!

GetBounds
I have a game that utilizes get Bounds. When I change my charachters speed variable it runs right over the walls ( or the hit test object)

GetBounds
Hey there,

I attempted to use the getBounds function months ago, and gave up on the project. Now it's come back to haunt me and a friend of mine, and still now, after looking at it and attempting to use it so many times, I cannot figure out exactly how it works.

I've searched up many tutorial sites and forums and I cannot understand how this function works. If anyone can give me a full description of how to use it, I would be really greatful.

I also attached a little example of something I tried just to get it to work, except it isn't working. I don't get why...

Thanks a bunch,
~ Pol

GetBounds - Help
I have a few mc:s that I want to be able to drag. But i donīt want them to be draggable outside a specified mc ( works as the screen )

But I canīt get it work. Now when You press and start drag the mc jump to one of yMin of ramen. Maybe it works when You walk with a character with the arrows but not now. I need help!


-------

kanel.onPress = function(){
this.startDrag(false);
};
kanel.onPress=function(){
burkflytt = _root.kanel.getBounds(_root);
ramen = _root.bakgrund.gul.getBounds(_root);
if(burkflytt.yMax<ramen.yMin){
this._y=ramen.yMax;
}
if(burkflytt.yMin>ramen.yMax){
this._y=ramen.yMin;
}
if(burkflytt.xMax<ramen.xMin){
this._x=ramen.xMax;
}
if(burkflytt.yMin>ramen.yMax){
this._x=ramen.yMin;
}
}
kanel.onRelease = function(){
this.stopDrag();
}

-------

Help With GetBounds
Hey everyone,
I have a problem with the getbounds function at the moment, i have been working on this frustrating scrolling thumbnail page for a while and i stil havent got it worked out, I have a scrolling thumbnail panel that has a invisible movie clip over top called bounds. The scroll panel has code on it that makes the panel stop sliding once the mouse is outside of the "bounds" clip. Anyway this all works fine, but when i load the clip into the main flash file with loadMovie It still works but its really jerky and the release functions on the thumnails doenst work, I have tried refferencing from the root down to the clip but with no luck, Ill add the code so you guys might be able to understand what i mean better.

Thanks

This code is on the first frame of the timeline of this movie, this movie loads into another flash file with loadMovie
#include "lmc_tween.as"

loadMovie("images/24/1.jpg","imageclip");

panel.onRollOver = panelOver;

function panelOver() {
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
}

var b = bounds.getBounds(_root);

function scrollPanel() {
if(_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax){
this.onRollOver = panelOver;
delete this.onEnterFrame;
}

if(panel._x >= 0){
panel._x = 0;
}

if(panel._x <= -32){
panel._x = -32;
}

var xdist = _xmouse - 102.3;

panel._x += -xdist / 5;
}


This is the code that is on the thumnails inside the panel movie clip

on (release){
loadMovie("images/24/2.jpg","_root.containermain.imageclip");
}

as you can see, this movie loads into a movie clip in the main flash file called containermain

GetBounds()
Hello anyone can teach me about getBounds()?
I saw smth like this
mc.getBounds(_root)

????

GetBounds
I am looking for a function that returns width, height, x, y of multiple movieclips.

I am passing an array of names to that function and it returns me all the above information.

Anyone knows how to achieve that?

GetBounds...
hi guys.. i have a little problem here.. which is i don't really get what is the meaning of 'xMin, xMax, yMin and yMax' in getBounds... what are 'these things' refering to? I have a box and I don't get which point the max and min are refering... can somebody explain to me in detail?

GetBounds
hi
i looked in the flash help but couldnt find anything that helped me.
i was wondering if someone could describe getBounds for me and how it works

thanks!

GetBounds() AS 2.0 Vs AS 3.0 Different
AS 2.0 getBounds yields an object with xMin and xMax props that give true pixel bounds.
However AS 3.0 treats the object as having a bounding rectangle and uses that.
Now this is ok until the object is rotated

e.g. take a centered circle, rotate it 45 degrees, getBounds in AS 2.0 will give the xMin and xMax with identical vals

whereas AS 3.0 gives differing values, the square bounding box is wider when rotated

Furthermore the width of the circle changes in AS 3.0 but is constant in AS 2.0
So how do I find the correct pixel bounds of an object, and is this implementation in As 3. correct.

Please note I've tried the .transform.pixelBounds, to no avail
Any ideas, much appreciated?

cheers Steve

GetBounds Help
I wanna to restrict some area in a movie of dragging a movie clip.
eg . if there's a square (or a mazed shaped area) in the movie. a movie clip cannot entered inside the square while dragging.
but it can be dragged rest of the space.

am not familiar with the syntax of using getBounds();

Help With Getbounds
can some one tell me how to stop mc with walls by get bounds?
and explain me how its works?

Using GetBounds ?
hi guys...
Iknow there's a getBounds thing in AS, but i don't know to use it
anyone help please...
here's a fla to solve..
thank u...

GetBounds
Hey could someone tell me where i can find a simple getbounds tutorial?

GetBounds Help
I wanna to restrict some area in a movie of dragging a movie clip.
eg . if there's a square (or a mazed shaped area) in the movie. a movie clip cannot entered inside the square while dragging.
but it can be dragged rest of the space.

am not familiar with the syntax of using getBounds();

Help With Getbounds
can some one tell me how to stop mc with walls by get bounds?
and explain me how its works?

GetBounds()
Last edited by marcelozep : 2004-04-08 at 09:13.
























I would like to know for what ( I know its smth like hitTest) and when ill use getBounds()? And what does it mean?

Many Thanks

marcelozep

GetBounds()
Are there any known issues with getBounds()?

I mean, I check the bounds of a clip, reposition it, check again, and the bounds are still the same? That cannot be right. If I move the a.b.c, a.b.c.getBounds(a) before and after cannot possibly be the same. Only in the next frame does the getBounds() reflect the change in position.

GetBounds(), What Is It For?
Hi, can someone tell me what can I do with getBounds()? I've read sme tutorials but I just don't get why would I use it?

Thanks

Getbounds Madness
Hi, i posted this in the games section before by accident when i mean to post it here. If you've seen it before forgive me :-O

i'm trying to use getbounds too. I'm trying to make a circle bounce around inside of a square movie clip. Right now it just has a seizure and i go :-(

here is what i put on the circle movie clip:

onClipEvent (load){
myBounds = _root.square.getBounds(_root);
goX = 3;
goY = 3;
}
onClipEvent (enterFrame) {
this._x+=goX;
this._y+=goY;
if(this._x > myBounds.XMax or this._x < myBounds.Xmin){
trace(Xmax);
goX *=-1;
if(this._y > myBounds.YMax or this._x < myBounds.Ymin){
trace(Ymax);
goY *=-1;
}
}
}

here is a link to the .fla file: http://www.threebrain.com/bs/circle_...nds_100201.fla

this is driving me nuts! I'm sure i'm doing something stupid. If anyone helps me i'll give them a back rub or a dollar.

thanks,

threebrain

MoviClip.getBounds();
Does anybody has a small sample on how to use moviClip.getBounds().
I've seen this looks like java getBounds, but I haven't had any success trying it.

Thank you.

.getBounds Object
I just want the mc,box to follow the mouse when the mouse is inside the borders of mc called mcB when the mouse is outside the mcB borders I want the mc,box to stop I have tried so many things but I cant seem to get it to work .

Code:
function mousePar () {
bounds = _root.mcB.getBounds(_root);
if ((_root._xmouse<=_root.bounds.xMax) &&
(_root._xmouse>=_root.bounds.xMin) &&
(_root._ymouse<=_root.bounds.yMax) &&
(_root._ymouse>=_root.bounds.yMin))
active=true;
}
then on the box mc
[code]
onClipEvent ( enterFrame ) {
_root.mousePar ();
if (_root.active) {
this._x=_root._xmouse;
}
}

GetBounds Problem
There is something im trying to do...im trying to make an MC "die" when it is shot. I have made the gun and it rotates toward the mouse. I am trying to make an MC"die" when the gun is pionted at it...(he way im doing that may be alot harder than other people know how i could do this, if it is please tell me)... I made a long MC inside the gun MC that is not visible. but when I use the hitTest with it it uses the "bounding box" and not just the MC itself. In the maze game on Flash MX, it uses this getBounds action, But i do not know how to use it...Can anyone help me please?

Uderstanding Getbounds
The script that is stumping me is the getbounds method.
im learning to build a simple rpg like a primitive final fantasy.
here is the fla. so far http://24.98.190.46/beta.fla
my cherecter mc named walkdn is animated in 4 directions.
at end of its actions is listener for on key release go to and stop on frame 5 so the mc's animation comes to a stop.
that part works great.
so my next step was a backround I sed a bryce jpeg.

so now my charecter can walk about this picture looks intresting.
untill he walks over the water or off the screen or even over the tree.

so im like ok ill build walls somehow that are at alpha 0 in its owne layer at bottom of timeline shouldnt be hard right?
well after a week of reading tutorials now im still confused.
ive tried everything it seems. then i heard getbounds method can do this aplied to both mc you want to detect bounds? well ok i add go to and play then get bound to a rectangle movie clip well code getbonds doesnt do anything the script editor shows it as red.
how do script this simple thing with my typs of movie clips?
what is proper way to use get bounds between more than one object?
where in my movement script should I use the getbounds?
is there math behind this action?

GetBounds And HitTest Together
I'm at a loss here and hoping that somebody can help me here, as nobody else can.

I'm creating the game Blasterball and having problems with the ball hitting the blocks. My problems for the time being are:

1) Setting up variables that are made in one movieclip and can be read in another movieclip (ie:getBounds)
2) Combining the hitTest and getBounds methods to determine if an object (clip2) hits a certain point of clip1

I was thinking something along the lines of:

PHP Code:




if(_root.clip1, hitTest(_root.clip2.getBounds.xMin)){
//action;
}






Then having the code for all 4 sides of clip2.
This however doesn't so much work.

Thanks for your help, and I'll keep ya'll updated as to how my game is developing and for people to play and enjoy.

Please Help Me With My GetBounds Script
For some reason, this script is working as expected for xMin and xMax but not working for yMin and yMax. Can anyone see anything wrong?

I have a mask_mc and a map_mc on the stage as well as several text fields I have set up for debugging. This script is on the first frame of my timeline:


Code:
// initialize the boundaries by getting the borders of the map mask.
//this works fine for all text fields mentioned
_root.onLoad = function(){
var maskBorder = mask_mc.getBounds(_root);
maskTop_txt.text = maskBorder.yMin;
maskBottom_txt.text = maskBorder.yMax;
maskLeft_txt.text = maskBorder.xMin;
maskRight_txt.text = maskBorder.xMax;
}
// make the map draggable
map_mc.onMouseDown = function(){
startDrag(this, false);
}
map_mc.onMouseUp = function(){
stopDrag();
}
// monitor the boundaries of the map while being dragged
//this also works for all text fields
_root.onEnterFrame = function(){
var mapBorder = map_mc.getBounds(_root);
mapTop_txt.text = mapBorder.yMin;
mapBottom_txt.text = mapBorder.yMax;
mapLeft_txt.text = mapBorder.xMin;
mapRight_txt.text = mapBorder.xMax;
/* #######################################
here is where the problem starts
I get an "Out of Bounds" when the map border is lower than the mask
border, and also when the map border is further left than the mask
border, but NOT when the map border is further right than the mask,
or the map is higher than the mask bottom. Why?
##########################################
*/
if(mapBorder.xMax < maskBorder.xMax || mapBorder.xMin > maskBorder.xMin || mapBorder.yMin > maskBorder.yMin){
myFlag_txt.text = "Out of Bounds";
}else{
myFlag_txt.text = "Ok";
}
}

GetBounds() Precision?
Hello, I'm making (done) a getter/setter property for MovieClips to make it more convenient. Here is the code I use.
code: //LEFT
getLeft = function () {
var b = this.getBounds(_root);
return b.xMin;
};
setLeft = function (x) {
var b = this.getBounds(_root);
b = this._x-b.xMin;
this._x = x-b;
};
MovieClip.prototype.addProperty("_left", getLeft, setLeft);
//RIGHT
getRight = function () {
var b = this.getBounds(_root);
return b.xMax;
};
setRight = function (x) {
var b = this.getBounds(_root);
b = this._x-b.xMax;
this._x = x+b;
};
MovieClip.prototype.addProperty("_right", getRight, setRight);
//TOP
getTop = function () {
var b = this.getBounds(_root);
return b.yMin;
};
setTop = function (y) {
var b = this.getBounds(_root);
b = this._y-b.yMax;
this._y = y-b;
};
MovieClip.prototype.addProperty("_top", getTop, setTop);
//BOTTOM
getBottom = function () {
var b = this.getBounds(_root);
return b.xMax;
};
setBottom = function (y) {
var b = this.getBounds(_root);
b = this._y-b.yMin;
this._y = y-b;
};
MovieClip.prototype.addProperty("_bottom", getBottom, setBottom);
delete getLeft;
delete setLeft;
delete getRight;
delete setRight;
delete getTop;
delete setTop;
delete getBottom;
delete setBottom;



To test it out, I have a Flash file with this:
code:
//bounds.as is the code I showed earlier
#include "bounds.as"
thing._left = 0;
trace(thing._left);

I get -1 returned, didn't I just set it to 0?

Nested Mc.getBounds()
I have one more question. Why, when I nest a mc inside another, does the getBounds() feature no longer work? I am trying to place a fish on the map, so that it's position will be relative to the movement of the map rather than the main movie.

I guess that it has something to do with the targetCoordinateSpace parameter, but I just can't seem to get the right target path.

with(this._parent.fish) {
if (this.hitTest(getBounds(_root).xMax, _y, true))
}

Thanks once more. Hopefully this will almost complete my game.

GetBounds And HitTest
I have some code to make a maze. It works fine, but there are parts of it I don't understand. Here is the code:

_root.maze.walls.onEnterFrame = function () {
myBounce = 3;

with (_root.character) {
if (_root.maze.walls.hitTest (getBounds(_root).xMax,_y,true)) {
_x-=myBounce;
}
if (_root.maze.walls.hitTest (getBounds(_root).xMin,_y,true)) {
_x+=myBounce;
}
if (_root.maze.walls.hitTest (_x,getBounds(_root).yMax,true)) {
_y-=myBounce;
}
if (_root.maze.walls.hitTest (_x,getBounds(_root).yMin,true)) {
_y+=myBounce;
}
}
}

There is another piece of code to move the character around with the arrow keys. So you can move the character through the maze and whenever it hits a wall it bounces off.

I understand in general how this works, but I'm not clear about this line:(_root.maze.walls.hitTest (getBounds(_root).xMax,_y,true)

Is getBounds getting the boundary of character? What does _y refer to and what is true for? In the normal hitTest you would just have maze.walls.hitTest (character). But when I tried that it didn't work at all, because the character was inside the walls, so it thought it was always hitting. What is telling the character that a hit only counts when it hits the walls, and not when it is inside the shape. Also, why does walls need to be inside of maze?

Thank you for your help,
Eliana

GetBounds Clearification
I am trying to automatically position icons in a windows simulation. I need the height and width of an icon currently on the screen to know where to place the next.


var firstIn:Sprite= icons[0];
trace(firstIn.getBounds(this) );//this = a sprite containing all of my icons
/* output
(x=6710896, y=6710896, w=0, h=0)
*/

firstIn is actually at the 15,15 location and is 50px * 50px

I must be missing something fundamental and hope somone can explain how to use this function or how else to get the width and height of a sprite

HitTest With GetBounds
I'm working on maze game for a high school class that I teach. The collision detection code is:

if (walls.hitTest(getBounds(_root).xMax, _y, true))

this is used in conjuction with a with command:

with (_root.ball)

Code works but I'm not sure about the getBounds(_root). What is it getting min & max values of?

GetBounds Not GettingBounds
while i am searching and trying to figure out my issue, will someone let me know if this is correct? the main image area is supposed to move as the user moves their mouse. my main area is 1360px X 768px. for some reason the top, left, and right are stopping at the boundaries, but when you scroll to the bottom the image area continues to scroll (as in it does not stop like the top, left, and right do).


Code:
imageSlider_mc.onRollOver = panelOver;
function panelOver() {
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
}
var b = stroke.getBounds(_root);
function scrollPanel() {
if (_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax) {
this.onRollOver = panelOver;
delete this.onEnterFrame;
}
if (imageSlider_mc._x>=-1) {
imageSlider_mc._x = 0;
}
if (imageSlider_mc._x<=-1) {
imageSlider_mc._x = 0;
}
if (imageSlider_mc._y>=-1) {
imageSlider_mc._y = 0;
}
if (imageSlider_mc._y>=-1) {
imageSlider_mc._y = 0;
}
var xdist = _xmouse-680;
imageSlider_mc._x += Math.round(-xdist/20);
var ydist = _ymouse-384;
imageSlider_mc._y += Math.round(-ydist/20);
}
once i get past this issue i am on to more difficult tasks such as making the loaded images display in 3d space!

GetBounds() Is Undefined?
OK, I think that this is a common question, but I couldn't find an answer to this one. I have a MC that I want to load images into. Once the image is loaded in, I want to get the dimensions of the image and adjust the frame around it to fit the image. Seems easy enough.

I set an onEnterFrame function in the parent of the target MC which checks to see if the bytes loaded equal the bytes total. If not, it goes into a loading routine. Is so, it runs a getBounds() function to see what the images dimensions are. Here's where it gets weird...

Sometimes it works fine, but mostly it does not. If the images are on the local machine, it works great. If the are loaded from the internet the getBounds() function returns undefined. If the image wasn't showing up I would think that it hadn't loaded, but you can see it. Also, there is some output on every frame telling me the results of the getBounds() function. Even when the images are loaded in it shows undefined. Then if I hit the same button again to call the same image (this is a gallery by the way), it works fine. I can only assume because the image is stored in the local computers cache, but I have no idea.

If anyone has any thoughts about this, I would love to hear them. I need to have this working and I can't see why it works sometimes but not others.

Here is the code that is called on every frame, which resides in the timeline that the target MC (imgHolder) is in:


Code:
this.createEmptyMovieClip("imgHolder", 1);

this.closeBTN.onRelease = function() {
_parent.viewer._visible = false;
}


this.onEnterFrame = function() {
if (imgHolder.getBytesLoaded() == imgHolder.getBytesTotal()){
_parent.viewer._alpha = 100;
bounds = imgHolder.getBounds(this);
imgWidth = bounds.xMax - bounds.xMin;
imgHeight = bounds.yMax - bounds.yMin;

frame_mc._width = imgWidth + 10;
frame_mc._height = imgHeight + 25;

frameBounds = frame_mc.getBounds(this);

closeBTN._x = frameBounds.xMin + 5;
closeBTN._y = frameBounds.yMin;

imgHolder._x = frameBounds.xMin + 5;
imgHolder._y = frameBounds.yMin + 15;
counter++;

outputTXT.text = bounds.xMax + "
" + bounds.xMin + "
" + imgWidth + "
" + imgHeight + "
" + counter;
} else {
frame_mc._height = 20;
frame_mc._width = 100;
_parent.viewer._alpha = (imgHolder.getBytesLoaded() / imgHolder.getBytesTotal()) * 100;
}
}

Problem With GetBounds()
Hello everybody! I have this code:

ActionScript Code:
box_mc.onMouseUp = function() {
    this._xscale *= 1.10;
    this._yscale *= 1.10;
    var bounds_obj:Object = box_mc.getBounds(this);
    for (var i in bounds_obj) {
        trace(i+" --> "+bounds_obj[i]);
    }
};

my problem is, it can't read the latest size of the scaled/zoomed box. what did i do wrong here? it keep reading the original size of the box..

Getbounds Problems
Hiya

I have a flash website where the main home page movie, index.swf, loads into it several other child swf movies into the movieclip symbol "mov_pages"

Within one of these child swf movies i hav a symbol called "stroke"

I am trying to use the function getbounds to return the bounds of "stroke" for the variable "b" within action script in the child swf.

My current coding reads:


var b = mov_pages.stroke.getBounds(_root);


Unfortunately, this is not returning the bounds - obviously i hav got something wrong in the coding.

Initially I was using the code:


var b = stroke.getBounds(_root);


Which worked fine if i opened the child swf alone, but not within the parent swf. Adding the "mov_pages." before stroke seemed a logical way to make it work, when the child swf is loaded in the movieclip "mov_pages" within the parent swf but this doesnt work.


Can anyone help me adjust this to work correctly?

Is it to do with the "_root" part?

Thanks

Alex

GetBounds Problem
I'm using getBounds to stack some radioButton controls.
I set textField.wordWrap in order to shows long texts.
When I change label property, the behavior change too.
Below follow the code sample. RadioButton and Button required in library.
I appreciate your suggestions.
Thanks.








Attach Code

package
{
import fl.controls.*;
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.text.*;

public class radioButtonWordWrap extends MovieClip
{
public var intervalIdDistribution:uint;
public var intervalId:Array=new Array();
public var arItens:Array;
public var str:String="I'm using textField.wordWrap=true and getBounds to control the radioButton 'y'. A long and equal text for all controls causes a organized layout. I didn't set this text for the second controls just to contrast"
public var btn0:Button;
public var btn1:Button;
public var btn2:Button;
public var btn3:Button;
public var counterDistributer:int = 0;

public function radioButtonWordWrap() {
arItens=new Array()
for(var i:int=0;i<3;i++){
arItens[i] = new RadioButton();
addChild(arItens[i]);
arItens[i].width = 300;
intervalId[i] = setInterval(createEvent, 10, arItens[i], i);
}

btn0 = new Button();
addChild(btn0);
btn0.label = "1. short text";
btn0.x = 350;
btn0.y = 20;
btn0.width = 150;

btn1 = new Button();
addChild(btn1);
btn1.label = "2. long text";
btn1.x = 350;
btn1.y = 60;
btn1.width = 150;

btn2 = new Button();
addChild(btn2);
btn2.label = "3. recreate control";
btn2.x = 350;
btn2.y = 100;
btn2.width = 150;

btn3 = new Button();
addChild(btn3);
btn3.label = "4. another long text";
btn3.x = 350;
btn3.y = 140;
btn3.width = 150;

btn0.addEventListener(MouseEvent.CLICK, btnClick0);
btn1.addEventListener(MouseEvent.CLICK, btnClick1);
btn2.addEventListener(MouseEvent.CLICK, btnClick2);
btn3.addEventListener(MouseEvent.CLICK, btnClick3);
}

private function btnClick0(e:MouseEvent) {
arItens[0].label = "short text, short width, 2 lines. Why???";// preecherEspaco("aaa");
arItens[0].addEventListener(Event.ENTER_FRAME, arItensEnterFrame);
}

private function btnClick1(e:MouseEvent) {
arItens[0].label = "When you set a long text in a control that has a short text it assumes the short text width.";
arItens[0].validateNow();
arItens[0].addEventListener(Event.ENTER_FRAME, arItensEnterFrame);
}

private function btnClick2(e:MouseEvent) {
removeChild(arItens[0]);
arItens[0] = new RadioButton();
arItens[0].width = 300;
addChild(arItens[0]);
arItens[0].label = "The only way I discovery is to recreate the control. But even setting the same width for all it can vary. It seems instable or uncontrolable. Anyone knows another way?";
arItens[0].validateNow();
arItens[0].addEventListener(Event.ENTER_FRAME, arItensEnterFrame);
}

private function btnClick3(e:MouseEvent) {
arItens[0].label = "After recreate 2 lines again...";
arItens[0].validateNow();
arItens[0].addEventListener(Event.ENTER_FRAME, arItensEnterFrame);
}

public function createEvent(pObj:Object, i:int){
clearInterval(intervalId[i]);
pObj.visible=false;
if (i != 1) { pObj.label = str; }
pObj.addEventListener(Event.ENTER_FRAME, arItensEnterFrame);
}

public function arItensEnterFrame(e:Event){
e.target.textField.wordWrap=true;
e.target.textField.autoSize=TextFieldAutoSize.NONE;
e.target.removeEventListener(Event.ENTER_FRAME, arItensEnterFrame);
e.target.validateNow();
distributer();
}

public function distributer(){
counterDistributer++;
if(counterDistributer<arItens.length){
return;
}
else{
intervalIdDistribution=setInterval(distributerContinuation, 10);
}

}

public function distributerContinuation(){
clearInterval(intervalIdDistribution);
this.graphics.clear()
var soma:int = 0;
arItens[i].width=300
arItens[i].validateNow()
for(var i:int=0;i<arItens.length;i++){
if(i==0){
arItens[i].y=arItens[i].getBounds(this).height>28?arItens[i].getBounds(this).height/2-28/2:0;
}
else{
arItens[i].y=arItens[i].getBounds(this).height/2+soma-28/2
}
soma+=arItens[i].getBounds(this).height>28?arItens[i].getBounds(this).height:arItens[i].getBounds(this).height;
arItens[i].visible = true;

this.graphics.lineStyle(1, 0x000000, 100);
this.graphics.drawRect(arItens[i].getBounds(this).x, arItens[i].getBounds(this).y, arItens[i].getBounds(this).width, arItens[i].getBounds(this).height);
}
}

private function preecherEspaco(pStr:String):String {
var str:String = ""
for (var i:int = 0; i < 402-pStr.length; i++) {
str += " ";
}
return pStr + str;
}


}

}

GetBounds() Really Confusing
Hey, I've tried looking through the flash help, through several books, tutorials, and posts but I still don't understand how I use getBounds. It's really frustrating. I need to use it to detect collision on all four sides of a wall and based upon where my movie clip (_root.char) hits it, and have it stop moving in that direction.

Please help explain this simply...thanks in advance.

Help With Maze, CD, And GetBounds
I pieced together some code using getBounds and I have made a simple little maze thing.

What I can't do, which is the ultimate goal of this program, is to put MCs around the stage and have various things happen when the moving ball MC passes over them. But I can't get that to happen. There's one in the Walls MC and one just out on the stage.

I'm attaching the fla so maybe someone can find my simple error.

Thanks.

GetBounds....how To Pull Out H= ?
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)

Other Method Than Getbounds()?
I've used this code to define a hitarea that would send two other MC on a tween when rolled over. But it's not that acurate and i have it on a slim popup. Sometime it seems like it can't update fast enough.


heres the code:


ActionScript Code:
var bounds = getbound_mc.getBounds(this);
var up = false;
_root.onMouseMove = function(){
   
if(_xmouse>=bounds.xMin&&_xmouse<=bounds.xMax&&_ymouse>=bounds.yMin&&_ymouse<=bounds.yMax) {
 
         if (up == false) {
           
                left_mc.tween("_x",265,1,"easeOutElastic");
                right_mc.tween("_x",687,1,"easeOutElastic");
           
             up = true;
         }
             } else {
               
          if(up == true){
                left_mc.tween("_x",325,1,"easeOutElastic");
                right_mc.tween("_x",627,1,"easeOutElastic");
            
             up = false;
        }
    }
    updateAfterEvent();
}



any suggestion?

Add Property To GetBounds()
Hye !

Someone could tell me if it's possible to add proprety to the built-in getBounds();

exemple :

// draw
this.createEmptyMovieClip("mc1", 10);
mc1.beginFill(0x0000FF, 100);
mc1.lineTo(0, 100);
mc1.lineTo(100, 100);
mc1.lineTo(100, 0);
mc1.endFill();
mc1._x = 50;
// getBounds
box = mc1.getBounds(_root);
//
trace ('xMin : '+box.xMin)
trace ('xMax : '+box.xMax)
// calc
box.xMid = box.xMin+(box.xMax-box.xMin)/2
// Mid like middle...
trace ('xMid : '+box.xMid)

I calculate xMid after create box. It is possible to add this calcul to the getBounds method ?

An idea ? Thanks a lot !

GetBounds Definition
Hi,
i am working on a nested menu ...
my problem is when i copy the menu..i don't know how to redefine my boundaries for each menu in my code...
Code:

//--------
b01.onRollOver = panelOver;
b02.onRollOver = panelOver;
b03.onRollOver = panelOver;
b04.onRollOver = panelOver;


function panelOver() {
   this.gotoAndPlay(2);
   this.onEnterFrame = getBoundaries;
   delete this.onRollOver;
}
var b = b01.stroke.getBounds(_root);
function getBoundaries() {
   if (_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax) {
      this.gotoAndPlay(7);
      this.onRollOver = panelOver;
      delete this.onEnterFrame;
   }
}

//--------



enclosed the .fla which is probably more explicit..

if someone can help me...

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