How to use Bitmap and BitmapData in ActionScript 3 – v3
April 29th, 2008
Alright, this example is very similar to the other examples I have done. But with this one I am scaling all pixels at the same rate. Just click on it the image in the example Source | Example
[as] import flash.display.*;
import caurina.transitions.Tweener;
import flash.sampler.*;
var pixHolder:Sprite = new Sprite();
var img:Img = new Img();
//pixHolder.opaqueBackground = true;
addChild(pixHolder);
var coords_array:Array = [];
var pixels_array:Array = [];
var bmd:BitmapData = new BitmapData(img.width, img.height, false);
bmd.draw(img, new Matrix());
bmd.lock();
startSampling();
for (var i:int = 0; i < img.width; i++)
{
for (var j:int = 0; j < img.height; j++)
{
var coords:Object = {};
//var pixData:BitmapData = new BitmapData(1, 1, false, bmd.getPixel(i, j));
//var pixBit:Bitmap = new Bitmap(pixData, PixelSnapping.ALWAYS, true);
var pixSprite:Sprite = new Sprite();
pixSprite.graphics.beginFill(bmd.getPixel(i, j), 1);
pixSprite.graphics.drawRect(0, 0, 1, 1);
pixSprite.graphics.endFill();
pixSprite.x = i;
pixSprite.y = j;
//pixSprite.filters = [new BlurFilter(5, 5, 3)];
//pixSprite.addChild(pixBit);
pixHolder.addChild(pixSprite);
coords.sprite = pixSprite;
coords.x = i;
coords.y = j;
coords_array.push(coords);
}
}
trace(”what: ” +getSampleCount() )
bmd.unlock();
bmd.dispose();
stage.addEventListener(MouseEvent.CLICK, updating, false, 0, true);
function updating(evt:MouseEvent):void
{
removeEventListener(MouseEvent.CLICK, updating);
trace(”over”);
for(var k:int = 0; k < coords_array.length; k++)
{
Tweener.addTween(coords_array[k].sprite, {x:coords_array[k].sprite.x * 2, scaleX:coords_array[k].sprite.scaleX * 2, scaleY:coords_array[k].sprite.scaleY * 2, delay:.5, y:coords_array[k].sprite.y * 2, transition:”linear”, time:.5});
}
trace(getSampleCount() )
}
[/as]
Last 5 posts in as3
- HOWTO Create a Facebook App using FlexBuilder - June 24th, 2009
- Guitar Synth for Flash - February 27th, 2009
- Abstract Thermometer AIR app - January 22nd, 2009
- Roman Numeral/Arabic Convertion AIR App - Johnny V Now Available - December 25th, 2008
- How to convert Roman Numerals and Arabic numbers in ActionScript 3 - December 17th, 2008
Last 5 posts in Bitmap/BitmapData
- Flash Player 10 Dynamic Sound Generation - May 20th, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v2 - April 23rd, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v1 - April 21st, 2008
Last 5 posts in flash
- HOWTO Create a Facebook App using FlexBuilder - June 24th, 2009
- Roman Numeral/Arabic Convertion AIR App - Johnny V Now Available - December 25th, 2008
- How to convert Roman Numerals and Arabic numbers in ActionScript 3 - December 17th, 2008
- Flash Player 10 Pure Flash Keyboard using SampleDataEvent - September 3rd, 2008
- Using Flash Player 10 to produce Dynamic Musical Notes - May 20th, 2008
Last 5 posts in I just thought
- My 2009 Predictions - December 31st, 2008
- Merry Christmas I'm not completely Tone Deaf?...am I? - December 25th, 2008
- Happy Birthday, me - June 20th, 2008
- Mrs. Spitzer's thoughts during her husbands sex scandal press conference - March 12th, 2008
- Hilary Clinton's Advice to NY Governor's wife - Bitstrips is awesome - March 12th, 2008
Last 5 posts in observations
- Mrs. Spitzer's thoughts during her husbands sex scandal press conference - March 12th, 2008
- This is what I don't like about Comedy - February 17th, 2006
- To go or not to go that is the question - January 13th, 2006
- So what's going on - October 8th, 2005
- I see dead people - August 27th, 2005
Entry Filed under: Bitmap/BitmapData, I just thought, as3, flash, observations
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackback this post | Subscribe to the comments via RSS Feed