<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
backgroundColor="0x101010"
xmlns:local="*"
creationComplete="init()">
<Library>
<Definition name="circle">
<s:Ellipse x="0" y="0" width="100" height="100" >
<s:fill>
<s:SolidColor color="0x000000" />
</s:fill>
</s:Ellipse>
</Definition>
</Library>
<Script>
<![CDATA[
import spark.primitives.supportClasses.GraphicElement;
import spark.primitives.supportClasses.FilledElement;
import mx.graphics.SolidColor;
private function init():void {
for (var i:int=128; i <= 255; i++) {
//create a new instance of the definition and set some properties
//For some reason the flex-compiler won't find the class.
//In this case copying the library over to this file and use
//new FXGLibraryTest_definition1(). Does the trick.
var obj:GraphicElement = new FXGLibraryTest_definition1(); // new MyLibrary_definition1();;
var rnd:Number = Math.random() * 25 + 25;
obj.width = rnd;
obj.height = rnd;
obj.x = Math.random() * container.width;
obj.y = Math.random() * container.height;
obj.blendMode = "screen";
//the definition is a FilledElement. Add some variation the the color.
var scf:SolidColor = SolidColor(FilledElement(obj).fill);
scf.color = 0x0000ff; //i;
container.addElement(obj);
}
}
]]>
</Script>
<local:MyLibrary visible="false" />
<s:Group id="container" width="50%" height="50%" horizontalCenter="0" verticalCenter="0" />
</s:Application>