[Last Call] Learn how to a build a cloud-first strategyRegister Now


AS3 proper use of getBounds()

Posted on 2009-04-30
Medium Priority
Last Modified: 2013-11-11

I have a simple MC on the stage. I want to create a simple conditional statement that would check if the mouse is on the rectangle using get bounds. something like

if(mouseX > mc.getbounds(min,max) || mouseY > mc.getbounds(min,max))
do something
do nothing

Basicaly...how do I properly use the getBounds in a situation like this? Thanks.
Question by:420_dragon

Accepted Solution

section25 earned 1000 total points
ID: 24276353
create a rectangle object and use that to call the getBounds function. The getBounds function require a namesapce as a parameter so you need to put where the object is in parenthesis (like this, or root).

var bound:Rectangle=rect_mc.getBounds(this);

Then you can reference the returned properties as top,bottom,left,right,width, and height. So you could write your if statement like this:

if(mouseX > bound.left && mouseX < bound.right && mouseX > bound.top and mouseX < bound.bottom){
//do something
else {
do something else


Author Comment

ID: 24291953

that may just do the trick ...let m etry it out and if it works I'll give you the points.

THanks again for your help.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question