Flex :: Image Won't Resize To Fit The Sprite?
Apr 13, 2010I have this snippet of ActionScript code that is supposed to resize an image to fit the sprite: (as in rescale the image not just clip it)
[Code]...
I have this snippet of ActionScript code that is supposed to resize an image to fit the sprite: (as in rescale the image not just clip it)
[Code]...
I am trying to center an image in the middle of the stage and scale it proportionally to the correct aspect ratio based on its loader's size when the image is loading.
In my main app runner I do:
private var rec:Rectangle = new Rectangle();
private var img:BitmapDisplay = new BitmapDisplay();
stage.addEventListener(Event.RESIZE, setRect);
img.imageURL = "some/path/to/image.jpg";
addChild(img);
[Code]...
I'm trying to build an Air application where a user can drop in an image. That image needs to resize if it's bigger than 1024px 1024px.
What's the best practice for resizing an image in Air development? And what's the best practice if I want to send this to codeigniter amf server in Air 2.0, bytearray format?
I have a custom component which is an HBox & I'm trying to resize a child which happens to be an image. This is image is inside a VBox which is also a child of the HBox. I have a number of these images so In UpdateDisplayList I call:myimageArray[0-5].setActualSize(50,50);but the image is never resized it just stays a large default size. The images source is a url path and I'm wondering if that is what is causing the problem?
View 1 RepliesSo I'm loading a really big pic in this mx:Image manteinAspectRatio enabled with a height constraint and as usual it doesn't work (Flex is definitely not for me):
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
[code].....
I am working on image and i like to scale or resize the image by dragging and resize option.same working as "free transform tool" in flash (design part); i need same functionality in application.
View 7 RepliesI'm making a resize function that has to resize a Project object that extends Sprite.
But I keep ketting a type coercion error:
TypeError: Error #1034: Type Coercion failed: cannot convert AS:: Project@318ff89 to mx.core.IUIComponent.
I've tried casting the Project object to an UIComponent or DisplayObject, but this also throws a TypeError.
[AS]var resizeTarget:UIComponent = new UIComponent();
resizeTarget = UIComponent(target.getChildAt(0));
var myResize:Resize = new Resize(resizeTarget);[/AS]
So basically should I try avoiding the use of Sprites in Flex?
I need to resize images in actionscript maintaining the quality aka bicubic or bilinear resizing. At the moment my algorithm just loops through every single pixel and calculates the new pixel. example:
[Code].....
This is really slow and shamefully there is no multi-threading in the flash player, so I was wondering what tricks I can use to speed things up?
I have a sprite in as3 code, I want to enter its height to resize it, how can I scale the width accordingly?
sprite.height = 200;
sprite.width = ??
How do you resize a sprite without resizing the contents? For example the script below create a sprite, attaches it to the root, creates a button, attaches the button to the new sprite then resizes the sprite. but it scales the button when I try to resize?[code]...
View 9 RepliesI'm currently working on a center stage component and I was wondering if there's a good way to detect when a stage component has been changed if any of the elements inside it have been enlarged?
This seems like it should be available but I can't find one that doesn't fire before the redraw. Or at all for that matter.
I want to dynamically resize and align a Sprite with a DropShadowFilter so it fits all Stage but in a way that the Shadow keeps visible.
The problem is that when I resize the Sprite it fits the Stage but it doesn't take the filter in consideration and the shadow is drawn outside the stage.
For example:
imageSprite.filters = createFilters(); // this method creates the DropShadowFilter
var s : Sprite = new Sprite();
[Code]....
Resizing Sprite 's' has the same effect as resizing 'imageSprite' and I couldn't find a way to get the size of the image+shadow.
Im trying to get the sprite overlay to stick to the edges of the stage when I resize the swf window. It works when you resize the width, but not the height.
[Code]...
i am creating flex 3 component when i re size the window i need to re size the labels and text.how to do this?
View 1 RepliesSome images I load dynamically are too big so I would like to scale them to fit the stage.
[Code]...
this returns 0. Why does it return 0 when the image loaded is obviously much larger then 0 pixels. How do I change the width and height of imgCont to a specified dimension.
I have Buttons which I have rotated vertically within a Canvas, that is working fine. The problem occurs, when the user resizes the window to a small size a vertical scroll bar appears, I would rather have each button squashed upto a smaller size.
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="40" maxWidth="40" xmlns:myComponents="myComponents.*"
horizontalScrollPolicy="off"
[code].....
I'm having a little issue with the resize event and resize effect of a VBox.
I have something like this:
<mx:VBox id="container"
backgroundColor="0xFFFFFF"
backgroundAlpha=".9"
paddingTop="15"
paddingLeft="15"
[Code]...
Im quite new to actionscript and am in the process of making a simple platformer game. This is my first project and am still learning all the functions of actionscript.I am trying to embed an image, and then have a sprite have the appearance of that image ( I dont know how to word that any better...)[code]Im getting no errors, but the Sprite is still not showing the image i want it to.
View 1 Repliesi am building an editor which allows you to resize images and to do this (once an image is selected) I add a visible border to the image that allows you to resize the image. so i want to have a function something like,
[Code]....
and i have to call this redrawborder function inside the MOUSE_MOVE listener that controls the resizing (so that i am constantly removing and redrawing the border). constantly removing and redrawing the frame seems very inefficient. is there some property or better why to do this? i want to have, displayobj.scaleChildren = false or something like that
I have a datagrid that occupies 100% of browser screen. I want the grid to automatically resize when the browser is resized to small or full screen.
View 1 RepliesI already have an image that gets resized. Is there an easy way to add a text box on the bottom of it so that it behaves the same way as the picture?
View 3 RepliesI am trying to embed an image (PNG) in my SWF and display it with a Sprite. Below is my code, which displays nothing.
Code:
package
{
import flash.display.Bitmap;
[Code].....
I eventually want a class that extends Sprite and contains multiple embedded images, which I load randomly on every instantiation of that class.
I am working on a small project by writing .AS files in a text editor and compiliing from the command line with MXMLC. I have completed most of my project, but am stuck figuring out how to embed images and get them into a Sprite.
I'm trying to build a picture viewer that can be used in every way. So it's important for me to make everything dynamic. I have a xml file that I load and then I read all the images and I want a border surrounding the image. I've made a new sprite to load everything in, I made a second sprite to load the images and that second sprite should be behind every image but it will only show behind the first image.
<code>
main_container = new Sprite();
main_container.x=containerX;
[code].....
Can you name a Sprite like a movie clip and then reference that to attach an image? Like:
myMovieClip.mySprite.attachChild(imageLoader);
If I want to have a mouseEvent and add an image to a sprite I need to add the image in the class and not after? See where I have used addChild?
[Code]....
I create my sprite and eventlistener like this:
public function init():void
{
var mySprite:Sprite = new Sprite();
mySprite.graphics.beginFill(0x336699);
mySprite.graphics.drawRect(100,100,150,50);
addChild(mySprite
[Code]...
But how would I and a image to the sprite so the TouchEvent responds to touching the image?
I create a simple .As file with following score code:
Code:
package{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.URLRequest;
public class AS3_Project1 extends Sprite{
private var sprite:Sprite;
[Code] .....
And the image wont appear but if i remove the sprite.width = 500; line and I can view the image? what going on?
I'm working with flashdevelop and the free sdk. I made some flash art and want so save them as image on my harddisk.
Unfortunately I can only find examples which seem to need flex(?) and libraries I don't have.
I have two illustrator vector images "apple.ai" and "orange.ai" imported in the library. I create a new sprite in actionscript and want to assign apple.ai as the graphic for the sprite and on mouseover want to change the graphic to orange.ai. I don't want to use button but only sprite: basically i want to know if there is a way in actionscript to assign and change the graphic of a sprite.
View 1 RepliesI load an png image and add it to the display list. Now I want to add this image more than once, like a pinball game there could be 3,4,5 balls, all with the same image. But I cant add the same image reference more than once to the display list, right? So should I make a copy of it? How can I copy it and add to the display list without needing to load it from file more than once?
I tried using this: [URL] But didnt worked! I use the class Loader to load an png, and I use the Loader.content as a parameter of that function. When I add the result to the displaylist nothing appears!