file size is something else then memory size.
If you want a smaller swf size, you have to make the source image
smaller within the fla or before embedding it via code.
So be more specific.
But I think you are after this:
import flash.geom.*;
import flash.display.BitmapData;
import flash.display.Bitmap;
//var container:Sprite = ...I assume you have a container Sprite;
// 10 times smaller
var scaleFactor:Number = 0.1;
var matrix:Matrix = new Matrix ();
matrix.scale (scaleFactor, scaleFactor); // x and y scale
var bmpData:BitmapData = new BitmapData(
int(container.width*scaleFactor), int(container.height*scaleFactor) );
bmpData.draw(container,matrix)
addChild(new Bitmap(bmpData,"auto",true)); // arguments:
bmp,pixelsnapping,smoothing
removeChild(container)
More nice examples on Matrix here:
http://jasu.tistory.com/228
Latcho
Anthony Pace wrote:
Now when I scale the image it won't display... OMG. this is nuts.
I thought I had it all figured out, and then wham... it won't work.
Glen Pike wrote:
|Hi,
Something like this:
import flash.display.Bitmap;
import flash.display.BitmapData;
//original image in here
container.width /= 10;
||container.height /= 10;|
//maybe invalidate if it does not redraw??
|
var a:BitmapData = new BitmapData(container.width, container.height);
var b:Bitmap = new Bitmap(a);
addChild(b);
a.draw(container);
container.visible = false;|
Anthony Pace wrote:
Examples?
Glen Pike wrote:
Hi,
The only way to reduce the memory size of a bitmap is to resize
it and reduce the number of pixels.
If you are loading images from the server, you might want to
think about generating smaller images server side - you may only
have to do this once when the image is uploaded, so this may be
more useful if you don't require lots of different sizes / unknown
sizes at runtime - depends on the project. Wordpress among other
things does this quite nicely for you at upload time (when the
Wordpress coders stop moaning about FP10 and fix the uploader, it
will be even nicer) and there are lots of scripts which are
variations - resize on the fly & cache, etc.
For client side - reduce the size of the container, then draw
the bitmap image of this into a new bitmap data object - you should
then have a smaller image and you could discard your container'd one.
Glen
Anthony Pace wrote:
I can do it by reducing the size of the container object; yet, the
bitmap remains the same file sized and can be scaled well.
Is there a way to guarantee the memory usage drops? or at least a
better way then mine?
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders