PDA

View Full Version : Displaying Library Content in AS 3.0 code in a class??



Dimitree
May 4th, 2007, 10:41 AM
I was wondering, can the code of this tutorial be written in a class?
I was thinking about this ActionScript Code:

ActionScript Code:


package
{ import flash.display.MovieClip;
import flash.events.*;

public class BlueCircle extends MovieClip {
public function BlueCircle() {
for (var i:int= 0; i < 200; i++) {
private var newCircle:BlueCircle = new BlueCircle();
private var randomValue:Number = Math.random()*1;


newCircle.x = -100+Math.random()*500;
newCircle.y = -100+Math.random()*400;


newCircle.scaleX = newCircle.scaleY = randomValue;
newCircle.alpha = 1-randomValue;
this.addChild(newCircle);
BlueCircle();
}
}
}}





Be gentle with me I am a newbie!!

stringy
May 4th, 2007, 11:29 AM
if you use BlueCircle as your document class and rename the class in the library to BC


package {
import flash.display.MovieClip;
import flash.events.*;

public class BlueCircle extends MovieClip {
public function BlueCircle() {

for (var i:int= 0; i < 200; i++) {
var newCircle:BC= new BC();
var randomValue:Number = Math.random()*1;


newCircle.x = -100+Math.random()*500;
newCircle.y = -100+Math.random()*400;


newCircle.scaleX = newCircle.scaleY = randomValue;
newCircle.alpha = 1-randomValue;
addChild(newCircle);

}
}
}
}

Dimitree
May 4th, 2007, 11:47 AM
Yes! Thanks a lot stringy =)