SKITSANOS FOR RIA

Skitsanos

Thursday, May 29, 2008

Sprite in ActionScript 3

A sprite is a new feature introduced in Action Script 3 but unlike MovieClip, Sprite does not contain Timeline. As in Action Script 2, a MovieClip can contain another MoviClip, same is true for Sprite i.e. sprite can contain a children.

Example:

import flash.display.Sprite
var circle:Sprite=new Sprite();
circle.graphics.beginFill(0xFFCC00);
circle.graphics.drawCircle(200,200,20);
addChild();


In the above example we have imported the class Sprite. In the next line we have declared a new class circle. By using the graphics property we draw a circle of radius 20 at the location 200 & 200. We fill this circle by the yellow color using the beginfill() Method. Finally, the addChild method adds circle instance on the stage.



Check other AS3 related posts on http://action-script3.blogspot.com

1 comments:

Nuno said...

hi,

addChild();

should be

addChild(circle);

Webware development dedicated blog by Skitsanos R&D Labs. ASP.NET, XML, RIA, Adobe Flex, ActionScript 3, AIR, AJAX, Web 2.0, Backbase, CGI development with RealBasic and other web development issues.
News
Downloads