13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with bitmaps<br />

import flash.display.Bitmap;<br />

import flash.display.BitmapData;<br />

var myBitmapDataObject:BitmapData = new BitmapData(1000, 1000, false, 0x00FF0000);<br />

var seed:Number = Math.floor(Math.random() * 100);<br />

var channels:uint = BitmapDataChannel.GREEN | BitmapDataChannel.BLUE;<br />

myBitmapDataObject.perlinNoise(100, 80, 6, seed, false, true, channels, false, null);<br />

var myBitmap:Bitmap = new Bitmap(myBitmapDataObject);<br />

myBitmap.x = -750;<br />

myBitmap.y = -750;<br />

addChild(myBitmap);<br />

addEv<strong>en</strong>tList<strong>en</strong>er(Ev<strong>en</strong>t.ENTER_FRAME, scrollBitmap);<br />

function scrollBitmap(ev<strong>en</strong>t:Ev<strong>en</strong>t):void<br />

{<br />

myBitmapDataObject.scroll(1, 1);<br />

}<br />

Taking advantage of mipmapping<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

MIP maps (also known as mipmaps), are bitmaps grouped together and associated with a texture to increase runtime<br />

r<strong>en</strong>dering quality and performance. Each bitmap image in the MIP map is a version of the main bitmap image, but at<br />

a reduced level of detail from the main image.<br />

For example, you can have a MIP map that includes at the highest quality a main image at 64 × 64 pixels. Lower quality<br />

images in the MIP map would be 32 × 32, 16 × 16, 8 × 8, 4 × 4, 2 × 2, and 1 × 1 pixels.<br />

Texture streaming is the ability to load the lowest quality bitmap first, and th<strong>en</strong> to progressively display higher quality<br />

bitmaps as the bitmaps are loaded. Because lower quality bitmaps are small, they load faster than the main image.<br />

Therefore, application users can view image in an application before the main, high quality bitmap loads.<br />

Flash Player 9.115.0 and later versions and AIR implem<strong>en</strong>t this technology (the process is called mipmapping), by<br />

creating optimized versions of varying scale of each bitmap (starting at 50%).<br />

Flash Player 11.3 and AIR 3.3 support texture streaming through the streamingLevels parameter of the<br />

Context3D.createCubeTexture() and Context3D.createTexture() methods.<br />

MIP maps are created for the following types of bitmaps:<br />

a bitmap (JPEG, GIF, or PNG files) displayed using the ActionScript 3.0 Loader class<br />

a bitmap in the library of a Flash Professional docum<strong>en</strong>t<br />

a BitmapData object<br />

a bitmap displayed using the ActionScript 2.0 loadMovie() function<br />

MIP maps are not applied to filtered objects or bitmap-cached movie clips. However, MIP maps are applied if you have<br />

bitmap transformations within a filtered display object, ev<strong>en</strong> if the bitmap is within masked cont<strong>en</strong>t.<br />

Last updated 6/6/2012<br />

253

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!