views:

296

answers:

2

Hello,

I am creating Sprite objects as simple shapes, and would like to know how to resize them dynamically.

my question:

How can I enable the Sprite to be re-sized on mouse drag(perhaps enabling a only a portion of the Sprite for this behavior)?

It might be important to note that I am using the Flex SDK, and therefore do not have full access to the Flash libraries.

Thank you in advance.

+1  A: 

Doesn't the sprite always adapt itself to its contents to set its height and width? (like movieclips in as2). If you want to resize a sprite, I guess you'd have to draw something as background?

What do you mean by enabling a portion of the sprite to be re-sized?

Lieven Cardoen
"What do you mean be enabling a portion of the sprite to be re-sized?"For example, If my Sprite is a square, that mouse-down+dragging would only trigger resize in one section of the Sprite(e.g., the lower right corner) which is actually standard behavior in Flex UIComponents.
meiguoren
I guess you would have to check for the x and y of the mouse and if it's over the lower right area, then you could change the mouse pointer into a proper image. If you would then click, you could set a flag to true saying it's in drag mode and setting it false when unclicking. Another way would be to have different sprites handling the corners...You could also try to make a custom component in Flex as it's very easy or extending an existing component.Some years ago I helped in a project that had to draw a lots of things in flex sprites and the same things as in flash were possible.
Lieven Cardoen
Lieven, Thank you for the very helpful suggestions.
meiguoren
+1  A: 

You might want to check out the Flex Object Handles open source library. Check out the demo to see how it can be used to allow users to resize any object in a Flex app.

James Ward
Nice, will bookmark that open source library. thx.
Lieven Cardoen
James, this library looks great! Thank you.
meiguoren