Author Topic: Not working on touchscreen  (Read 1332 times)

Kotch

  • Jr. Member
  • **
  • Posts: 30
Not working on touchscreen
« on: January 15, 2012, 06:47:37 pm »
As mentioned in other posts, I couldnt get the Megazine zoom to work just as I wanted so I am not just using the loading in Megazine swf for the page flipping and I am doing the zoom myself (by scaling the scalex and scaley of the megazine swf instance).

This has worked fine on my laptop and a couple of other macs but when I run on our touchscreen I get a serious problem. 

I load the megazine swf into a container movieclip.  I attach an event listener for the MouseEvent.CLICK event on the container movieclip and when the user clicks I only activate the zoom when the target is of type 'LoaderExt' as follows:

Code: [Select]
private function checkForZoom ( _target:Object ) : void
{
// Set zoom transform point to the current position of the mouse
var doZoom:Boolean = false;
var originX : Number;
var originY : Number;

// Do zoom if we are clicking anywhere in the page, except the edges
if ( _target.toString() == "[object Sprite]" ) {
if ( Sprite(_target).parent.toString() == "[object Area]") {
doZoom = true;
}
}

if ( _target.toString() == "[object LoaderExt]") {
doZoom = true;
}

// [object LoaderExt] is the Megazine content
if ( doZoom ) {
originX = view.mouseX + MEGAZINE_X;
originY = view.mouseY + MEGAZINE_Y;

// Swap zoom mode
if ( zoomMode == ZOOM_MODE_OUT ) {
zoomInOnPoint(originX, originY);
} else {
zoomOut();
}

}
}

Basically it works when I am doing a click with the mouse but NOT when I do a 'click' with my finger on the touchscreen.  The zoom is not activated most of the time, only very very occasionally.  I am guessing its something to do with the fact the cursor moves slightly when you are 'clicking' with your finger but that with a mouse click you only click on one point.

Please please can you help me with this soon.   Maybe I can email you personally? I have a deadline which is looming very close and I am going nuts trying to work out all these various Megazine issues.

I am using version 2.0.10 by the way but I will be upgrading to the latest release in the hope that this may fix the problems I am having with Megazine.

Thanks

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Not working on touchscreen
« Reply #1 on: January 26, 2012, 12:23:09 am »
Not really sure if this relates, but from fiddling with TUIO I realized that the mouseX and mouseY properties are not always quite as up-to-date as one would like. If at all possible, use those from a mouse event.
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

Kotch

  • Jr. Member
  • **
  • Posts: 30
Re: Not working on touchscreen
« Reply #2 on: January 28, 2012, 12:13:26 am »
Hi Florian

Please can you elaborate on this.  This may help me solve the current issue I'm having with Megazine in my application which I am running on touchscreen.

If I move my finger onto the bottom left corner of page 2 of a book the 'turn' cursor appears and stays on this corner.  If I then lift my finger and place it on the bottom right corner of page 3 (with the intention of turning to page 4) a 'turn' cursor now appears in this location.  However, the custom megazine 'turn' cursor also stays on the corner of page 2 which is odd as I now have two cursors displayed (I would expect the page 2 cursor to disappear and just the page 3 cursor be active). Then when I click or drag on the bottom right corner of page 3, I am not taken to page 4 but its as if the cursor on page 2 has triggered and instead I am taken to page 1.

Have you any idea what is happening here?  I'd really appreciate some pointers as its making the application look rather unstable.  Is this related to the mouseX and mouseY properties you were referring to?  I thought maybe there is a queue of active cursors and when a click event occurs it looks at the cursor at the head of the queue, in this case the one on page 2 (which should have actually been cleared by this point) and assumes the click has happened at this cursor location.

Will using the TUIO plugin miraculously solve these issues?

As you can see, I need some help!  I look forward to your reply - I'm glad you are back replying to posts, Florian ;)

BTW, I managed to workaround my previous problem by listening for the mouse 'down' rather than mouse 'click' event  on the loaded in Megazine swf.  The mouse 'click' event and the mouse 'up' event doesn't always seem to be triggered on a touchscreen.

Thanks


Kotch

  • Jr. Member
  • **
  • Posts: 30
Re: Not working on touchscreen
« Reply #3 on: January 30, 2012, 11:26:23 am »
I've tried to recreate the problem at home as follows:

-Using a Wacom tablet, set to 'force proportions' mode so it acts like a touchscreen
-also attaching a mouse to my laptop.
I can position the mouse on the bottom corner of the left page and then use the wacom pen to select the bottom corner of the right page.  In this case, it works as it should - the pen action takes priority and the the cursor on the left page corner disappears leaving only one cursor for the pen.

Hmm, now why isn't this happening on the touchscreen?....

touchrev

  • Newbie
  • *
  • Posts: 2
Re: Not working on touchscreen
« Reply #4 on: January 31, 2012, 04:10:51 am »
I've tried to recreate the problem at home as follows:

-Using a Wacom tablet, set to 'force proportions' mode so it acts like a touchscreen
-also attaching a mouse to my laptop.
I can position the mouse on the bottom corner of the left page and then use the wacom pen to select the bottom corner of the right page.  In this case, it works as it should - the pen action takes priority and the the cursor on the left page corner disappears leaving only one cursor for the pen.

Hmm, now why isn't this happening on the touchscreen?....

What OS platform are you running?  (I am positive that this is specifically windows 7 related and I have not had this issue on other platforms or with TUIO).
- The Wacom tablet you are using to test has its own HID driver and the touchscreen almost always uses the windows 7 native multi-touch driver, so, it will not function the same as a touchscreen.

Try this:
1)  "position the mouse on the bottom corner of the left page"
2)  then randomly touch and *drag your finger quickly on the screen somewhere to update the cursor so the cursor is no longer in the btm-left corner
     - to test my hypothesis that the issue occurs primarily on a draggable corner after a page turn has been fired by a click (not by dragging the page) and the cursor has remained over the corner.
3)  then try to "select the bottom corner of the right page" with the touchscreen by touching and *dragging the page with your finger

-  In the above control test, does the cursor update to the bottom corner of the right page as it should and start dragging the page? 
If so, then Florian is correct and the mouseX/Y properties are not up-to-date. 
Furthermore, a potential factor can be narrowed down to a cursor remaining on or near the position of a corner after a previously triggered page turn was fired with a click and not page drag (?)..

Correct me if I am wrong -- if the lastMouseEvent X/Y position has not been updated by a page drag, a TOUCH_DOWN/UP event (from a new location) can still target the lastMouseEvent X/Y location (?).
Florian - What are your thoughts on this?

Kotch - I am not sure how complicated this will be for you or if your touch controller supports tuio data, but, I believe it will solve your issue in the meantime if you find what you need to get it working.
- In order to use TUIO touch data instead of the windows 7 native touch driver you will need to do the following:
1)  Locate & download a TUIO driver or bridge that is compatible with your touchscreen (google: make and model of your touchscreen + tuio driver, bridge etc.)
2)  download this: Flash UDP->LC tuio/osc bridge ( http://gkaindl.com/software/udp-flashlc-bridge )
3)  Optionally, unless you are running a WM_TOUCH tuio bridge found in step 1, you might need to disable touch/multitouch in the "Pen and Touch" & "Tablet" settings in the control panel.
4)  enable the TUIO plugin and set the tuio parameters in your .mz3 <book> configuration
   <book
   plugins="tuio"
   tuioconnector="lc"
   tuiolcnamein="_OscDataStream"
   tuiolcnameout="_OscDataStreamOut"
   tuiotcphost="127.0.0.1"
   tuiotcpport="3333"
   >

Kotch

  • Jr. Member
  • **
  • Posts: 30
Re: Not working on touchscreen
« Reply #5 on: January 31, 2012, 05:57:43 pm »
Hello

Thank you so much for your post.  Its great to get some input on this matter.

I do the Control test you suggest and it does just what you expect - the cursors update to the bottom corner of the right page as it should and start dragging the page.

I would add that the issue doesn't necessarily happen after a page turn has been fired by a click.  The cursor just has to remain over the corner.

It would be great to get clarification on this matter:
"if the lastMouseEvent X/Y position has not been updated by a page drag, a TOUCH_DOWN/UP event (from a new location) can still target the lastMouseEvent X/Y location (?)."

Florian, which class should I be looking at to change?  DragHandler.as.

TouchRev, I'm not sure we can go down the Tuio route at present.

Cheers

Kotch

  • Jr. Member
  • **
  • Posts: 30
Re: Not working on touchscreen
« Reply #6 on: January 31, 2012, 06:16:04 pm »
Well, I have had a bit of result.  I've managed to get rid of this problem by reverting back to Megazine version 2.0.8.

I noticed that this problem didn't happen on a project we did a couple of years ago and so when I hook into this Megazine library I do not have this issue.  This version of the source files was hacked into quite a bit (by someone else) so it's possible that something they did rectified this issue.

Florian, can you see why this issue wouldn't happen in version 2.0.8?


Kotch

  • Jr. Member
  • **
  • Posts: 30
Re: Not working on touchscreen
« Reply #7 on: February 01, 2012, 11:48:24 am »
So, now I'm using version 2.0.8, which is bringing its attendant issues... ;)

There appears to be a problem with the overlays and how I've coded interaction with them for version 2.1.1.   

Can you throw any light on this?

This is the relevant code as far as I'm aware.

Code: [Select]

                // Look at the Area overlays specified in the mz3 file and set up accordingly
private function initPageHitAreas () : void
{

  // Go through each Page side
var pageCount:uint = megazine.pageCount;

for (var i:Number=0; i<pageCount-1; i++ ) {
var pageSide:IPageSide = megazine.getPageSide( i);

// Go through each Element in each Page side
for each (var proxy:IElementProxy in pageSide.elementProxies) {
           
if ( proxy.type == "area" ) {
// If the element is an 'area'
// Add listener so we know when its loaded
// Once loaded, add a MouseEvent.CLICK listener to it
proxy.addEventListener( Event.COMPLETE, onPageHitAreaLoaded);
}

            }

}
}



// When page hit area has loaded in add a Mouse.click handler to it
private function onPageHitAreaLoaded ( e:Event ) : void
{
var proxy:IElementProxy = e.target as IElementProxy;
stylePageHitArea ( proxy );
buildBoundClickHandler( proxy );
}




// Attach a MouseEvent.CLICK eventlistener to the hit area
// Store hitArea data on click, and dispatch event so infoPanel can be update
private function buildBoundClickHandler(proxy:IElementProxy):void
{

// Attach event listener for mouse click
proxy.element.interactiveObject.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void {

// Record which Area has been clicked on
clickedHitAreaPage = proxy.getAttribute("hitAreaPage") ;
clickedHitAreaID = proxy.getAttribute("hitAreaID") ;

// Dispatch event
dispatchEvent ( new PaperLargeEvent ( PaperLargeEvent.HIT_AREA_CLICK, clickedHitAreaPage, clickedHitAreaID ));

});

}

Thanks

Kotch

  • Jr. Member
  • **
  • Posts: 30
Re: Not working on touchscreen
« Reply #8 on: February 01, 2012, 11:50:03 am »
Though obviously it'd be much nicer to have a fix for the original issue...