AS3 proper use of getBounds()

Posted on 2009-04-30
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
} do I properly use the getBounds in a situation like this? Thanks.
Question by:420_dragon
    LVL 8

    Accepted Solution

    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 > and mouseX < bound.bottom){
    //do something
    else {
    do something else


    Author Comment


    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
    This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
    The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now