dimanche 19 mars 2017

EventDispatch error in action script 3

I am not sure if something is wrong with my code or if I have to handle the error differently. I have an instance of Gear and the other one is bLine. I am trying to make both move as soon as the gear falls on the line. So what I have inside of the instance coded is:

var ev2:Event = new Event("transfer");

dispatchEvent(ev2);


stop();

In the bLine I have: `

import flash.events.Event;

this.addEventListener(Event.ENTER_FRAME,Move);

function Move(e:Event):void {
    this.x=this.x+3;

};

Then, in the main timeline:

 import flash.events.Event;
gear.addEventListener("transfer",transferGear);

function transferGear(e:MouseEvent) {
bLine.gotoAndPlay(2);

 };

This is the output I'm getting: "TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@16bbd6bb7821 to flash.events.MouseEvent. at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent()

at Rube2_fla::mc_gear_4/frame24()"

So what am I doing wrong and how I could fix it?

Aucun commentaire:

Enregistrer un commentaire