Shootorial #5 Issue

Subscribe to Shootorial #5 Issue 7 posts

Sign in to reply


 
avatar for 1071111 1071111 4 posts
Flag Post

Hey, I have looked at my shootorial source code and i have completely checked it and nothing seems wrong, but when i test the movie it has these errors,

Error C:\Users\George Kung\Desktop\Game\EnemyShip.as: Line 27: This statement is not permitted in a class definition.
shootTimer +=1;

Error C:\Users\George Kung\Desktop\Game\EnemyShip.as: Line 28: This statement is not permitted in a class definition.
if(shootTimer > 30)

Error C:\Users\George Kung\Desktop\Game\EnemyShip.as: Line 43: ActionScript 2.0 class scripts may only define class or interface constructs.
}

Error C:\Users\George Kung\Desktop\Game\EnemyShip.as: Line 44: Unexpected ‘}’ encountered
}

Error C:\Users\George Kung\Desktop\Game\EnemyShip1.as: Line 27: This statement is not permitted in a class definition.
shootTimer +=1;

Error C:\Users\George Kung\Desktop\Game\EnemyShip1.as: Line 28: This statement is not permitted in a class definition.
if(shootTimer > 30)

Error C:\Users\George Kung\Desktop\Game\EnemyShip1.as: Line 43: ActionScript 2.0 class scripts may only define class or interface constructs.
}

Error C:\Users\George Kung\Desktop\Game\EnemyShip1.as: Line 44: Unexpected ‘}’ encountered
}

Error Symbol=EnemyMissile, layer=Layer 1, frame=1:Line 1: The class or interface ‘EnemyMissile’ could not be loaded.

Error C:\Users\George Kung\Desktop\Game\Ship.as: Line 2: ‘{’ expected
}

Error C:\Users\George Kung\Desktop\Game\Ship.as: Line 3: ActionScript 2.0 class scripts may only define class or interface constructs.
var velocity;

Error C:\Users\George Kung\Desktop\Game\Ship.as: Line 4: ActionScript 2.0 class scripts may only define class or interface constructs.
var shootLimiter;

Error C:\Users\George Kung\Desktop\Game\Ship.as: Line 5: ActionScript 2.0 class scripts may only define class or interface constructs.
var enemyTimer;

Error C:\Users\George Kung\Desktop\Game\Ship.as: Line 6: ActionScript 2.0 class scripts may only define class or interface constructs.
var enemies;

Error C:\Users\George Kung\Desktop\Game\Ship.as: Line 14: ActionScript 2.0 class scripts may only define class or interface constructs.
}

Error C:\Users\George Kung\Desktop\Game\Ship.as: Line 47: ActionScript 2.0 class scripts may only define class or interface constructs.
}

Total ActionScript Errors: 16 Reported Errors: 16

 
avatar for 1071111 1071111 4 posts
Flag Post

also, whenever i download the source code, i cannot find the explosion movie clip

 
avatar for DTran DTran 219 posts
Flag Post

Post your code, and use the “< pre >” tags.

 
avatar for explodingferret explodingferret 1505 posts
Flag Post

Seems like you’re missing all or part of the function onEnterFrame() { line, or you have put an extra } on line 25ish.

 
avatar for 1071111 1071111 4 posts
Flag Post

Heres the Enemy Ship

class EnemyShip extends MovieClip
{
var speed;
var shootTimer;

function onLoad()
{
x = 700;
_y = Math.random()300;
speed = Math.random()
5 + 5;
shootTimer = 0;
}

function onEnterFrame()
{
_x -= speed;
if(
x < -100)
{
this.removeMovieClip();
}
if(this.hitTest(_root.ship))
{
explode();
}
}

shootTimer +=1;
if(shootTimer > 30)
{
shootTimer = 0;
var missile = root.attachMovie(“EnemyMissile”,“EnemyMissile” + _root.getNextHighestDepth(), _root.getNextHighestDepth());
missile.
x = x – 50;
missile.
y = y + 2;
}
}

function explode()
{
var explosion = _root.attachMovie( “Explosion” , “Explosion” + _root.getNextHighestDepth(), _root.getNextHighestDepth() );
explosion.
x = x;
explosion.
y = _y;
this.removeMovieClip();
}
}

 
avatar for 1071111 1071111 4 posts
Flag Post

Heres my Ship Class

class Ship extends MovieClip
}
var velocity;
var shootLimiter;
var enemyTimer;
var enemies;

function onLoad()
{
velocity = 10;
shootLimiter = 0;
enemyTimer = 0;
enemies = [];
}

function onEnterFrame()
{
shootLimiter += 1;

if( Key.isDown(Key.RIGHT) ){_x = x + velocity;}
if( Key.isDown(Key.LEFT) ){
x = x – velocity;}
if( Key.isDown(Key.UP) ){
y = y – velocity;}
if( Key.isDown(Key.DOWN) ){
y = y + velocity;}

if( Key.isDown(Key.SPACE) && shootLimiter > 8)
{
shootLimiter = 0;
var missile = _root.attachMovie(“Missile”,“Missile” + _root.getNextHighestDepth(), _root.getNextHighestDepth());
missile.
x = x + 110;
missile.
y = _y + 15;
}

enemyTimer = 1;
if(enemyTimer > 60)
{
enemyTimer = 0;
_root.attachMovie(“EnemyShip”, “EnemyShip”
_root.getNextHighestDepth(), _root.getNextHighestDepth());
}

enemyTimer += 1;
if(enemyTimer > 60)
{
enemyTimer = 0;
var enemy = _root.attachMovie(“EnemyShip”, “EnemyShip” + _root.getNextHighestDepth(), _root.getNextHighestDepth());
enemies.push(enemy);
}
}

 
avatar for TheFishOfDoom TheFishOfDoom 9 posts
Flag Post

on the enemy ship class, try removing the second } after calling the explode function

Sign in to reply