Skip to main content
ColbyFulton
Known Participant
January 15, 2019
Answered

eventListener for movieClip inside other movieClip

  • January 15, 2019
  • 1 reply
  • 1260 views

So I'm building a game that has a playing area which can be scrolled (dragged) with a finger to allow more horizontal play area. I've got buttons on the main stage which allow characters to be created... these used to create the characters on the stage but now with this draggable map, I've used addChild to add them to the gameplay movie clip (which works great, the little animated characters are now 'attached' to the gameplay area).

The problem is that the eventListener which would detect whether these characters are clicked on to control them no longer works. Should I be handling all the eventListeners and functions for these characters on the timeline of the parent movieClip? Or can I control them all through the main stage code using some "my_mc.eventListener..." style coding? I can't seem to get that working.

Thx

This topic has been closed for replies.
Correct answer Colin Holgate

There is target and currentTarget. You can perhaps use currentTarget to see if the user is trying to touch an embedded object.

The complication is that if they intend to drag, but happen to be over an object at the time, that could confused things. There are solutions to that.

First see if currentTarget helps.

1 reply

Colin Holgate
Colin HolgateCorrect answer
Inspiring
January 15, 2019

There is target and currentTarget. You can perhaps use currentTarget to see if the user is trying to touch an embedded object.

The complication is that if they intend to drag, but happen to be over an object at the time, that could confused things. There are solutions to that.

First see if currentTarget helps.

ColbyFulton
Known Participant
January 15, 2019

Yeah I thought the drag eventListener might have been disrupting things. I traced the character's mouse event eventListener and it doesn't activate when you click on them... but they still move off the screen in a weird way. I'm not sure why they're x & y locations are being affected at all by a click...

Thanks I'll look into this target stuff