Skip navigation
Currently Being Moderated

help with rollover on UIComponent

Aug 9, 2012 6:31 PM

Hi

 

I've loaded an array of images into a border container, and each is it's own UIComponent. I want to roll over each object in the border container and perform some action such as a vertical transform, or maybe a tool tip, or a drag and drop. I just need some direction as to how to detect what's under the mouse and select it.

 

What is the direction I should look? Would this be an event on the borderContainer, and is mouseEnabled going to utilise

flash.display.DisplayObjectContainer.mouseChildren?

 

I'm a learner here. I don't even know if I can do what I want with this method. However, I did discover that placing the required number of image components on the screen really slows down the performance.

 

private function result(event:SQLEvent):void

                              {

                                        var data:Array = selectStmt.getResult().data;

 

                                        for (var i:int = 0; i < data.length; i++)

                                        {

                                                   /* trace(data[i].image);  */

 

                                                  var card:Loader = new Loader();

                                                  var imageUrl:String = "assets/" + data[i].image;

                                                  var cardImage:UIComponent = new UIComponent();

 

                                                  card.load(new URLRequest(imageUrl));

                                                  cardImage.addChild(card);

                                                  bc1.addElement(cardImage);

                                                  cardImage.scaleX = .5;

                                                  cardImage.scaleY = .5;

                                                  cardImage.x = 25*i;

                                                  cardImage.y = 5;

                                                  cardImage.mouseEnabled = true;                    //check out:  flash.display.DisplayObjectContainer.mouseChildren

                                        }

                              }

 

Thanks

 

Kristin

 
Replies
  • Currently Being Moderated
    Aug 9, 2012 10:27 PM   in reply to Kristin95762

    Your code looks ok to me.

     

    You would then listen for MouseEvent.MOUSE_OVER on the container and the event.target should be the image.

     

    This should not cause a performance issue unless you have l hundreds of images.  It might help if you size the images up front so you don’t have to scale them.  You should not set mouseEnabled and/or mouseChildren on the container, but you might need to set cardImage.mouseChildren

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 10, 2012 9:50 AM   in reply to Kristin95762

    CardImage is a loop variable so it is setting it on all of them.

     

    For a 100 cards, I’m surprised that Spark Image is that much slower.  You could also try using BitmapImage.

     

    Frameworks do have a cost as they are more general so yes, you can always optimize by going low level.  But that usually takes more time and maintenance.  It is just a trade-off.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points