Leistungsoptimierung für die ADOBE FLASH-PLATTFORM
Leistungsoptimierung für die ADOBE® FLASH®-PLATTFORM
Leistungsoptimierung für die ADOBE® FLASH®-PLATTFORM
Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.
YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.
LEISTUNGSOPTIMIERUNG FÜR DIE <strong>FLASH</strong>-<strong>PLATTFORM</strong><br />
Einsparen von Arbeitsspeicher<br />
// Create a single 20 x 20 pixel bitmap, non-transparent<br />
var myImage:BitmapData = new BitmapData(20,20,false,0xF0D062);<br />
var myContainer:Bitmap;<br />
const MAX_NUM:int = 300;<br />
for (var i:int = 0; i< MAX_NUM; i++)<br />
{<br />
// Create a container referencing the BitmapData instance<br />
myContainer = new Bitmap(myImage);<br />
}<br />
// Add it to the display list<br />
addChild(myContainer);<br />
// Place each container<br />
myContainer.x = (myContainer.width + 8) * Math.round(i % 20);<br />
myContainer.y = (myContainer.height + 8) * int(i / 20);<br />
Bei <strong>die</strong>sem Verfahren können ca. 700 KB Arbeitsspeicher eingespart werden, was bei herkömmlichen Mobilgeräten<br />
eine bedeutende Einsparung darstellt. Jeder Bitmapcontainer kann über <strong>die</strong> Bitmap-Eigenschaften bearbeitet werden,<br />
ohne dass <strong>die</strong> ursprüngliche BitmapData-Instanz geändert werden muss:<br />
// Create a single 20 x 20 pixel bitmap, non-transparent<br />
var myImage:BitmapData = new BitmapData(20,20,false,0xF0D062);<br />
var myContainer:Bitmap;<br />
const MAX_NUM:int = 300;<br />
for (var i:int = 0; i< MAX_NUM; i++)<br />
{<br />
// Create a container referencing the BitmapData instance<br />
myContainer = new Bitmap(myImage);<br />
}<br />
// Add it to the DisplayList<br />
addChild(myContainer);<br />
// Place each container<br />
myContainer.x = (myContainer.width + 8) * Math.round(i % 20);<br />
myContainer.y = (myContainer.height + 8) * int(i / 20);<br />
// Set a specific rotation, alpha, and depth<br />
myContainer.rotation = Math.random()*360;<br />
myContainer.alpha = Math.random();<br />
myContainer.scaleX = myContainer.scaleY = Math.random();<br />
Die folgende Abbildung zeigt das Resultat der Bitmaptransformationen:<br />
Letzte Aktualisierung 9.5.2012<br />
9