I did something like this in my 'Sorted Details' demo:
http://graphics-geek.blogspot.com/2008/04/sorted-details.html
(there's also a short video of it here: 
http://graphics-geek.blogspot.com/2008/09/video-sorted-details.html)

The 'slides' in the demo are custom components, subclassing UIComponent, which 
have an Image as a child. The custom component manually resizes the Image child 
(to make it smaller than the slide) and puts a gradient background and border 
around it in the updateDisplayList() override. Check out Slide.as in the code 
for the [sorted] details.

Hope that helps

Chet.



From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
dave_defusion
Sent: Friday, November 28, 2008 6:04 AM
To: [email protected]
Subject: [flexcoders] Issues trying to create a custom image component


I'm trying to create a custom image component so that I can have it
with a border and rounded corners.

I tried doing it by just extending the image component, but quickly
found that it was a bit more difficult than I expected within the
image component - as I couldn't figure out how to move the image
itself around when drawing the border.

So the second solution I came up with was as follows:

* A custom component which has a child as the image
* The image has a mask applied
* The border is drawn using the custom components graphics

This all works out pretty much OK, except for two issues:

1) The child image is only ever displayed if the custom component
extends the Canvas component.

2) Resizing of the component does not work in the same way as resizing
an image component - e.g. if you set a width on an image component
then the image is scaled appropriately. With me extending the Canvas I
just get scroll bars.

The code for the component can be found here on pastie:
http://pastie.org/326072

Any ideas are greatly appreciated.

Reply via email to