我是flash的新手,我正在阅读本书中的教程和aster创建新的包作为.as脚本,当我尝试导入它时我得到2个错误我不确定是什么问题! 错误是:
Scene 1, Layer 'Layer 1', Frame 1, Line 2 1093: Syntax error.
Untitled-1\Star.as, Line 1 1037: Packages cannot be nested.
首先,项目代码部分给出错误:
import flash.display.Shape;
#include "Star.as"; //syntax error here ?
var rect:Shape = new Shape();
rect.graphics.lineStyle(2, 0x0000FF);
rect.graphics.beginFill(0xFF0000);
rect.graphics.drawRect(25, 25, 50, 50);
addChild(rect);
rect.x = rect.y = 50;
包裹是这样的:
package {
import flash.display.*;
import flash.geom.Point;
import flash.display.Shape;
public class Star extends Shape {
private var n:int; //spokes
private var r:Number; //radius
private var c:uint; //color
private var t:Number; //line thick
public function Star(n:int = 6, r:Number = 40, col:uint = 0x0000FF, t:Number = 1){
//constructor
super();
this.n = n;
this.r = r;
this.c = col;
this.t = t;
graphics.lineStyle(t, c);
var a:Number = 2*Math.PI/n; //leņķis
var p1, p2:Point;
for(var i:int = 0; i < n; i++){
p1 = Point.polar(r, i*a);
p2 = Point.polar(r, i*a+Math.PI);
Graphics.moveTo(p1.x, p1.y);
Graphics.lineTo(p2.x, p2.y);
graphics.lineStyle(4*t, 0x000000);
graphics.drawCircle(0, 0, r);
}
}
}
}
我不确定我做错了什么...... 如果我删除了#include行,它就可以正常工作了。
包正在创建简单,应该是正确的.. 有什么帮助吗?