I'm really new to using Action Script in general and could use a good explanation on how to do this as well as how it works.
I'm trying to create a stage event in AS3 for Android.
When the user touches the stage and not an object in particular I need to detect if they are dragging and the location of where there finger has dragged to.
I've started like this to detect if they have touched the stage:
stage.addEventListener(TouchEvent.TOUCH_BEGIN, stageTouchBegin);
var stageTouchDragBounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
function stageTouchBegin(event:TouchEvent):void
{
event.target.startTouchDrag(event.touchPointID, false, stageTouchDragBounds:Rectangle);
trace(event.stageX);
trace(event.stageY);
}
This line is where I get the error and I'm assuming that it's because target would typically be referencing a movie symbol or something but in this case it's not because its the stage. I tried replacing target with stage but it didn't work:
event.target.startTouchDrag(event.touchPointID, false, stageTouchDragBounds:Rectangle);
Here is the error: 1061: Call to a possibly undefined method startTouchDrag through a reference with static type flash.events:TouchEvent.
From there my plan was to proceed to use something like this to start recording where they were at:
var curPosX;
var curPosY;
function stageTouchMoveHandler(event:TouchEvent):void
{
trace(event.stageX);
this.curPosX = event.stageX;
trace(event.stageY);
this.curPosY = event.stageY;
}
Then handle the ending as such:
function stageTouchEndHandler(event:TouchEvent):void
{
event.target.stopTouchDrag(event.touchPointID);
}
Any insight/advice on how to do this or an explanation of target, especially example code, would be greatly appreciated. Thank you for your time!