Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4099646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:27:40+00:00 2026-05-20T20:27:40+00:00

So I’m Bitmaping some heavy stuff to try bring down the [pre-render] and [render]

  • 0

So I’m Bitmaping some heavy stuff to try bring down the [pre-render] and [render] which is quite high according to FlashBuilder’s profiling. I thought this was going well until I realised that as soon as you change a MovieClip to a Bitmap, you lose the pixel based accuracy of the mouse move events (Over, Out, Move…), all your left with is the entire bounding box of the Bitmap, something which is less than desirable. I’ve got a game where many Bitmapped assets would be on top of each other in a scene, on the stage, arranged in various ways and need to have that pixel accuracy moving between each one and have exhausted my efforts as to how to achieve the same mouse move results with the Bitmapped guys as normal.

This, http://seadersforums.appspot.com/static/bitmaps.fla , is a FLA which shows this operation, and you can see how it works here, http://seadersforums.appspot.com/static/bitmaps.html . When it loads up, both items on stage are drawn Shapes, encapsulated in MovieClips, both that get a glow, if you hover over them. If you click the stage at all, the purple guy gets turned into a Bitmap and now, his ‘hit area’, when it comes to MouseEvents is his whole bounding box and you can only get through to the back green item at the edge slivers.

I’m also tracing the pixel which the mouse is over, so I can clearly tell when the mouse is over a transparent area, it’s 0, but how can I tell the event to forward itself on down the chain to the green MovieClip?

Below is how it’s now pretty much working for me,

        var bitmap:Bitmap = this['bitmap'];
        var shouldMouseOver:Boolean = bitmap.bitmapData.getPixel(event.localX - bitmap.x, event.localY - bitmap.y);
        if(shouldMouseOver)
        {
            this.mouseOver();
        }
        else {
            this.mouseEnabled = false;
            var point:Point = new Point(event.stageX, event.stageY);
            for each(var other:DisplayObject in _topContainer.getObjectsUnderPoint(_topContainer.globalToLocal(point)))
            {
                if(other.mouseEnabled)
                {
                    point = other.globalToLocal(point);
                    other.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_MOVE, false, false, point.x, point.y));
                    break;
                }
            }
            this.mouseEnabled = true;
        }

I shut off mouseEnabled for my item, when I know it’s wrong, then I search for another item that properly fits the bill and if there is one, send an Event to that and break. If that one’s also wrong, it’ll do the same again, but each time taking themselves out of the loop.

This does work exactly how I want it to, but I’d always prefer to keep things like globalToLocal and looping, and reading from arrays for not frequently updated methods like listeners to MOUSE_MOVE. Is there a more efficient way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:27:41+00:00Added an answer on May 20, 2026 at 8:27 pm

    Off the top of my head you could use the getObjectsUnderPoint method. Any display object typed class has this method. The method takes an argument of type Point, where you can pass the mouse coordinates. I believe the method returns an array of objects beneath that point, that are contained within the DisplayObject that you called the getObjectsUnderPoint method on. For example if these movieclips of yours are nested within a parent clip called Container, then you could do something like this:

    var pt:Point = new Point(10, 20);
    var objects:Array = container.getObjectsUnderPoint(pt);
    

    Then for your specific scenario I’d sort the returned objects by depth to get the next one in the list (the one beneath, or whatever one I want).

    var i:int = 0;
    var topContainer:DisplayObject;
    var lastIndex:int = 0;
    for(i; i < objects.length; ++i){
       if(topContainer:DisplayObject){
           if(container.getChildIndex(DisplayObject(objects[i])) < lastIndex){
                lastIndex = container.getChildIndex(DisplayObject(objects[i]));
           }
       }else{
           topContainer = DisplayObject(objects[i]);
           lastIndex = container.getChildIndex(DisplayObject(objects[i]));
       }   
    }
    

    So basically what I’m doing here is sorting through all the results and picking the one with the lowest child index to ideally get the next child closest to the surface. It’s been a while since I’ve been into flash so I’m not 100% sure if the display list works that way in terms of child index, that is, if closer objects have a lower index value or higher. In other words, it is highly possible that a child with an index if 0 could be the child at the bottom of the list. You’ll have to give it a try and just adjust the above code if that is the case. Anyway once that function runs (it’s un-tested by the way, so might be type-o’s and things of this nature but the concept should work) then you will have the clip you really want to access referenced by topContainer. From here you can dispatch a mouseEvent to that container.

    topContainer.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN, false, false, MOUSE_POSITION_X, MOUSE_POSITION_Y));
    

    Now this is what you would do if you have a listener inside of the topContainer waiting to receive it’s own mouse event. That is, there is an event listener directly attached to the topContainer object as so:

    topContainer.addEventListener(MouseEvent.MOUSE_DOWN, onMouse);
    

    or, inside the topContainer class:

    this.addEventListener(MouseEvent.MOUSE_DOWN, onMouse);
    

    The reason being that we are dispatching the event directly to the topContainer reference with no event target, and with event bubbling turned off.

    If on the other hand your model involves a single MouseEvent handler at the stage level or some other level, and your onMouse handler has a switch statement to do certain actions depending on the event target as so:

    function onMouse(e:MouseEvent):void
    {
       switch(e.currentTarget){
          case MyMovieClip1:
              //Do Something
          break;
    
          case MyMovieClip2:
              //Do Something
          break;
       }
    }
    

    Then you’re going to need to dispatch that event in a slightly different manor. You’ll need to include a reference to the topContainer object as well as enable event bubbling:

    someRelativeClip.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN, true, false, MOUSE_POSITION_X, MOUSE_POSITION_Y, topContainer));
    

    Hope this helps let me know if you need any clarification.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.