Highlighted

Drag/Drop with Long Press Mobile Event

New Here ,
Feb 27, 2020

Copy link to clipboard

Copied

Hi there,

I'm a complete beginner. I'm looking for some help on what I imagine is a pretty simple piece of code.
I have a drag and drop function, below:
---------
skittles.addEventListener(MouseEvent.MOUSE_DOWN, startDragging01);
function startDragging01(event:MouseEvent):void
{
skittles.startDrag();
}
skittles.addEventListener(MouseEvent.MOUSE_UP, stopDragging01);
function stopDragging01(event:MouseEvent):void
{
skittles.stopDrag();
}
---------

I wish to use this function with the Long Press Mobile Event . The snippet code is as follows:

---------


/* Long Press
Pressing the object for one second executes a function containing your custom code. You can use this action to display a context menu for that object.

Instructions:
1. Add your custom code on a new line after the lines that say "// Start your custom code" below.
*/

var fl_PressTimer_2:Timer = new Timer(1000);
fl_PressTimer_2.addEventListener(TimerEvent.TIMER, fl_PressTimerHandler_2);

function fl_PressTimerHandler_2(event:TimerEvent):void
{
// Start your custom code
// This example code doubles the object's size
skittles.scaleX = 2;
skittles.scaleY = 2;
// End your custom code
}

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

skittles.addEventListener(TouchEvent.TOUCH_BEGIN, fl_PressBeginHandler_2);
skittles.addEventListener(TouchEvent.TOUCH_END, fl_PressEndHandler_2);
skittles.addEventListener(TouchEvent.TOUCH_OUT, fl_PressEndHandler_2);
skittles.addEventListener(TouchEvent.TOUCH_ROLL_OU T, fl_PressEndHandler_2);

function fl_PressBeginHandler_2(event:TouchEvent):void
{
fl_PressTimer_2.start();
}
function fl_PressEndHandler_2(event:TouchEvent):void
{
fl_PressTimer_2.stop();
// Start your custom code
// This example code resets the object to its original size
skittles.scaleX = 1;
skittles.scaleY = 1;
// End your custom code
}
---------
Can I somehow merge the two?  Any help would be much appreciated

TOPICS
ActionScript, Code

Views

86

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Drag/Drop with Long Press Mobile Event

New Here ,
Feb 27, 2020

Copy link to clipboard

Copied

Hi there,

I'm a complete beginner. I'm looking for some help on what I imagine is a pretty simple piece of code.
I have a drag and drop function, below:
---------
skittles.addEventListener(MouseEvent.MOUSE_DOWN, startDragging01);
function startDragging01(event:MouseEvent):void
{
skittles.startDrag();
}
skittles.addEventListener(MouseEvent.MOUSE_UP, stopDragging01);
function stopDragging01(event:MouseEvent):void
{
skittles.stopDrag();
}
---------

I wish to use this function with the Long Press Mobile Event . The snippet code is as follows:

---------


/* Long Press
Pressing the object for one second executes a function containing your custom code. You can use this action to display a context menu for that object.

Instructions:
1. Add your custom code on a new line after the lines that say "// Start your custom code" below.
*/

var fl_PressTimer_2:Timer = new Timer(1000);
fl_PressTimer_2.addEventListener(TimerEvent.TIMER, fl_PressTimerHandler_2);

function fl_PressTimerHandler_2(event:TimerEvent):void
{
// Start your custom code
// This example code doubles the object's size
skittles.scaleX = 2;
skittles.scaleY = 2;
// End your custom code
}

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

skittles.addEventListener(TouchEvent.TOUCH_BEGIN, fl_PressBeginHandler_2);
skittles.addEventListener(TouchEvent.TOUCH_END, fl_PressEndHandler_2);
skittles.addEventListener(TouchEvent.TOUCH_OUT, fl_PressEndHandler_2);
skittles.addEventListener(TouchEvent.TOUCH_ROLL_OU T, fl_PressEndHandler_2);

function fl_PressBeginHandler_2(event:TouchEvent):void
{
fl_PressTimer_2.start();
}
function fl_PressEndHandler_2(event:TouchEvent):void
{
fl_PressTimer_2.stop();
// Start your custom code
// This example code resets the object to its original size
skittles.scaleX = 1;
skittles.scaleY = 1;
// End your custom code
}
---------
Can I somehow merge the two?  Any help would be much appreciated

TOPICS
ActionScript, Code

Views

87

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 27, 2020 0

Have something to add?

Join the conversation