Blogroll

This blog is created for education about engineering students.All the engineering students are get free downloadable books here. not only books and also different software also available here

12. Drawing a Rectangle

12. Drawing a Rectangle

Procedure:
step 1: Open flash 8
step 2: Select Action Script document

step 3: write the source code on action script frame and save it Rectangle.as
step 4: Select Flash Document
step 5: Select 1st layer, 1st frame on that document and write source code on Actions Frame and save it Rectangle.fla
step 4: To check output press ctrl+enter(test movie)

Source code:


1.Rectangle.as:-

class Rectangle
{
private var width:Number;
private var height:Number;
private var mc:MovieClip;
public function Rectangle(w:Number,h:Number,x:Number,y:Number,target:MovieClip,depth:Number)
{
mc=target.createEmptyMovieClip("boxcontainer"+depth,depth);
setWidth(w);
setHeight(h);
setX(x);
setY(y);
}
public function getWidth():Number
{
return width;
}
public function setWidth(w:Number):Void
{
width=w;
draw();
}
public function getHeight():Number
{
return height;
}
public function setHeight(h:Number):Void
{
height=h;
draw();
}
public function getX():Number
{
return mc._x;
}
public function setX(x:Number):Void
{
mc._x=x;
}
public function getY():Number
{
return mc._y;
}
public function setY(y:Number):Void
{
mc._y=y;
}
public function draw():Void
{
mc.clear();
mc.lineStyle(1,0x000000);
mc.moveTo(0,0);
mc.beginFill(0xffffff,100);
mc.lineTo(width,0);
mc.lineTo(width,height);
mc.lineTo(0,height);
mc.lineTo(0,0);
mc.endFill();
}
}

2.Rectangle.fla
var b:Rectangle=new Rectangle(250,260,100,110,this,1);




No comments:

Post a Comment

Total Pageviews