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

Dont detect MouseEvent as2 to as3.

New Here ,
Dec 28, 2012 Dec 28, 2012

Hello. I transform a as2 game to as3. transform all the code and the game start but dont detect any MouseEvent associated to a MovieClip. In stage yes but not in any MovieClip. This is one example of my code...

Code:

wheelmain.wheel.addEventListener(MouseEvent.MOUSE_DOWN, onWheelDown);
wheelmain.wheel.addEventListener(MouseEvent.MOUSE_UP, onWheelUp);
wheelmain.wheel.addEventListener(MouseEvent.ROLL_OUT, onWheelRollOut);
wheelmain.wheel.addEventListener(MouseEvent.CLICK, onWheelReleaseOutside);

function onWheelDown(e:MouseEvent)
{
     trace("Boton del raton pulsado.");
     //sndPotencia.start();
     potenciaRuletaOn();
}

wheelmain.wheel exists and is a MovieClip. The movie dont show nothing to console.

Anybody help me?.

thanks!.

TOPICS
ActionScript
1.8K
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
Community Expert ,
Dec 28, 2012 Dec 28, 2012

what's in the output panel when you use:

wheelmain.wheel.addEventListener(MouseEvent.MOUSE_DOWN, onWheelDown);
wheelmain.wheel.addEventListener(MouseEvent.MOUSE_UP, onWheelUp);
wheelmain.wheel.addEventListener(MouseEvent.ROLL_OUT, onWheelRollOut);
wheelmain.wheel.addEventListener(MouseEvent.CLICK, onWheelReleaseOutside);
trace(wheelmain.wheel.stage,wheelmain.wheel.x,wheelmain.wheel.y,wheelmain.wheel.mouseEnabled)

function onWheelDown(e:MouseEvent)
{
     trace("Boton del raton pulsado.");
     //sndPotencia.start();
     potenciaRuletaOn();
}
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
New Here ,
Dec 28, 2012 Dec 28, 2012

This is the output:

[object Stage] 0 0 true

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
Community Expert ,
Dec 28, 2012 Dec 28, 2012

can you see wheelmain.wheel?

if it's covered by another object, has its (or one of its parents) visible property assigned to false, it will not respond to the mouse.

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
New Here ,
Dec 28, 2012 Dec 28, 2012

Yes, i see the movieclip in the screen but the strange thing is that any of the movie MovieClip respond to mouse events

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
Community Expert ,
Dec 28, 2012 Dec 28, 2012

i didn't understand your last post.

is wheelmain.wheel timeline tweened?

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
New Here ,
Dec 28, 2012 Dec 28, 2012

Sorry for my bad english.

Well, if i change one of the lines and type this:

wheelmain.wheel.addEventListener(Event.ENTER_FRAME, onWheelDown);

when the output console write:

Boton del raton pulsado.

Boton del raton pulsado.

Boton del raton pulsado.

Boton del raton pulsado.

.

.

That means that the object is displayed and accessible, but for some strange reason it seems that no stage Movieclip dispatches any mouse event.

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
Community Expert ,
Dec 28, 2012 Dec 28, 2012

that doesn't mean the object is displayed and it doesn't mean the object is accessible.

it just means wheelmain.wheel exists when the listener is added.  if those traces continue when you click wheelmain.wheel you can conclude it exists when you click something.  but, you cannot conclude you clicked the object that has the enterframe listener.

is wheelmain.wheel or wheelmain part of a timeline tween.

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
New Here ,
Dec 28, 2012 Dec 28, 2012

To my knowledge there is not part of any interpolation, the movie only has 1 frame.

When i transform the game as2 to as3 i only changed code,dont change library and in as2 the game run correctly.

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
Community Expert ,
Dec 28, 2012 Dec 28, 2012

because similar code worked in as2 doesn't mean much.  as3 is much more picky and has a tendency to lose object references for no good reason.

if there is no timeline tweening, put your mouse listener code in the first keyframe that contains wheelmain.wheel. retest.

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
Enthusiast ,
Dec 28, 2012 Dec 28, 2012
LATEST

Maybe a transparent object is over the stage

try

stage.addEventListener(MouseEvent.CLICK, dimeVaquero)

function dimeVaquero(e:MouseEvent):void {

    trace(e.target.name);

}

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