I’m new to actionscript, and got this error in my output: 1083: Syntax error: package is unexpected.
I did search the forums here and found some people that said that the class is missing or that if it’s meant to be on the timeline that the “package” doesn’t need to be there. I am creating this in a “class” and I don’t understand the problem any help would be great. I place the package in bold for the purpose of this post, it’s not bod in the actual script.
Here is the script:
var cTime:int = 0;
var cLimit:int = 12;
var shootAllow:Boolean = true;
if(cTime < cLimit){
cTime++;
} else {
shootAllow = true;
cTime = 0;
}
if(event.keyCode == 32 && shootAllow){
shootAllow = false;
var newBullet:Bullet = new Bullet();
newBullet.x = turret.x + turret.width/2 - newBullet.width/2;
newBullet.y = turret.y;
addChild(newBullet);
}
**package {**
import flash.display.MovieClip;
import flash.events.*;
public class Bullet extends MovieClip{
private var _root:Object;
private var speed:int = 10;
public function Bullet(){
addEventListener(Event.ADDED, beginClass);
addEventListener(Event.ENTER_FRAME, eFrame);
}
private function beginClass(event:Event):void{
_root = MovieClip(root);
}
private function eFrame(event:Event):void{
y -= speed;
if(this.y < -1 * this.height){
removeEventListener(Event.ENTER_FRAME, eFrame);
_root.removeChild(this);
}
}
}
}