Resize Sprite Flex/ActionScript - apache-flex

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.

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.

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?

Related

Differences between Image and BitmapImage with Flex?

In Image's asdoc, we can see :
Flex also includes the BitmapImage class. This class is used for embedding images into skins and FXG components
but we can also use Image in skins and use #Embed with Image...
Therefore, where and when should I use Image or BitmapImage please ?
Image is a skinnable class that wraps BitmapImage. As such BitmapImage is more lightweight, but Image has more features. So the question when to use which boils down to this:
if the features of BitmapImage suffice, use that; otherwise use Image. Especially in mobile environments try to favor the use of BitmapImage.
Now what features does Image add exactly?
Image extends SkinnableComponent: this means you can assign your images a skin with a border or a dropshadow or whatever you like consistently throughout your application.
It also provides a progress indicator which can be displayed while the image is loading.
One more feature is the possibility to queue the loading of multiple images.

Flex3: where to find loading animations? Is it possible to load GIF images easily?

I would like to use a GIF image as a loading animation on my Flex application, however I read Flex 3 doesn't have native support for GIF images. Therefore, is there any way to use them without any drawbacks?
If not, where can I find some flash animations to include in my app?
There are a lot of progress indicator flash animations out there as swf which can be easily be embedded (ie. here) or search google for Flex Progress Spinner. It's not that difficult to implement your own anyway. You just need a canvas and some matematics (rotation about point formulars).
Yes it's possible. You can find and design your own loading animation in:
http://www.ajaxload.info/. All you need to do is add this image in canvas or anyobject then call this one everytime you load.hope this will help you

Is there a way to use Flex 9-slice scaling at runtime?

I haven't been able to find an answer to this online. Is there a way to use 9-slice scaling with images loaded at runtime?
To clarify, let's say that I build an application that lets a user skin a button with whatever image they want. This would be an image that's not embedded with the swf. Is there a way to set that runtime image as a background and use 9-scaling?
Thanks!
You can specify a rectangle as the scale9grid of a movieClip that contains your image art.
http://www.sephiroth.it/tutorials/flashPHP/scale9/
Now, to use a MovieClip in Flex (it's a Flash thingy) you have to load it into a UIComponent:
http://cookbooks.adobe.com/post_You_wish_to_add_a_Sprite_or_MovieClip_to_a_Flex_ap-7142.html

Flex/AIR layout for presentation tool (resize logic, aspect ratios etc.)

I'm developing a presentation tool for AIR (to be used together with, or as a replacement to, PowerPoint) but I'm quite a newcomer to flex layouting.
As you can see from the image, the presenter can open various apps from the main window.
Each of these apps open up in new windows which have different visual characteristics; some use the main content area to show graphics, others bullet points. Most app windows have buttons and view stacks with embedded Flash assets (using s:SpriteVisualElement).
My questions are the following:
1a. When developing a PowerPoint-like presentation tool with Flex, which layout type (basic, vertical etc.) will provide most flexibility?
1b. How do I make sure no clipping occurs on various projector screens - which aspect ratio should I have in mind?
2a. How can I resize children sprites in the SpriteVisualElement container proportionally to the window resolution?
2b. And where do I place this resize logic - on each component (sprite) with resizeHandlers or in one resizeHandler / window?
Please use the comment thread if you want me to elaborate further. Thanks.
Since you're new to Flex, I strongly reading up on the Flex Component LifeCycle.
1a. When developing a PowerPoint-like presentation tool with
Flex, which layout type (basic,
vertical etc.) will provide most
flexibility?
The layout you choose will depend on what you want to display. I don't see layouts as "Flexible". They do their job and position their elements appropriately. I can easily envision using all types of layouts in such a complicated application, each for different purposes.
1b. How do I make sure no clipping occurs on various projector screens -
which aspect ratio should I have in
mind?
I'm not quite sure I understand what this question means, but I take it to mean you want to avoid the presence of scroll bars in your app. To do that, you'll have to develop layout code that sizes and positions your children so that they do not extend past the height and width of your available content space. In Flex 3 (Halo) architecture, this would be done by writing an updateDisplayList() method for your component. In the Flex 4 (Spark) architecture, this would probably be done by writing an updateDisplayList() method for your skin class.
2a. How can I resize children sprites in the SpriteVisualElement
container proportionally to the window
resolution?
I believe my above answer already addresses this.
2b. And where do I place this resize logic - on each component
(sprite) with resizeHandlers or in one
resizeHandler / window?
In a resize handler, I would most likely use invalidateSkinState and/or invalidateDisplayList. The resizing code would be in the skin and/or updateDisplayList.

How to create fixed size swf in pure AS3 only

I was wondering if there are anyways to get the fixed size swf file when I build my AS3 only project in Flex environment. I can't use scaleMode="noScale" since my swf is very small. I don't want it expand it to full browser winder either. Are there anyways to do it? Thanks for the help!
Your Application is sort of like a Canvas inside of the flash player. Thus, you can give it a fixed size (with the width and height attributes), but that will just reduce its size inside the flash player. I don't think you can mess with this in pure AS3 - you'd need to change the underlying HTML (although, you may be able to do this with ExternalInterface, which allows you to call javascript methods on the HTML page...).
Use metadata above the main class declaration
[SWF(width="400", height="125")]
public class MyAS3Project extends Sprite

Resources