Touch events conundrum/problem

I've been using Flash CS5.5 targeting the IOS platform (iPad).
I have been writing a small application that relies on things being  dragged around - can't really say much more right now.
I need to know when dragging starts, so on the thing that's being  dragged I add a listener for TouchEvent.TOUCH_BEGIN.
I need to know when it's being moved, so the widget also has a listener  for TouchEvent.TOUCH_MOVE.
And finally, I need to know when dragging stops, so the widget listens  for TouchEvent.TOUCH_END.
Now mostly, everything goes OK, I get:
TOUCH_BEGIN, followed by one or more TOUCH_MOVE, and finally a  TOUCH_END. Happiness.
I have noticed that sometimes if I drag too fast and/or gently do a  swipe motion lifting my finger gently, the TOUCH_END doesn't seem to  happen, so the app doesn't know that the user has stopped dragging. For  the app, this is a problem because the user is allowed to position the  widget roughly and on TOUCH_END it should snap into place.
Anyone else seen this?
I can imagine a workaround using a timer to catch missing TOUCH_END  events, but it's a bit of a kludge.
Paul
Test case: I have created a very simple app with a symbol instance "square" which is simply a MovieClip containing a box shape and also on the stage I have a text field "countText". Dragging the square around gently means the numbers show multiple moves and matching begins and ends. Start dragging quickly and gently lifting the finger then the begin events then outnumber the end ones.
On frame 1 I have the following code:
stop();
import flash.ui.*;
import flash.events.TouchEvent;
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
square.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchEvent);
square.addEventListener(TouchEvent.TOUCH_MOVE, onTouchEvent);
square.addEventListener(TouchEvent.TOUCH_END, onTouchEvent);
var beginCount:uint=0;
var moveCount:uint=0;
var endCount:uint=0;
function onTouchEvent(event:TouchEvent):void{
    switch (event.type){
        case TouchEvent.TOUCH_BEGIN:
                    beginCount++;
                    square.startTouchDrag(event.touchPointID);
                    break;
        case TouchEvent.TOUCH_MOVE:
                    moveCount++;
                    break;
        case TouchEvent.TOUCH_END:
                    endCount++;
                    square.stopTouchDrag(event.touchPointID);
                    break;
    countText.text = "begin: "+beginCount+" move: "+moveCount+" end: "+endCount;

I realised myself what has been happening.
With the listener added to the component being dragged, there's a problem when the drag speed is too fast because the movement of the component being dragged can lag behind the finger. When this happens, the TOUCH_END  event may not be seen by the dragged object, because the finger is being raised from the tablet when the dragged object hasn't caught up with the movement of the finger so it doesn't catch the event. Basically the finger moves off the dragged component when the finger goes too fast.
The solution has been to add the TOUCH_MOVE and TOUCH_END listeners to the stage.
Paul

Similar Messages

  • Timer & Touch Event Problem

    Hi all,
    I am developing a block game in iphone & i am facing problem in timer & touch event.
    The timer goes slower down & the app stuck on the device as well as simulator after sometime.
    Also when a particular block is touched.. the events are not fetched properly..
    Please comment if you have any suggestion.
    Thanks
    Jaya

    I remember slightly is has something to do with runloops.
    If I am not wrong, timers and events get added to the current NSRunLoop and processed in the order of entry. If your runloop is full with stuff things might maybe slow down or get dropped.
    Not sure if thats 100% how it works, but maybe check the documentatoion for RunLoops/Timer

  • Switching touch events from symbols/classes to the main stage?

    For previous threads:
    http://forums.adobe.com/thread/864057
    http://forums.adobe.com/thread/863566
    http://forums.adobe.com/thread/864262
    http://forums.adobe.com/thread/863597
    Bug ID #2940816
    I have an app that wasn't compiling correctly. I sent the bug to Adobe who responded with a workaround. However, I can't figure out how to make their stated workaround work in my code.
    I have puzzle pieces on the stage. Each is assigned to a separate class. Inside the class I have touch events defining multiple touch events for each piece.
    I have another spot on the stage where, when it is touched, a puzzle piece appears. These are also each linked to a separate class. Inside this class I also have touch events defining multiple touch events for each piece.
    Though it works fine on my computer, it wasn't working on an iPad. Adobe said that I needed to switch the touch events so that they were assigned to the main stage instead of to each individual object.
    However, the code they gave me didn't really make sense in context and I'm confused how to implement it.
    This is the code in the class for each piece that is created when you touch the stage:
            public function GeoPiece(): void {
                if (PuzzleGlobals.currentLevel == "Name") {
                    this.gotoAndStop("wholeName");
                else if (PuzzleGlobals.currentLevel == "Abbrev") {
                    this.gotoAndStop("abbrev");
                else if (PuzzleGlobals.currentLevel == "Shape") {
                    this.gotoAndStop("shape");
                this.addEventListener(TouchEvent.TOUCH_MOVE, geoPieceBegin);
            public function geoPieceBegin (e:TouchEvent): void {
                PuzzleGlobals.pieceActive = true;
                e.target.startTouchDrag(e.touchPointID, false);
                e.target.addEventListener(TouchEvent.TOUCH_END, geoPieceEnd);
                e.target.interactionBegin();
                MovieClip(this.parent.parent).nameDisplay.gotoAndStop(e.target.abbrev);
                PuzzleGlobals.currentPiece = e.target.abbrev;
            public function geoPieceEnd (e:TouchEvent): void {
                PuzzleGlobals.pieceActive = false;
                if (currentObjOver.isLocked == true) {
                    currentObjOver.gotoAndStop ("Lock");
                else {
                    currentObjOver.gotoAndStop ("Out");
                MovieClip(this.parent.parent).nameDisplay.gotoAndStop(PuzzleGlobals.chosenPuzzle);
                e.target.stopTouchDrag(e.touchPointID);
                if (this.dropTarget.parent is GeoPuzzle) {
                    if (GeoPuzzle(this.dropTarget.parent).abbrev == e.target.abbrev) {
                        PuzzleGlobals.statesCompletedUSA++;
                        GeoPuzzle(this.dropTarget.parent).isLocked = true;
                        GeoPuzzle(this.dropTarget.parent).gotoAndStop("Lock");
                        e.target.parent.removeChild(DisplayObject(e.target));
                    else {
                        //play BOOP sound indicated wrong drop;
                if (PuzzleGlobals.statesCompletedUSA == PuzzleGlobals.TOTAL_NUMBER_USA) {
                    //play fireworks game
                else {
                    //do nothing
                e.target.removeEventListener(TouchEvent.TOUCH_END, geoPieceEnd);
            public function interactionBegin () {
                if (this.dropTarget != null && this.dropTarget.parent is GeoPuzzle) { //check to make sure it's over a puzzle piece
                    currentObjOver = GeoPuzzle(this.dropTarget.parent);
                    currentObjOver.gotoAndStop("Over");
                if (lastObjOver != currentObjOver) {
                    if (lastObjOver.isLocked == true) {
                        lastObjOver.gotoAndStop("Lock");
                    else {
                        lastObjOver.gotoAndStop("Out");
                    lastObjOver = currentObjOver;
    This is the code in the class for each piece that's already on the stage:
            public function GeoPuzzle(): void {
                if (this.isLocked == true) {
                    this.gotoAndStop ("Lock");
                if (PuzzleGlobals.pieceActive == true) {
                    this.addEventListener(TouchEvent.TOUCH_BEGIN, geoPuzzleBegin);
            public function geoPuzzleBegin (e:TouchEvent): void {
                e.target.addEventListener(TouchEvent.TOUCH_END, geoPuzzleEnd);
                e.target.gotoAndStop("Over");
                MovieClip(this.parent).nameDisplay.gotoAndStop(e.target.abbrev);
            public function geoPuzzleEnd (e:TouchEvent): void {
                if (e.target.isLocked == false) {
                    e.target.gotoAndStop("Off");
                else if (e.target.isLocked == true) {
                    e.target.gotoAndStop("Lock");
                MovieClip(this.parent).nameDisplay.gotoAndStop(PuzzleGlobals.chosenPuzzle);
                e.target.removeEventListener(TouchEvent.TOUCH_END, geoPuzzleEnd);
    You can see that each piece (whether it's already locked on the stage or movable) reacts differently to different touch events. However, this is the code that Adobe gave me as a workaround:
    this.stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchEvent);
    this.stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchEvent);
    this.stage.addEventListener(TouchEvent.TOUCH_END, onTouchEvent);
    var beginCount:uint=0;
    var moveCount:uint=0;
    var endCount:uint=0;
    function onTouchEvent(event:TouchEvent):void{
         switch (event.type){
              case TouchEvent.TOUCH_BEGIN:
                             trace("BEGIN")
                             beginCount++;
                             square.x = event.stageX;
                             square.y = event.stageY;
                             square.startTouchDrag(event.touchPointID, false);
                             break;
              case TouchEvent.TOUCH_MOVE:
                             trace("MOVE")
                             moveCount++;
                             break;
              case TouchEvent.TOUCH_END:
                             trace("END")
                             endCount++;
                             square.stopTouchDrag(event.touchPointID);
                             break;
         trace("begin: "+beginCount+" move: "+moveCount+" end: "+endCount);
    //     countText.text = "begin: "+beginCount+" move: "+moveCount+" end: "+endCount;
    This doesn't make any sense to me because it seems that it would only work if touching the stage had to react in just a single way. I have multiple pieces that need to each react differently.
    1. The pieces that are locked to the stage need to highlight when touched and display their name.
    2. These pieces also need to keep themselves highlighted and their names displayed when the touch is dragged off of them instead of just removed.
    3. Each piece needs to be created when touching the Puzzle Piece button the stage. As these pieces are dragged, they need to highlight the pieces underneath them and unhighlight them when they are dragged off. They also need to display their own names, and lock into place when they are dragged over the correct piece.
    My questions are:
    1. Why don't touch events work in the compiler?
    2. How can I translate my current working code's touch events to all be directly linked to the stage instead of their objects?
    Thanks so much!
    Amber

    I am going to copy and paste this answer into all of the forums I've asked this question in case some noob like me comes along and needs the answer.
    I found the problem! After 3 months I finally figured out what was wrong and why my app was working in Device Central when exported as Flash 10.1 and not on my iPad when exported as AIR for iOS.
    The problem is that in the Flash runtime, if a line of code returns a bug, the flash runtime says "Error, shmerror, try again next time." So I had one if, else statement that was executing when it wasn't supposed to be - only once, at the very beginning of the program. It was throwing an error. When I exported as Flash, flash didn't care, and still executed the code later when it was supposed to. But Apple won't let their programs crash. So instead of just trying that code again, Apple decided, after the first error was thrown, that it would then COMPLETELY IGNORE that line of code. So the error was in the line where the states would unhighlight themselves. Apple just shut down that line of code, that's why it wouldn't execute properly.
    I ended up changing this line of code
    if (lastObjOver != null && lastObjOver.isLocked == true)
    which threw an error when the piece was FIRST dragged over the puzzle, to to this
    if (lastObjOver.parent != null && lastObjOver.isLocked == true)
    which wouldn't throw the error.
    Problem solved!
    If anyone else is having this problem, I suggest you do what I did. Change all your touch events to mouse events so you can run the program in the adc debugger. That's when I discovered the error being thrown.

  • How to implement drag and drop functionality in a HTML5 webpage using touch events?

    Hi all,
         I need to create a webpage having two parts.One part is having set of SVG images into it and other part is having canvas.I need to drag those image onto the canvas allowing same image for multiple times and those images on the canvas are movable inside the canvas only. This webpage is only used in iphone or ipad like touching devices so I need to handle touch events.
         There is already jQuery plugin for drag drop functionality but it is not supported for touch events.
    It is only for desktop veriosns.So if you know about any jquery plugin let me know.
         So please help me to carry out this task.

    I have tried using the same but still not working.
    I have handled touch events like touchstart,touchend,touchmove.
    But the problem is when I drag the image from upperbox onto canvas, the clone of that image is creating but the image which I dragged on canvas gets vanished.
    I am creating clone because I want to add multiple images onto canvas.
    Atik

  • How to get a touch event in a UIWebView object?

    I have looked around and several people have had the same question but a workable answer has not arisen. I want to detect a touchesEnded() event in an area which is covered by a UIWebView() control. Normally a webview eats all the touches; I don't want to use the trick of having a transparent UIView on top of my UIWebView to grab the touches because I want to let most of the touches through to the UIWebView control so that the user can scroll. I suspect I have to grab events at the higher level and filter them, apparently subclassing UIWebView doesn't pass the events through, surely someone has solved this very fundamental problem.

    I have been working on same problem. I came to following conclusion. There are two ways to handle:
    1. Subclass: WebView doesn't forward touch events by blocking in hitTest function. But link clicking works
    2. Transparent subview of WebView: Touch events obtained through transparent view can be forwrded to scrollview subview of webView and all seems working. But link linking fails. It seems like touch event for link clicking is handled by webView only. It does it before other touch events are processed. So there is no point in passing those touch events to webView. WebView doesn't expose way to handle click handling.
    Correct me if wrong. If someone has solution please post.

  • [iPhone] - No Touch Events After Selecting Photo in UIImagePicker

    In my OpenGL ES app, after calling the UIImagePicker and selecting a photo (or hitting cancel,) my app no longer registers any touch events.
    Touch events work fine before UIImagePicker is called. I am guess that somehow UIImagePicker (even though I release it) or something else is intercepting the touch events and not passing them along.
    Does anyone have any idea how to solve this problem?
    Photo Controller code:
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
    [self UseImage:image];
    // Remove the picker interface and release the picker object.
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    [picker release];
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    [picker release];
    - (void)SelectPhoto
    if( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary ] )
    UIImagePickerController *pImagePicker;
    pImagePicker = [[UIImagePickerController alloc] init];
    pImagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    pImagePicker.delegate = self;
    pImagePicker.allowsImageEditing = NO;
    // Picker is displayed asynchronously.
    [self presentModalViewController:pImagePicker animated:YES];
    - (void)TakePhoto
    if( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera ] )
    UIImagePickerController *pImagePicker;
    pImagePicker = [[UIImagePickerController alloc] init];
    pImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    pImagePicker.delegate = self;
    pImagePicker.allowsImageEditing = NO;
    // Picker is displayed asynchronously.
    [self presentModalViewController:pImagePicker animated:YES];
    // Implement this method in your code to do something with the image.
    - (void)UseImage:(UIImage*)theImage
    The code calling the photo controller:
    [g_window addSubview:m_pPhotoController.view];
    [m_pPhotoController SelectPhoto];
    Thanks.

    Some more information:
    If I add a TouchesBegan function to my PhotoController it registers the touches. The stack-trace is:
    #0 0x000315be in -[GEPhotoController touchesBegan:withEvent:] at gephotocontroller.mm:155
    #1 0x30adb941 in forwardMethod2
    #2 0x30a6786b in -[UIWindow sendEvent:]
    #3 0x30a56fff in -[UIApplication sendEvent:]
    #4 0x30a561e0 in _UIApplicationHandleEvent
    #5 0x31565dea in SendEvent
    #6 0x3156840c in PurpleEventTimerCallBack
    #7 0x971545f5 in CFRunLoopRunSpecific
    #8 0x97154cd8 in CFRunLoopRunInMode
    #9 0x31566600 in GSEventRunModal
    #10 0x315666c5 in GSEventRun
    #11 0x30a4eca0 in -[UIApplication _run]
    #12 0x30a5a09c in UIApplicationMain
    #13 0x00002be0 in main at main.m:14
    I tried removing the photo controller's view by calling
    [m_pPhotoController.view removeFromSuperview];
    But to no avail. My photo controller object still captures all the touch events.

  • IBooks mouse and touch events

    We have an issue with our interactive books on the ipad. We are using epub3, javascripts and event listeners. All interactivity works perfectly on the ipad using eventlistener for touch. When we download the book to mac-maverick-ibooks there is no issue with the mouse events working on the touch events.. Apple want the books to include javascript to handle both touch or mouse events for each device. We attempted to include mouse events with the touch events without success.  Does anyone know how to handle this.  This is a snippet of the code we triede to use without success.
    var eventName = "click";
    if (navigator.epubReadingSystem.hasFeature('touch-events')) { eventName = "touchstart"; }
    if (document.getElementById('openpopup')) { document.getElementById('openpopup').addEventListener(eventName,popup,false); }

    Many Thanks Richard.. sorry for the delay I was away traveling ..I havn't done anything to my pc as yet , but the problem seems to have gone... My son said it was probably because I put some new applications on and maybe this had something to do with it, but it seems to have sorted itself out now..but I will keep your suggestion ready incase it happens again .. thank you again Phil

  • [IPhone SDK] NSTimer conflicts with touch events

    Hi all,
    i've an NSTimer that refresh the UIView at 30 fps. Below there is the scheduled timer:
    animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(refreshAll) userInfo:nil repeats:YES];
    The problem is that the app doesn't wrap the touch events (touchbegan, touchesMoved and touchEnded) because the timer interval is too low and conflicts with this events.
    I tried to set the animation interval to 2 seconds and the touch events works but the rendering obviously is slow.
    However the problem is only on the device because when i launch the app on the simulator i have no problem with the timer.
    Can anyone tell me how I can solve this problem?
    Thanks

    The game I'm developing for the iPhone has 2 play modes (the second mode has more on screen objects). In the first game mode, I get a solid 29-30 frames per second (acceptable), however the second mode with more objects gives me 25 fps (slightly jerky). BTW, on a PC with modern hardware I get >1300 fps @1680x1050.
    At first I thought that the NSTimer resolution might be causing problems. The Apple demos all use a resolution of 1/60. Setting a value of 0.0 actually bumps the frame rate up by few frames, but I lose the ability to process touch input (crap). Adding usleep(a_delta) hoping to invode a context switch does nothing for the touch input.
    The next thing I tried was creating a dedicated rendering thread which basically does a while (1) render(); The thread will loop as fast as it can, and I regain touch input. On the plus side, I gained 3-4 fps for both game modes, so now I can hit 30 fps for the second mode (sweet).
    To make this work, I obviously needed to add locking primitives between the render thread and the iphone input (touch, sleep, phone call etc). The render loop is now basically:
    while (alive)
    aLock->Lock();
    render();
    aLock->Unlock();
    Anyway, I thought people would appretiate my experience when looking to squeeze a few more frames out of the iPhone. You just need to understand multiprocessing to work out the synchronisation issues.
    PS. There is some interesting advice in the following thread:
    http://discussions.apple.com/thread.jspa?messageID=7898898&#7898898
    Basically, they set invoke the runloop from the animation method. This might be simpler than spawning threads and handling locking, but I haven't tried it.

  • Bug fix requires switching touch events from symbols/classes to the main stage?

    Also posted in Mobile Development, I'm still not sure which forum I should be in.
    For previous threads:
    http://forums.adobe.com/thread/864057
    http://forums.adobe.com/thread/863566
    http://forums.adobe.com/thread/864262
    http://forums.adobe.com/thread/863597
    Bug ID #2940816
    I  have an app that wasn't compiling correctly. I sent the bug to Adobe  who responded with a workaround. However, I can't figure out how to make  their stated workaround work in my code.
    I have puzzle  pieces on the stage. Each is assigned to a separate class. Inside the  class I have touch events defining multiple touch events for each piece.
    I  have another spot on the stage where, when it is touched, a puzzle  piece appears. These are also each linked to a separate class. Inside  this class I also have touch events defining multiple touch events for  each piece.
    Though it works fine on my computer, it wasn't  working on an iPad. Adobe said that I needed to switch the touch events  so that they were assigned to the main stage instead of to each  individual object.
    However, the code they gave me didn't really make sense in context and I'm confused how to implement it.
    This is the code in the class for each piece that is created when you touch the stage:
            public function GeoPiece(): void {
                if (PuzzleGlobals.currentLevel == "Name") {
                    this.gotoAndStop("wholeName");
                else if (PuzzleGlobals.currentLevel == "Abbrev") {
                    this.gotoAndStop("abbrev");
                else if (PuzzleGlobals.currentLevel == "Shape") {
                    this.gotoAndStop("shape");
                this.addEventListener(TouchEvent.TOUCH_MOVE, geoPieceBegin);
            public function geoPieceBegin (e:TouchEvent): void {
                PuzzleGlobals.pieceActive = true;
                e.target.startTouchDrag(e.touchPointID, false);
                e.target.addEventListener(TouchEvent.TOUCH_END, geoPieceEnd);
                e.target.interactionBegin();
                MovieClip(this.parent.parent).nameDisplay.gotoAndStop(e.target.abbrev );
                PuzzleGlobals.currentPiece = e.target.abbrev;
            public function geoPieceEnd (e:TouchEvent): void {
                PuzzleGlobals.pieceActive = false;
                if (currentObjOver.isLocked == true) {
                    currentObjOver.gotoAndStop ("Lock");
                else {
                    currentObjOver.gotoAndStop ("Out");
                MovieClip(this.parent.parent).nameDisplay.gotoAndStop(PuzzleGlobals.c hosenPuzzle);
                e.target.stopTouchDrag(e.touchPointID);
                if (this.dropTarget.parent is GeoPuzzle) {
                    if (GeoPuzzle(this.dropTarget.parent).abbrev == e.target.abbrev) {
                        PuzzleGlobals.statesCompletedUSA++;
                        GeoPuzzle(this.dropTarget.parent).isLocked = true;
                        GeoPuzzle(this.dropTarget.parent).gotoAndStop("Lock");
                        e.target.parent.removeChild(DisplayObject(e.target));
                    else {
                        //play BOOP sound indicated wrong drop;
                if (PuzzleGlobals.statesCompletedUSA == PuzzleGlobals.TOTAL_NUMBER_USA) {
                    //play fireworks game
                else {
                    //do nothing
                e.target.removeEventListener(TouchEvent.TOUCH_END, geoPieceEnd);
            public function interactionBegin () {
                 if (this.dropTarget != null && this.dropTarget.parent is  GeoPuzzle) { //check to make sure it's over a puzzle piece
                    currentObjOver = GeoPuzzle(this.dropTarget.parent);
                    currentObjOver.gotoAndStop("Over");
                if (lastObjOver != currentObjOver) {
                    if (lastObjOver.isLocked == true) {
                        lastObjOver.gotoAndStop("Lock");
                    else {
                        lastObjOver.gotoAndStop("Out");
                    lastObjOver = currentObjOver;
    This is the code in the class for each piece that's already on the stage:
            public function GeoPuzzle(): void {
                if (this.isLocked == true) {
                    this.gotoAndStop ("Lock");
                if (PuzzleGlobals.pieceActive == true) {
                    this.addEventListener(TouchEvent.TOUCH_BEGIN, geoPuzzleBegin);
            public function geoPuzzleBegin (e:TouchEvent): void {
                e.target.addEventListener(TouchEvent.TOUCH_END, geoPuzzleEnd);
                e.target.gotoAndStop("Over");
                MovieClip(this.parent).nameDisplay.gotoAndStop(e.target.abbrev);
            public function geoPuzzleEnd (e:TouchEvent): void {
                if (e.target.isLocked == false) {
                    e.target.gotoAndStop("Off");
                else if (e.target.isLocked == true) {
                    e.target.gotoAndStop("Lock");
                MovieClip(this.parent).nameDisplay.gotoAndStop(PuzzleGlobals.chosenPu zzle);
                e.target.removeEventListener(TouchEvent.TOUCH_END, geoPuzzleEnd);
    You  can see that each piece (whether it's already locked on the stage or  movable) reacts differently to different touch events. However, this is  the code that Adobe gave me as a workaround:
    this.stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchEvent);
    this.stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchEvent);
    this.stage.addEventListener(TouchEvent.TOUCH_END, onTouchEvent);
    var beginCount:uint=0;
    var moveCount:uint=0;
    var endCount:uint=0;
    function onTouchEvent(event:TouchEvent):void{
         switch (event.type){
              case TouchEvent.TOUCH_BEGIN:
               &nbs p;           &n bsp; trace("BEGIN")
               &nbs p;           &n bsp; beginCount++;
               &nbs p;           &n bsp; square.x = event.stageX;
               &nbs p;           &n bsp; square.y = event.stageY;
               &nbs p;           &n bsp; square.startTouchDrag(event.touchPointID, false);
               &nbs p;           &n bsp; break;
              case TouchEvent.TOUCH_MOVE:
               &nbs p;           &n bsp; trace("MOVE")
               &nbs p;           &n bsp; moveCount++;
               &nbs p;           &n bsp; break;
              case TouchEvent.TOUCH_END:
               &nbs p;           &n bsp; trace("END")
               &nbs p;           &n bsp; endCount++;
               &nbs p;           &n bsp; square.stopTouchDrag(event.touchPointID);
               &nbs p;           &n bsp; break;
         trace("begin: "+beginCount+" move: "+moveCount+" end: "+endCount);
    //     countText.text = "begin: "+beginCount+" move: "+moveCount+" end: "+endCount;
    This  doesn't make any sense to me because it seems that it would only work  if touching the stage had to react in just a single way. I have multiple  pieces that need to each react differently.
    1. The pieces that are locked to the stage need to highlight when touched and display their name.
    2.  These pieces also need to keep themselves highlighted and their names  displayed when the touch is dragged off of them instead of just removed.
    3.  Each piece needs to be created when touching the Puzzle Piece button  the stage. As these pieces are dragged, they need to highlight the  pieces underneath them and unhighlight them when they are dragged off.  They also need to display their own names, and lock into place when they  are dragged over the correct piece.
    My questions are:
    1. Why don't touch events work in the compiler?
    2. How can I translate my current working code's touch events to all be directly linked to the stage instead of their objects?
    Thanks so much!
    Amber

    Sure!
    I haven't changed much. I've been playing around and I think I know where the problem is coming from now. I just can't figure out how to fix it.
    This it the only code I've modified:
            public function interactionBegin () {
                trace ("Current: " + currentObjOver);
                trace ("Last: " + lastObjOver);
                if (this.dropTarget != null && this.dropTarget.parent is GeoPuzzle) { //check to make sure it's over a puzzle piece
                    currentObjOver = GeoPuzzle(this.dropTarget.parent); //make "currentObjOver" assigned to the puzzle piece the finger is currently touching
                    currentObjOver.gotoAndStop("Over"); //highlight the current piece
                    if (currentObjOver != lastObjOver) { //if your finger moves and you're now touching a different state
                        if (lastObjOver != null && lastObjOver.isLocked == true) { //if the previous state you were touching has been solved
                            lastObjOver.gotoAndStop("Lock"); //lock this state into place
                        else if (lastObjOver != null && lastObjOver.isLocked == false) { //if the previous state you were touching wasn't solved
                            lastObjOver.gotoAndStop("Off"); //unhighlight that state
                        lastObjOver = currentObjOver; //assign the current state to be the last state you were touching
    lastObjOver and currentObjOver are always assigned the same object. I can't figure out why, I've run it line by line but I can't figure out where I'm going wrong.

  • Custom UIView not receiving touch events for fast mouse clicks in simulator

    I'm having a problem in the simulator where if I click fast in a UIView inside a table cell that is setup to receive touch events, it doesn't receive them. But if I click slow (holding down the button for a little bit) the view gets the touch events. I can't test it on the device. Is this a known problem in the simulator?
    Thanks.

    Hi George,
    Thanks a lot for your quick response and jumping to help.
    I am so frustrated that I did not get touch event for the custom cell.
    I also tried your solution for a custom UIImageView, I put the codes of PhotoView.h, PhotoView.m and TestTouchAppDelegate.m here: Please help to look into it for me.
    // PhotoView.h
    // Molinker
    // Created by Victor on 6/18/08.
    // Copyright 2008 _MyCompanyName_. All rights reserved.
    #import <UIKit/UIKit.h>
    @interface PhotoView : UIImageView {
    CGPoint touchPoint1;
    CGPoint touchPoint2;
    @property (nonatomic) CGPoint touchPoint1;
    @property (nonatomic) CGPoint touchPoint2;
    @end
    // PhotoView.m
    // Molinker
    // Created by Victor on 6/18/08.
    // Copyright 2008 _MyCompanyName_. All rights reserved.
    #import "PhotoView.h"
    @implementation PhotoView
    @synthesize touchPoint1;
    @synthesize touchPoint2;
    - (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
    // Initialization code
    self.userInteractionEnabled = YES;
    return self;
    - (void)drawRect:(CGRect)rect {
    // Drawing code
    // Handles the start of a touch
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    UITouch *touch = [touches anyObject];
    touchPoint1 = [touch locationInView:self];
    // Handles the end of a touch event.
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    UITouch *touch = [touches anyObject];
    touchPoint2 = [touch locationInView:self];
    if(touchPoint1.x>touchPoint2.x)
    //move Left
    NSLog(@"Move Left");
    if(touchPoint1.x<touchPoint2.x)
    //move Right
    NSLog(@"Move Right");
    - (void)dealloc {
    [super dealloc];
    @end
    // TestTouchAppDelegate.m
    // TestTouch
    // Created by Victor on 6/17/08.
    // Copyright _MyCompanyName_ 2008. All rights reserved.
    #import "TestTouchAppDelegate.h"
    #import "RootViewController.h"
    #import "PhotoView.h"
    @implementation TestTouchAppDelegate
    @synthesize window;
    @synthesize navigationController;
    - (id)init {
    if (self = [super init]) {
    return self;
    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Configure and show the window
    //[window addSubview:[navigationController view]];
    UIImage *myImage= [UIImage imageNamed: @"scene1.jpg"];
    CGRect frame = CGRectMake (0, 20, 300, 400);
    PhotoView *myImageView1 = [[UIImageView alloc ] initWithFrame:frame];
    myImageView1.userInteractionEnabled = YES;
    myImageView1.image = myImage;
    [window addSubview:myImageView1];
    [window makeKeyAndVisible];
    - (void)applicationWillTerminate:(UIApplication *)application {
    // Save data if appropriate
    - (void)dealloc {
    [navigationController release];
    [window release];
    [super dealloc];
    @end
    Message was edited by: Victor Zhang

  • Touch events don't work on an actual device?

    I'm posting here because I'm not sure where else to put it.
    I have a (semi) functioning prototype of an app and am trying to test it on an iPad.
    But when I export and install the ipa on my iPad through iTunes and Launch, most of the functionality is gone. In fact, all that happens is my buttons light up. Nothing does anything else.
    I'm (hoping) I'm just missing something simple like a publish setting wrong.
    Player: AIR for iOS
    Script: Actionscript 3.0
    Included .swf, .xml, and all relevant .as class files
    Published using quick publish for device testing
    And that's it. I opened the .ipa in iTunes and synced. And nothing works.
    What am I doing wrong?

    I am going to copy and paste this answer into all of the forums I've asked this question in case some noob like me comes along and needs the answer.
    I found the problem! After 3 months I finally figured out what was wrong and why my app was working in Device Central when exported as Flash 10.1 and not on my iPad when exported as AIR for iOS.
    The problem is that in the Flash runtime, if a line of code returns a bug, the flash runtime says "Error, shmerror, try again next time." So I had one if, else statement that was executing when it wasn't supposed to be - only once, at the very beginning of the program. It was throwing an error. When I exported as Flash, flash didn't care, and still executed the code later when it was supposed to. But Apple won't let their programs crash. So instead of just trying that code again, Apple decided, after the first error was thrown, that it would then COMPLETELY IGNORE that line of code. So the error was in the line where the states would unhighlight themselves. Apple just shut down that line of code, that's why it wouldn't execute properly.
    I ended up changing this line of code
    if (lastObjOver != null && lastObjOver.isLocked == true)
    which threw an error when the piece was FIRST dragged over the puzzle, to to this
    if (lastObjOver.parent != null && lastObjOver.isLocked == true)
    which wouldn't throw the error.
    Problem solved!
    If anyone else is having this problem, I suggest you do what I did. Change all your touch events to mouse events so you can run the program in the adc debugger. That's when I discovered the error being thrown.

  • Hello I have a problem with my ipod touch 1G the problem is that see me key to the floor! And when recogi not prendia after 5 minutes prendio but it gave to me the surprise of which the battery had finished completely! What I did was to set it to load wit

    Hello I have a problem with my ipod touch 1G the problem is that see me key to the floor! And when recogi not prendia after 5 minutes prendio but it gave to me the surprise of which the battery had finished completely! What I did was to set it to load with the USB but do not load the battery me the icon of the battery appear and below of her the beam that indicates that this being loaded but this way I have left it the whole yesterday and what goes of today and continues without loading anything! They can help me porfavor I am grateful for them to him very much!   And my PC does not detect it not itunes

    Try the not-charging topic of:
    iPod touch: Hardware troubleshooting
    It could be that the battery is dead.

  • Test touch events in SWF file?

    I'm sure this is one of those "Oh, press this button in Preferences" type of questions, but I have googled to no avail which makes me think I'm either missing something so simple no one has even bothered saying it or I'm asking the wrong question.
    I am trying to write a simple program, just to practice, that will use touch events for an iPad. I don't have a developer account and so am testing the app on my computer. However, it does nothing. Clicking the mouse on the movie clip does nothing. I even copy and pasted someone else's code so that I was sure it wasn't because I got my syntax wrong. Nothing. Is there a way to test touch events on a computer, or do I have to compile the app and send it to an iPad everytime I want to test the app? Is there no AIR simulator that will simulate touch events using a mouse, as there is with XCode?
    Thanks
    Amber

    http://www.republicofcode.com/
    Check for the latest tutorials on the right hand side for touch events

  • I'm running iTunes 10.5 on my Macbook Pro and software 4.1 on my 2g iPod touch and having problems getting photo's to sync. Same error iPod can't be synced req'd file can't be found. Tried deleting the photo cache, restoring the iPod etc but to no avail.

    I'm running iTunes 10.5 on my Macbook Pro and software 4.1 on my 2g iPod touch and having problems getting photo's to sync. Same error, "iPod can't be synced req'd file can't be found". Tried deleting the photo cache, restoring the iPod etc but to no avail.

    Try here:
    iTunes: Unable to sync photos
    Usually deleting the iPod Photo Cache Folder works. Note that if you sync via the folder method, make sure you dlete all the ifolders since :
    The iPod Photo Cache stores the photos that are optimized for display on your iPod, iPad, or iPhone. The location of this folder depends on the syncing options you select. In iTunes, if you change the selection in the “Sync Photos From” pop-up menu, a new iPod Photo Cache folder will be created (and the previous folder will remain).

  • What is Event queue problem?

    HI,
    I have come across JSF document, they mentioned that Event queue
    Problem ins SUN's JSF implementation. what is that?

    You're going to have to be a little more specific.

Maybe you are looking for

  • Divx and other media related plugins always crash and/or no longer work, please help

    Why is nothing of divx seems to work anymore? Every time i try to watch a video online using a divx site or site that uses a divx player, i get the message "divx plus web player pluging has cashed, send crash report" I send it - then am offered the o

  • Possible to place a signature in Acrobat Pro DC?

    In previous versions of Acrobat, I could easily add my signature to a PDF that a colleague had already signed.  This was useful (required actually) for documents that needed multiple levels of sign-off. It seems as though this is no longer possible i

  • Edit keywords whilst in full screen edit mode

    Hi all I want to edit the keywords assigned to an image in full screen edit mode. I have searched about a bit and have found links to Keyword Assistant which is all well and nice. It's not particularly quick to asign keywords though - my touch typing

  • Creating standby or logical standby database manually?

    Hi, I have to create 4 logical standby databases on a Linux Red Hat 64-bits server. The primary databases reside on another Linux Red Hat 64-bits server. The oracle database version is 10.2.0.3. The question is as follows: Should I create the logical

  • Creating a moasic-batch processing question?

    I 'volunteered' help to do a project for my daughter. For an elementary school fundraiser, she wants to create four moasics -- 11X17 images -- one for each of four classes, with an 'Egyptian' theme -- at least one of the images being of the pyramids