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

Events on document class

Community Beginner ,
Mar 30, 2009 Mar 30, 2009
Hi all!

I have a problem...if I attach an event (mouse_move) on a document class (that extends movieclips) it traces the coordinates of the mouse pointer only when I pass over his children. Why it doesn't trace also in the empty area? I need to catch the coordinates of the mouse everywhere ...

Thanks in advance
TOPICS
ActionScript
753
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
Guest
Mar 30, 2009 Mar 30, 2009
Try adding the eventlistener to the stage like this:

this.stage.addEventListener(MouseEvent.MOUSE_MOVE, showCoords);
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 Beginner ,
Mar 30, 2009 Mar 30, 2009
Hi Joergen, in this way it works, but I don't understand why it doesn't in the other case... The document class extends movieclip so using mouse_move directly on it should work ...

Thanks for the help

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
Engaged ,
Mar 30, 2009 Mar 30, 2009
Sorry to jump in here... You have to tell your code what display object is creating the event. If, by setting your listener to the stage object as Joergen suggested, then you have access to the full width and height of your movie, whereas with just setting your listener to a movie clip on the stage, you only have access to the dimensions of that clip.
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 Beginner ,
Mar 30, 2009 Mar 30, 2009
Hi xchanin,

But doesn't the document class have the same width / height of the stage? It is a movieclip too but if I put a listener here it reports only the coordinates when I pass over a child...

Thanks!
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
Engaged ,
Mar 30, 2009 Mar 30, 2009
Oh I see what you're saying: by either leaving the target for the event listener empty
addEventListener(MouseEvent.MOUSE_MOVE,test);

or by populating it with' this'
this.addEventListener(MouseEvent.MOUSE_MOVE,test);

then the mouseover is only working on the actual movie clip added to the stage. I'm not exactly sure why it defaults this way, maybe someone else in here has the answer to your question.
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
Guest
Mar 31, 2009 Mar 31, 2009
Well, I see it this way:
When the player starts, it generates a displaylist with the stage at the root and an instance of the document class on top of that. Then it adds all other objects placed on the stage at design time.
The instance of the document class has no graphical extension, so adding the listener to that instance will only generate listening behavior from it's graphical descendants.
On the opposite, adding the listener to the stage will generate listening behavior from the stage and all descendants.
I wonder, if this is the correct interpretation?
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 Beginner ,
Mar 31, 2009 Mar 31, 2009
LATEST
Hi !

I think you are right...the strange thing is that the document class is a movieclip...so it should accept listener too...

Thanks
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