Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

error 1067: Implicit coercion of a value of type flash.display:Movieclip to an unrelated type of cla

New Here ,
Jan 15, 2014 Jan 15, 2014

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?

TOPICS
ActionScript
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 15, 2014 Jan 15, 2014

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];

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 15, 2014 Jan 15, 2014
LATEST

       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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines