ActionScript 3.0 :: Differentiate Between A Click And A Drag?
Jun 2, 2010
I have created the attached FLA file as a horizontal draggable menu in AS3.At the moment i am having a couple of issues with it.
1) I am using MouseEvent.MOUSE_DOWN and MouseEvent.MOUSE_UP eventlisteners to control the dragging.
The problem is that I click down the mouse button on the movieclip, it will start dragging. All good. However if I then, after dragging it about, let go of the button it registers a click. Obviously i don't want it to do that, I understand that it is registering a click because a click effectively consists of a MOUSE_DOWN and MOUSE_UP. Is it something i am doing wrong with the dragging? I am not sure how to differentiate between a click and a drag?
2) I would quite like the stopDrag to have an easeout on it, instead of stopping dead. (Take a look at newcruelty.com for the effect i am after) is this possible, perhaps using Tweenlite or Tweenmax? I have attached the CS4 FLA file (it uses tweenlite)
View 7 Replies
Similar Posts:
Nov 13, 2010
I want to have an image and when I click on the image ,one can hold down the mouse and drag a copy to where ever on the stage and when one lets go, one can drag another and another with each copy still being able to be dragged after released.this is what i have but its pretty simple and doesn't work....
stage.addEventListener(MouseEvent.MOUSE_DOWN,makeA Box);
var i:Number = 1; //i will be the total number of boxes
var newBox:myMC = new myMC();[code]....
View 3 Replies
Jul 20, 2009
I have some code that does what I need it to do, but I need a way to differentiate between the mc's it creates.Here is the code:
_________________________________________________
TL = this;
str1 = ["strandA","strandT","strandC","strandG"];[code]....
It generates mc's randomly.So for instance, there might be 3 "strandT" mc's on the stage at the same time.How could I tell them apart? If, for example,I wanted to say, make the first "strandT" disappear, but not the second and third.
View 2 Replies
Apr 24, 2009
I have a main swf file (basically, a movie player), which, for the most part, just loads swf files into a container object and plays them.The nested clips are typically just straight movies that start at frame one and just play to the end, then another clip is loaded.However, some of the nested clips are interactive (games and such) that have alot of actionscript (2.0) within them.Now the problem is that, within the nested clips, _root objects are referenced, however, when the clips are loaded into the main swf container, the _root references the _root of the container, rather than the _root of the nested clip.I figured out that I can replace the _root references with something like _root.container.xxxx, but when I do that the nested clips don't work as a stand-alone (which isn't really necessary, but is easier to test without having to first load into the container swf). So, is there a property I can set that will differentiate between a _root reference within a nested clip as opposed to a _root reference in the container clip?
View 3 Replies
Jun 24, 2009
String.search function thinks that dot and comma (. and ,) is the same thing. Is there a way to fix this? I want to find comma and it gives me a dot.
View 2 Replies
Mar 8, 2011
I'm trying to differentiate anonymous functions like:
function() { trace("WOO"); }
from the other ones ('named'?) like
var _FUNC:Dynamic = function() { trace("WOO"); }
The reason I want to do that is because I can't compare between two anonymous functions, because they are two different ones.
var _TEST:Dynamic = function(a:Dynamic):String {
var _TESTA:Dynamic = function() { trace("WOO"); };
var _TESTB:Dynamic = _FUNC;
return (a == _TESTA) + ", " + (a == _TESTB);
}
If I run _TEST(_FUNC);, I'll get back "false, true". Even though they are the same function, they are NOT the same object.Is there a way to compare those such that functions that they are the same if they perform the same task? Is there a way to serialize functions? So that maybe I can compare the serialized representations and see if they share the same 'code'.
View 1 Replies
Apr 7, 2010
am hoping someone here might have some source in the little bag o' trix that will put me on the right road to achieving the following. i am trying to work out the best way of creating a movie that has buttons that when clicked will zoom into and centre a certain area of a larger movieclip?
and then a way of dragging the zoomed into movieclip around the stage area? or panning using x/y positions of the mouse. (and without asking for the moon on a stick - if the user clicks on a empty part of the zoomed mc - it zooms back out to it's original size position?)
any have any fla files or know of any good tut's or threads that can will give me a leg up to get it working? fingers crossed has done this before or know a good place to start?
View 2 Replies
Oct 18, 2010
How do I differentiate between a data provider update and a itemrender being recycled when using a custom itemrenderer in a DataGroup?I have overridden the set data function of the custom item renderer, but I have found that on making a change to the ArrayCollection used as the DataProvider some of the item renderers are not assigned the same object they had before the update. This has made it almost impossible for me to distinguish between a data update and an itemrender being recycled. Also, the data never seems to get set to a value = null, so that seems to be out as well.
View 2 Replies
Oct 7, 2010
I'd love to know how to make click and drag two different things. As it believes the drag function is also a click. Also I'd love to know how to set it so that ALL movieclips stop when they reach say -10px from each side?
View 2 Replies
Aug 24, 2009
I have a movieClip on stage.I wanted to make it so that you can click on stage and drag and if you drag up and right value increases and if you drag down and right value decreases.So that I can resize the movieclip (scaleX & scaleY) based on that dragging.
View 2 Replies
Feb 11, 2011
I have the following code, which works beautifully when all the boxes are the same height. The basic point is that I have three boxes on the stage, 10 pixels apart. If you click and drag those boxes above or below each other, they reorganize themselves. Code: Select all// based off Dynamic Stacking AS3 @ [URL]
[Code]....
View 1 Replies
Apr 1, 2006
I have an object that I drag on the page. The same object I would like to double click to play sound file and load movie.
View 1 Replies
Jun 16, 2009
How can I set different actions for click and drag or just click? For example I have a map with clickable objects. When clicked on object some action happens, but when a user clicks and drags the panning starts not the click action of object.
View 7 Replies
Nov 11, 2009
I built one of those click-and-drag rotating images. basically you click on it and drag left to right and it will scroll through a series of images in the timeline to make it appear like the object in the images is rotating he problem is I want to be able to click-and-drag the mouse up-and-down, AND left-and-right. Right now I can program it to do one or the other, but not both. if i put left,right,up,AND down in the code it ignores one or the other.
Code:
photos.stop();
var startX:Number;
[code]........
View 8 Replies
Apr 6, 2010
Basically using nothing but code I want to be able to hold down my mouse button and when I move my mouse a rectangle of any proportion based on from where the mouse left off is madeI can stretch this out to anywhere on screen till my finger is lifted off the mouse button.nce my finger is off the rect stays there till I create another and the previous rect disappears.I know how to creat a rect normally in AS3 but this has just stumped me
View 6 Replies
Apr 8, 2010
This script works good as it is. I need to switch it from rolling over the image to a click and drag.
I need to make it act like this link. [URL] as opposed to mine. [URL]
Code:
var maxSpeed:uint=50;
function startScroll(event:Event):void {
event.currentTarget.addEventListener(Event.ENTER_FRAME, doScroll);
[Code].....
View 1 Replies
Jun 14, 2009
make a script for a draggable button? I just need a button (..onPress) that will wont work if you start dragging it
View 3 Replies
Aug 16, 2010
After I drag and drop a label(or other UIComponent) in a container, i want to double click the label to show me an alert. well it doesn't work.
i've tried in the dragCompleteHandler to put event.dragIntiator.addEventListener or event.currentTargetaddEventListner but it doesn't work. Also i enabled the DoubleClickEnabler and still nothing?
View 1 Replies
Feb 5, 2009
I found code that enables my movie clip to have click and drag rotation.Not sure how this works exactly, but it does. Now I've placed buttons that show details when moused over, and I had to repeat them for every keyframe of the movie clip to have them follow the rotation of the images in the movie clip.My question is how do I now enable these detail buttons to be hidden and shown globally?I have enabled a hide/show button to change the visibility of one of the detail buttons as a test (on the tire of the race car), but what happens is the hide state gets lost as soon as you click and drag to a new keyframe and the button shows up again without having pressed the "show" button. What do I need to have the detail buttons stay hidden throughout the clip until the "show" button is pressed?Here's the swf for reference: http:[url].......And here's the current actionscript:
ActionScript Code:
cars.stop();
var startX:Number;[code]......
View 0 Replies
Nov 5, 2009
Basically what I am trying to do is have my movie clip rotate/pivot when I press on it, same as the arm on the record player of this [URL]. At the moment, the movie clip rotates according to mouse follow, but I would like to click, drag and rotate so it pivots from one point.
Code:
const TO_DEGREE:Number = 180/Math.PI;
addEventListener(Event.ENTER_FRAME, rotateObject);
var maxRotSpeed:Number = 5;
var rotScale:Number = 0.2;
function rotateObject(e:Event):void {
[Code] .....
View 0 Replies
May 4, 2010
tutorial about how to make a menu such as the one that can be seen at
View 0 Replies
Jul 29, 2010
i've been trying to make a script for dragging, exept that the object will automatically follow the cursor upon clicking, and will stop following cursor upon clicking again. i've used a variable called lol141 to keep track of how many times the person has clicked. after the first click(startdraggin), my first eventlistener does not get removed and thus when i click, the output shows an increased number.
[Code]...
View 1 Replies
Mar 11, 2011
I have to make a timer that starts off set at one minute and plays an animation mapped to the time remaining in the timer. I need it to start and stop on a button press, and once it has gone through the minute, I need to be able to add time to it and start it again (with the animation mapped to the new amount of time) by clicking and dragging (or maybe with a slider). I have the basic functions down, but I can't figure out how to get it to start over with the time added by dragging. Here is my code so far:
[Code]....
View 2 Replies
Mar 5, 2012
Why this isn't working? I get no errors but it just doesn't do what I'm telling it. I just want it to gotoAndStop on the frame I want but it isn't.
View 9 Replies
Sep 29, 2007
I load an image onto the stage and attempt to write this code to allow the user to click and drag the image, but it doesn't do anything!
[Code]...
View 2 Replies
Feb 17, 2009
I have unit A: on a mouseEvent: MouseUp and MouseDown event. I'm going click and dragging objects.
Unit A when I pick it up says I have picked up Unit A. I drop it in a location and it stays. GOOD
I pick up Unit B and it says I picked up Unit B. I drop it on top of Unit A and it says I have dropped Unit A. NOT GOOD.
I only want to drop unit B, not A. So I looked at the events:
Target: The InteractiveObject instance under the pointing device. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.
So I use currentTarget instead:
currentTarget: The object that is actively processing the Event object with an event listener. Except they both return the same. Both will register Unit A, even though I am holding Unit A.
View 1 Replies
Jun 18, 2009
My problem is i want the background of the map (i.e. the picture of the theme park) and the buttons which make the script interactive to move at the same time when the user naviagtes aorund the map; similar to thisthis is the script i am using to make the map interactive. It is located in a layer Action script.:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var cities:Array = ["muscat", "sohar", "dubai","abu_dhabi"]
[code].....
View 2 Replies
Jun 20, 2010
I am having this problem where i have a movieclip and i want it to be able to be dragged, and clicked. two separate events. But the problem is when i startdrag the MC, then when I stopdrag it, the click event gets called up. here is the code:
outa.box.addEventListener(MouseEvent.CLICK, that);
outa.box.addEventListener(MouseEvent.MOUSE_DOWN, that2);
outa.box.addEventListener(MouseEvent.MOUSE_UP, that3);
[Code]....
View 3 Replies
Oct 3, 2011
so far I have the 4 colours and 4 boxes you can drag them to, when you drop out side they reset but when dropped on a box they stack.what i would like to do, is when theyre dropped onto a box the original box is then reset, replacing it with the new box, the old colour is then returned to its original locationUpdate: I could get them to go back when dropped on, but now i cant get the boxes to snap back into place when not on a box :s
View 1 Replies
Jun 11, 2009
For a Majour project school assignment i am trying to create an interactive map for a hypothetical theme park, and i'll cut to the chase, i need a script that allows the player to drag the content of two or three layers around the screen upon mouse click, similar to this example:
[URL]
I will have a layer for buttons (probably called Buttons) and a layer for the map graphic (Probably called Map), similar to this tutorial:
[URL]
If anyone could produce, or has a script lying around that could do this; i would really apreciate it.This assignment has a large impact on my UAI (universities admission index).
View 9 Replies