Skip navigation
Currently Being Moderated

TransformGestureEvent misbehaving when zooming over child objects

May 1, 2012 7:46 AM

Tags: #as3 #ios #zoom #children #transformgestureevent

I'm building an iPad app that has a few objects that have mouse/touch interaction and an overall zoom gesture on the stage (which zooms a placeholder with these other object added as children - so that all the objects zoom together).

 

All works well if I 'two finger' zoom on a clear area of the stage but if this action occurs over any of the children the placeholder zoom goes crazy! It's fixed by adding placeHolder.mouseChildren = false; - but then the interaction of the children can't be accessed?

 

I've also tried to add / reinstate the mouseChildren bool as follows:

 

if (event.phase==GesturePhase.BEGIN || event.phase==GesturePhase.UPDATE) {

  placeHolder.mouseChildren = false;

} else if (event.phase==GesturePhase.END) {

  placeHolder.mouseChildren = true;

}

 

...but it seems the event is already captured on the child object as the zoom misbehaves once again (event though the children do not have any TransformGestureEvent.GESTURE_ZOOM events added).

 

Has anyone else run else run into this problem and can offer a helping hand?

 

Many thanks in advance!

 

AC

 
Replies
  • Currently Being Moderated
    May 1, 2012 9:00 AM   in reply to AuntieChristo

    Zooming can't go on forever. Perhaps a timer event to fire off the mouseChildren=true?

     
    |
    Mark as:
  • Currently Being Moderated
    May 1, 2012 9:23 AM   in reply to AuntieChristo

    You're trying to scale a clip that contains other clips while somehow the children clips aren't affected. You're in the 1% margin of the time that someone wants that to happen.

     

    It's math time. You're going to need to run a calculation on the scale of the outer clip and reduce the size of the child clips proportionately as well as re-align them if needed.

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 10:26 AM   in reply to AuntieChristo

    Your children are capable of receiving (stealing) events. So when you roll over them you're now triggering another event.

     

    For example, if you made a background for your whole outer clip and then applied the handler to that, all the images would be on top. Therefore anytime you roll over (touch) one of the pictures the event for the picture will fire off.

     

    It's a catch 22 that I often use a little class I wrote called "Intent". When the user touches the screen I don't "do" anything until they tell me what they "intend" on doing. If they move their fingers I know they want to move something. If they touch it and let go briefly, I know that's probably a click "intent". It's how I allow large container clips to be dragged that contain children that can also be clicked. If you don't click and move the mouse (or a finger) a certain distance I consider it a click. Then I'd zoom in on the picture clicked. However if you touch and move your fingers, I'll do something else like drag or zoom, based on what you're doing.

     

    Toss some trace()s up on the methods invoked when you sense for zoom and also on the image clips. I think you'll find your image clips are firing off and that's when you lose the zoom.

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 1:10 PM   in reply to AuntieChristo

    Some components can give you what you want like the scroller components (hopefully you're using Flash Builder or are using the latest Flex SDK for Spark components). Things like scrollers and Lists all use the same type of approach (I don't know how they do it but it's built in). Like on a list if you drag it the list will scroll but if you click an item it will select that item in the list. Same basic idea. "Do nothing on click, wait to figure out intent, handle it".

     

    Let me know if you have any questions. I made that system wayyyyy back in AS2 before spark ever existed.

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 5:40 AM   in reply to AuntieChristo

    No the intent is for the past. I was just offering past experience. I'm glad you figured it out in a modern way. Stick to that .

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points