Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-14-2011, 08:02 AM   #1
Rtaos
Registered User
 
Join Date: Jun 2011
Posts: 7
Default [AS3] Error 1078: Label must be a simple identifer

I am making a Flash game where you move a gun left to right across the screen to shoot at targets above. It has four external actionscripts: the game code itself, the gun object, the target object and the bullet objects.

The problem is with the gun object actionscript named: lGun. The game will not play and comes up with error 1078: label must be a simple identifer. The offending code is marked with a smilie.

lGun external actionscript file:
<as>
package {
import flash.display.*;
import flash.events.*;
import flash.utils.getTimer;

public class lGun extends MovieClip {
static const speed:Number = 150.0;
private var lastTime:int; // animation time

public function lGun() {
//intial location of gun
this.x = 275;
this.y = 340;

//movement
addEventListener(Event.ENTER_FRAME,movelGun): //this code has error 1078.
}
}

public function movelGun(event:Event) {
//get time difference
var timePassed:int = getTimer()-lastTime;
lastTime += timePassed;

// current position
var newx = this.x;

//move to the left
if (MovieClip(parent).leftArrow) {
newx -= speed*timePassed/1000;

}

//move to the right
if (MovieClip(parent).rightArrow) {
newx += speed*timePassed/1000;
}

//check boundaries
if (newx < 10) newx = 10;
if (newx > 540) newx = 540;

//reposition
this.x = newx;
}

// remove from screen and remove events
public function deletelGun() {
parent.removeChild(this);
removeEventListener(Event.ENTER_FRAME,movelGun);
}
}
}
</as>

This is a really odd error and I doubt there's a problem with the actionscript but somewhere else in the program. This is a tough one but any assistance people can provide will be much appreciated.

PS: Tried to use the as tags, didn't work sorry. I'm in a bit of a rush.
Rtaos is offline   Reply With Quote
Old 06-14-2011, 08:20 AM   #2
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,833
Send a message via Skype™ to henke37
Default

Colon instead of semicolon at the end of the line.
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Old 06-14-2011, 09:13 AM   #3
Rtaos
Registered User
 
Join Date: Jun 2011
Posts: 7
Default Error 5006: Actionscript cannot have two defintions

Ahh, thanks very much.

But now I've got another problem. Error 5006: An actionscript can not have more than one externally visible defintion: lGun, movelGun.

It thinks the movelGun is a second class but it isn't as it's inside the public class.

package {
import flash.display.*;
import flash.events.*;
import flash.utils.getTimer;

public class lGun extends MovieClip {
static const speed:Number = 150.0;
private var lastTime:int; // animation time

public function lGun() {
//intial location of gun
this.x = 275;
this.y = 340;

//movement
addEventListener(Event.ENTER_FRAME,movelGun);
}
}

public function movelGun(event:Event) { //It's inside the public class...
//get time difference
var timePassed:int = getTimer()-lastTime;
lastTime += timePassed;

This one is even more confusing than the last. Any help please?
Rtaos is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:37 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.