|
-
As3 Begginner
Hi, Im using Adobe Flash cs6 AS3, I am a complete beginner so bare with me please and I basically need a way to put multiple as3 shapes into one movie, I have 2 classes,
ellipse.as
circle.as
this is my elipse code
package {
import flash.display.MovieClip;
public class Ellipse extends MovieClip {
public function Ellipse(w:Number=145, h:Number=145, r:Number=1500, color:Number=0xFFFF00) {
// constructor code
graphics.beginFill(color);
graphics.drawEllipse(250, 50, 200, 150);
graphics.endFill();
}
}
}
this is my circle code
package {
import flash.display.*;
public class circle extends MovieClip{
public var mc1:MovieClip = new MovieClip();
public function circle() {
// constructor code
mc1.graphics.lineStyle(1);
mc1.graphics.beginFill(6697983);
mc1.graphics.drawCircle(50,50,20);<br />
this.addChild(mc1);mc1.graphics.endFill();
mc1.alpha =.5; mc1.scaleX =2; mc1.scaleY = 3;
}
}
}
there will also eventually be a square, another circle and a rectangle, ive tried various things here.
if I try to put the ellipse and circle in one class, like this
package {
import flash.display.*;
public class circle extends MovieClip{
public var mc1:MovieClip = new MovieClip();
public function circle() {
// constructor code
mc1.graphics.lineStyle(1);
mc1.graphics.beginFill(6697983);
mc1.graphics.drawCircle(50,50,20);<br />
this.addChild(mc1);mc1.graphics.endFill();
mc1.alpha =.5; mc1.scaleX =2; mc1.scaleY = 3;
}
}
}
package {
import flash.display.MovieClip;
public class Ellipse extends MovieClip {
public function Ellipse(w:Number=145, h:Number=145, r:Number=1500, color:Number=0xFFFF00) {
// constructor code
graphics.beginFill(color);
graphics.drawEllipse(250, 50, 200, 150);
graphics.endFill();
}
}
}
/*I get an error saying An ActionScript file can not have more than one externally visible definition: ellipse, circle
If i try to combine the code like this
package
*/{
import flash.display.*;
package {
import flash.display.MovieClip;
public class Ellipse extends MovieClip {
public function Ellipse(w:Number=145, h:Number=145, r:Number=1500, color:Number=0xFFFF00) {
// constructor code
graphics.beginFill(color);
graphics.drawEllipse(250, 50, 200, 150);
graphics.endFill();
public class circle extends MovieClip{
public var mc1:MovieClip = new MovieClip();
public function circle() {
// constructor code
mc1.graphics.lineStyle(1);
mc1.graphics.beginFill(6697983);
mc1.graphics.drawCircle(50,50,20);<br />
this.addChild(mc1);mc1.graphics.endFill();
mc1.alpha =.5; mc1.scaleX =2; mc1.scaleY = 3;
}
}
}
//I get error Packages can not be nested
Ive also got classes can not be nested,
public attributes cant be inside a package from other things ive tried
these codes separate work perfect but i need all of the shapes in one movie, and flash`` will only let me choose one class at a time
thanks in advance for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|