ActionScript 2.0 :: Make MC Snap To Specific Position Once Dragged?
Jun 2, 2011
I am creating an exercise to teach the meaning of the word "take". I want draggable objects (MC's) which will automatically snap to a different position when they are dragged a little way.
This is the code I am trying (not mine I'm afraid). I have it on the same frame as the MC in "Actions - movie clip". The MC is draggable but doesn't snap.[code]...
I have 2 mc's which can be dragged. When one is dragged I want the other to mirror the position of the dragged one.
say they are mcA and mcB if mcA is dragged, mcB's x should = mcA's x and mcB'sY should = mcA's Y * -1
same for when B is being dragged but reverse obviously
I want this to execute continuously while one of the mc's is being dragged. I tried using while with a boolean, maybe you can't? here is what I tried to simply get one to work, just B to follow A when A is dragged.
PHP Code:
var dragging:Boolean = false; main_mc.mcA.addEventListener(MouseEvent.MOUSE_DOWN, startDraggingAB); main_mc.mcB.addEventListener(MouseEvent.MOUSE_DOWN, startDraggingAB);
I'm trying to code the snap to grid functionality. The dragged object should snap to the grid if the distance between the object bounds and a grid line is less than 5px. I found a way to do it if the object's rotation is 0 but it doesn't work if I rotate the object. I need a different approach. Can you point me into the right direction with the algorythm or any source code?
I want to make a magic 8 ball in actionscript 3. I'd like to be able to click on the movie clip of the 8 ball, shake it with the mouse, and then have it snap back to its original position when I let go of the mouse button. I have three problems:
1) I can make the 8 ball track the mouse, that's easy, but how do I make it snap back to the original position when I let go of the mouse button?
2) I want to constrain the movement of the 8 ball movie clip so it won't go all over the stage, just enough to move it back and forth a bit.
3) How do I randomize output of answers in the 8 ball window...such as, "not now," "doesn't look good," or "yes" etc?
How would you force a mouse follow movieclip to snap to a x y position if it reaches x y boundaries or perhaps if a button is released the movie clip snaps to a x y position? Of course if the mouse returns to x y boundaries I'd like for the movie clip to follow again.
Right now this is the code I'm using to make the movieclip follow the mouse within x y boundaries:
I have movie clips loading in dynamically using an XML file, and the duplicate movie clip function. I need to be able to select one of those movie clips, drag it to a desired position and have it snap to place. As for right now, I'm using :
how to make a draggable map but the map can only be dragged in an area. let say if i did a rectangle as the limit,so the map can only be dragged within the rectangle... outside of the rectangle cant be dragged and cant be seen...
make snap object on the mouse movement. As, I have made the code but getting issue on removing from snapping. I have attached the file. you can look in the [URL]
I'm having trouble figuring out the code to make an object slide or snap.
I.e. imagine a checkerboard. I want it to be able to move only horizontally or vertically, from any square. But I also want to make it feel smooth like sliding (i.e. not just snap from square to square).
I'm new to Flash (sort of - I used it a bit back in 1999-2000, but it's changed a LOT since then). I'm making an educational game for my company that involves dragging labels from a word-bank to their correct position on a diagram. I want the kids to be able to drag any one of the five labels and move them to any one of five marked positions on the diagram. I'm using Flash CS5 with Actionscript 3. I used code snippets, so that each individual label has the following code associated with it:
I am using Flash CS3 with AS2 and I have made a drag and drop. Everything works fine, but I don't know how to make my movie clips snap to their targets.[code]
I wanna make menu buttons to be dragged to navigate, I could drag the menu up and down with the as3 as follow.
but whenever click it to drag again, starting point of the menu move where I click on the board. I want to make the menu start to move from the point the mouse out.
I think this part should be done with something else.
" menu.y = board.mouseY; "
ActionScript Code: var board01:Sprite = new Sprite(); stage.addChild(board); board01.graphics.beginFill(0xCCCCCC,0);
What I want is a hint how to make a specific thing happen while clicking a specific button. Like "if I click button 1, do this". Would like to use this script though I'm gonna add buttons over time and this is an easy way to have the functionality working.
Here's the code:
Attach Code
function hitButton(btn) { btn.onRollOver = function() { this.colorTo (0xC4006A);
I have searched the forum and could not find anything specific, so if you do, please show me the link. Let me set some theoretic environment for the question. let's take a circle that is like an anolog clock but only has 8 numbers; 12 o'clock, somewhere around 1:30, 3 o'clock, 4:30, 6, and so on.
I want to have each number, a button, and when clicked will rotate to the top of the circle.NOTE this is a static image, so the numbers will upside down, etc...the do not need to stay rightside up, as they will rotate with the circle image.
Every time a number is clicked, it will rotate the circle until that number is at the top, and can move either left or right depending on which number is clicked. I thought of doing this in design time, but there are many combinations, and it would be too weighty.
I do not know how to rotate it in actionscript and then have it stop at a certain position, which I assume I could plan out in degrees, and possibly use flags to tell which had been clicked in which position,
I'm doing a flash menu for a site and am stuck with a bit of action script. Below is a link to the swf file. http:[url].........What I am after is for the white bar to follow the mouse when you are over the flash file y axis only (this works on the file), then when you take your mouse away from the file it returns to a specific position.The action I have so far is attached bellow.
I have a textBox and I am using it as a mail address input field where the user can type in several addresses, a bit same as in hotmail. Each address is rendered into a clickable button. Thus upon double-clicking on a specific address I want the item to be editable. After having edited the address when the user taps enter, the item is added to the list of mail adds.I am adding it using the code below:
flowBox.addChildAt( myItem, myindex);
However addChildAt seems to add the item as the last item in the list. But I want it to add the item the position where it was originally. Say the item was at position 2 in the mail list, after editing adn tapping enter, it should add at position 2 itself and not at the end of the list.
I'm working on this scroll from tweener [URL]. I've made a button that lets me reach the position I want on the scroll Code: this.bout.onRelease = function() { this._parent.gotoPosition(4); };
Now I'd like to load a movie when I move to this or that position. Maybe with if? Code: this.bout.onRelease = function() { this._parent.gotoPosition(4); if (_root.Position=4) { loadMovieNum("test.swf", 1); }}; but this doesn't work (it loads the movie alright but not because of the position).
I have a text document which is several pages long and will use scrolling capabilities. This text document will be contained in an external swf. There will be 6 buttons on the main timeline which will all load the external swf with the text document but I would like the text to autoscroll to a specific postion/part of document that relates to that topic/button. Also, i would like the scrollbar to move in relation to position/part of document in case the user stays in the external swf and reads and scrolls through the document. Is this possible? I have searched for a tutorial on this but have found nothing. I have tried different things but nothing has worked.
I have a textBox and I am using it as a mail address input field where the user can type in several addresses, a bit same as in hotmail. Each address is rendered into a clickable button. Thus upon double-clicking on a specific address I want the item to be editable. After having edited the address when the user taps enter, the item is added to the list of mail adds.I am adding it using the code below:flowBox.addChildAt( myItem, myindex);However addChildAt seems to add the item as the last item in the list. But I want it to add the item the position where it was originally. Say the item was at position 2 in the mail list, after editing adn tapping enter,
I am currently trying to create an app using flash AIR.I would like to find some more information on how to make an object snap to another ojbect then follow its path, eg. a person object is already on the stage, then drag an arrow to the object which snaps to it, then on play button it follows the arrow path. all in pure actionscript, no guide layers.
What button event should I use to make the program understands to DO SOMETHING only when the button is pressed/dragged. In my sample code below, I want something to happens only if the button is dragged beyond 200 in y axis. I tried onRelease, onRollOver and onDragOver but still not working
I'm developing an app for ANDROID devices using Flash Builder Burrito and am having trouble figuring out how to accomplish one aspect of my app.I have an HGroup inside of a Scroller. The HGroup has images that are 400px in width and I have the width of each HGroup column set to 400px. Although the number of items is dynamic, assume I have 10 images in the HGroup. The width of the Scroller and Viewport is set to 400px.
So far so good -- the user can see a single image within the scroller. The user can then scroll left or right using touch or mouse and see each image. But here's where I'm stuck. I want to make it so that when the user STOPS scrolling the scroller then "snaps" an image into view. In other words, I don't want half of one image and half of another image in the viewport.
Seems pretty straightforward but I can't figure it out. Part of the issue is that there doesn't seem to be an event to use for this purpose. I know I can hook in to PropertyChangeEvent.PROPERTY_CHANGE or MouseEvent.MOUSE_UP/TouchEvent.TOUCH_END (which is what I'm doing now) but that event doesn't really give me what I need.
I really need an event that fires when the user releases the mouse as part of the scroll or lifts their finger off the device as part of the scroll. And then I need to wait for the scroll to stop. For example, if I do a really fast swipe I need to wait for the scroller to stop or almost stop before I perform the snap. The event fires as soon as I let go of the mouse or take my finger off the tablet, so if I alter the horizontal scroll pos then it gets overwritten by the "slowing down of the scroller".
By the way, I know I can use modulus logic to show each image "whole". That's not where I'm stuck -- I'm stuck at which event to use to know WHEN to perform this mod logic.
Note that what I've already developed works just fine if I slowly scroll and then let off the mouse. It's only when you slide more rapidly that it ceases to work.
Here's my partially working code:
private function onVehicleScrollerMouseUp(event:Event):void { snapScroller(); }