Multi-touch handling in AIR for Android/iOS

To handle multitouch in AIR you need to listen to TouchEvent events like TouchEvent.TOUCH_BEGIN. Which event you will listen depends on the Multitouch.inputMode defined, possile values are enumerated in MultitouchInputMode class. We will use MultitouchInputMode.TOUCH_POINT which specifies that events are dispatched only for basic touch events, such as a single finger tap.

It would be also good to make sure that we have touch enabled device or if we have enough number of touch points recognised, this information can be fetched from Multitouch class.


var m_oTouchIDs:Object;

if(Multitouch.supportsTouchEvents)
{
    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
    m_oTouchIDs = { };
    //we have touch screen
    stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
    stage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);
    stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
}

protected function onTouchMove(e:TouchEvent):void 
{
    //update
    var p:Point = m_oTouchIDs[e.touchPointID] as Point;
    p.x = e.localX;
    p.y = e.localY;
}
		
protected function onTouchEnd(e:TouchEvent):void 
{
    delete m_oTouchIDs[e.touchPointID];//release
}

protected function onTouchBegin(e:TouchEvent):void 
{
    m_oTouchIDs[e.touchPointID] = new Point(e.localX, e.localY);
}


Than you have an object containing position (and it could contain other details if needed) of each touch point which could be later used e.g. in a loop to verify what was “clicked”.

best regards

SQLite – compare null values

Hi,

this is a quick post describing issue I have found when using SQLite in flash. I’ve tried to fetch some rows using following snippet, but couldn’t get correct results. Then after digging on the net I have found that there is a different syntax to compare null values. The problem was in comparing values that sometimes can be null.

The idea was to get how many empty values I have in the database, the result was always 0. I have start with plain text query (no parameters), but it didn’t worked as I’ve found on the SQLite page you can’t just use equal to compare NULL values, you have special syntax IS NULL or IS NOT NULL.

Continue reading

‘unique’ as column name in SQLite table and SQLError

Hi,

I have just learned that “unique” is not a good name for column name when creating table. If you try to use it then you will get following meaningless (at least to me) error:

SQLError: 'Error #3115: SQL Error.', details:'near 'BOOLEAN': syntax error'

So whenever you will have similar error and at first glimpse everything looks fine then check your column IDs.