Copy link to clipboard
Copied
Hello,
i'm building a shooting game in as3 and i'm having trouble in making the cursor hit the creatures..
that's my code:
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.events.Event;
import flash.events.MouseEvent;
Mouse.hide();
var notequals:Timer = new Timer(1500, 1);
notequals.addEventListener(TimerEvent.TIMER,enterdmuiot);
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_5);
function fl_EnterFrameHandler_5(event:Event):void
{
notequals.start( );
my_cursor.x=mouseX;
my_cursor.y=mouseY;
}
function enterdmuiot(event:TimerEvent):void{
var dmuiot:Array = [dmutjump, dmutskate, dmutwalk, dmutonrope];
var myname:Array=["dmutjump", "dmutskate", "dmutwalk", "dmutonrope"];
for (var i:Number = 0; i<1; i++)
{
var myRnd:Number = int (Math.random()*dmuiot.length);
var dmut:MovieClip = new dmuiot[myRnd];
dmut.name = myname[myRnd];
addChild(dmut);
trace(dmut);
}
stage.addEventListener(MouseEvent.CLICK, dmutclick);
function dmutclick(e:MouseEvent):void
{
if (e.target is dmut){
e.target.parent.removeChild(e.target);
}
}
}
I always get error 1067:(
can someone help me with it?
Copy link to clipboard
Copied
enable debugging in your publishing options to identify the line in your code, where the error occurs.
i suppose its here where your code goes wrong:
var myRnd:Number = int (Math.random()*dmuiot.length);
var dmut:MovieClip = new dmuiot[myRnd];
Copy link to clipboard
Copied
if (e.target is dmut){
dmut is an object, not a class, and depending on what you are trying to do it is only going to be recognized as the last of the objects you create