29 November, 2007

My First Package and the DisplayList

so, following along the lynda.com tutorials, i happened upon the one about the new feature in ActionScript3, and that is the "displayList". New to ActionScript, the displayList is basically the manager for all things that APPEAR on the stage. In order to show something on the stage you must add it to the stage, and conversely in order to NOT display some object on the stage, you can use removeChild().

its nothing too crazy, and really not that hard, but it was cool to see my first little creation come to life! now, this may appear as nothing but a circle with a line through it, but for my company, Navtrak, Inc. the icon you see bears a striking resemblance to our vehicle icon in our software.

anyway, the code for this exercise is below:

package {
import flash.display.Shape;
import flash.display.Sprite;

public class DisplayList extends Sprite {

public function DisplayList() {
var circle:Shape = new Shape();
circle.graphics.lineStyle(5,0x000000,1);
circle.graphics.beginFill(0xcc0000,.75);
circle.graphics.drawCircle(20,20,15);
addChild(circle);
circle.x = 30;
circle.y = 10
var line:Shape = new Shape();
line.graphics.lineStyle(2, 0, 100);
line.graphics.lineTo(25, 25);
addChild(line);
line.x = 30;
line.y = 10;
}
}
}

The example is here.

Labels: , ,