Actionscript

3D carousel layout in Flex

The layout framework in Flex 4 makes it pretty easy to create generic 3D layouts with nice animations. The huge advatage of that generic approach is that you can use a layout for all sorts of graphical objects (like buttons, panels, images, ...). The following 3D carousel layout supports an autoLayout method wich will automatically center the carousel, depending on the largest object in the list.

Clone an Image in Flex (with flash.display.Loader)

One could think that Adobe's developers have already come up with a standard method to clone images by now. But NO - Nothing comes without a headache in Flash... The solution is to get hold of the bitmapData. In case you are using a Loader Class to load the image, the loader.content can be casted to a Bitmap Class Object. This Bitmap holds the raw bitmapData which can now be cloned:

Access an object inside the display list out of mouseEvent’s target property

In some situations it may become necessary to instantiate graphical objects that are somewhere in the display list but not directly accessible from a certain position inside the display list. Okay that might sound a little abstract, so let me try to explain it in a more practical way: Let’s say you register a mouse event listener on a panel container which holds many different types of children (Buttons, other panels, etc..). You may find yourself in a situation where you want to instantiate one of those objects (f.ex. to alter it).

Define a custom hitarea in Flex

Flex makes it possible to define a sprite as a custom hitarea for components that extend UIComponent. Defining a custom hitarea can become handy when dealing with complex graphical objects that consist of multiple elements such as bitmap images.

Problem:

Assigning a sprite to the objects hitarea variable doesn’t show any effects.

Solution:

The hitarea also has to be added as a child to the display object.

Creating a hitarea for PNG Image with transparent (alpha) regions in Flex

Unfortunately flex doesn’t take the alpha channel of PNG images for the hitarea into account when using mx.image or Bitmap class. That means that mouse events will trigger even if the mouse pointer is located over a transparent area of the image. Fortunately Flex lets us define a sprite as a custom hitarea for graphical Objects. With a simple method we can create a sprite that covers all non transparent areas of the bitmap image and assign it as a hitarea

Syndicate content