Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's a complete, working example I was able to create based on Joel Hooks' suggestions:</p> <p><strong>MXML FILE (ards.mxml):</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()"&gt; &lt;mx:Script source="ards_script.as" /&gt; &lt;/mx:Application&gt; </code></pre> <p><strong>SCRIPT FILE (ards_script.as):</strong></p> <pre><code>import mx.core.UIComponent; private function onCreationComplete():void { // create a UIComponent and add it to the Flex display list var component:UIComponent = new UIComponent(); component.width = this.width; component.height = this.height; component.x = 0; component.y = 0; this.addChild(component); // create a BitmapData object (basically an array of pixels) the same size as the screen var bd : BitmapData = new BitmapData( component.width, component.height ); // draw a green circle in the bitmap data var xCenter:int = component.width/2; var yCenter:int = component.height/2; var r:int = Math.min(xCenter,yCenter); var rSquare:int = r*r; var color:Number = 0x00ff00; for( var i:int=0; i&lt;component.width; i++ ) { for( var j:int=0; j&lt;component.width; j++ ) { var dX:int = i - xCenter; var dY:int = j - yCenter; var q:int = dX*dX + dY*dY; if( q &lt; rSquare ) { bd.setPixel( i, j, color ); } } } // create a bitmap based on the data, and add it as a child to the UIComponent to be displayed // (if you try to add it directly to the Application, you get a runtime error) var bt:Bitmap = new Bitmap(bd); component.addChild(bt); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload