after several days of coding, I learn some new syntax and coding techniques concerning AS 3.
1> to draw things with commands like lineTo(), beginGradientFill(), etc, we need to class Graphics:
MovieClip.graphics.lineTo(10,10);
2> the method drawCircle() of class Graphics has the following parameters:
xCenter:Number - The x location of the center of the circle relative to the registration point of the parent movie clip (in pixels).
yCenter:Number - The y location of the center of the circle relative to the registration point of the parent movie clip (in pixels).
radius:Number - The radius of the circle (in pixels).
If you set the xCenter and yCenter to some values, the circle drawn will have the offset even you change the x y properities later. e.g:
this.graphics.drawCircle(50,50,100);
x=100;
y=100;
The above circle will be positioned at (150,150) from the stage top left corner (if the stage is the container of that circle).
3> In previous version of Flash, I can set a 2D array like that:
size=10;
arr=new Array();
for(i=0;i
arr[i]=new Array();
for(j=0;j
arr[i][j]=j;
}
}
this doesn’t seems to work in AS 3 (maybe that’s my problem). So I use the following method:
var size:int=10;
var arr:Array=new Array()
for(var i:int=0;i
var temp:Array=new Array();
for(var j:int=0;j
temp[j]=j;
}
arr.push(temp);
}
I need to set up another array “temp” and then push it into “arr” to make it 2D. It works anyway, although I would prefer another more convenient methods.
4> You cannnot have a BitmapData show directly as by attachBitmap to a movie clip in Flash 8. Also attachBitmap is gone in AS 3. Instead you need the new Bitmap class:
var b:BitmapData=new BitmapData(100,100,false);
var bm:Bitmap=new Bitmap(b);
this.addChild(bm);
We need to tell the Bitmap “bm” to reference to the BitmapData “b”, and then use addChild to add it to the display list to make it show.
Hope these 4 “findings” can help . Feel free to correct me if there’s mistake.