Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Draggable Object?



Hi,

I am looking for a tutorial that will teach me how to create a movie clip that I can drag around the stage or the actionscript to do it. Can anyone help?

Thanks, Matt



FlashKit > Flash Help > Flash Newbies
Posted on: 09-23-2005, 02:48 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

A Draggable Object Within Limits Of Other Object
I am trying to create an object(circle movie clip) that is draggable but stays within the space of another object(square movie clip). i want to be able to drag this object and not be able to pull it out of the square movie clip. i am assuming hitTest will be one of the functions to use but what about knowing the space of the path object(square movie clip)?


J

Btn On A Draggable Object
Sir I have a problem with one of my scripts that I have written for bouncing a ball in 2D. The problem is that the ball_mc that I have used is also draggable means it is a drag and throw bouncing ball. I want to have button over it which trigger some getURL(); function.

Please guide me how I can put a button on a draggable ball.

wait for your professional idea till then bye bye.
Take Care

Draggable Object Restrictions
I trying to drag an object within flash. The dragging bit is easy, but I do not want the user to be able to drag the object off the screen. Do I have to set some kind of restrictions on where the user can move the object to?

Y Scale A Draggable Object, Please Help
I am tryng to make a draggable object get smaller as it is dragged up the screen, as in going into the distance, I would like a smooth dynamic effect. Does anyone have a tutorial or FLA they can share? I have had people give me parts of the code but I am pretty new at action scripts and need the entired code. Thanks with any help!!
R. Hamm

Draggable Object In Flash
I need to create a draggable object in flash, but to be moved along a straight line (horizontal in this case).
Something similar to the "constrain to line" behaviour in Director.

Any help?

Horacio Duek

Draggable Object Problem
I have a main movie that I am loading another movie into using an empty movie. The loaded movie has a draggable object which doesn't work once it is loaded in the main movie. In fact none of the buttons work in the loaded movie either...

Any suggestions?

Thanks,

pjustice

Set Location Of A Draggable Object?
Hi all,
Is it possible to set the starting location of a draggable moviclip (or make a draggable mc go to a specific location in any way)??

Whenever I create one, it seems to go to the absolute left side of the draggable area (unless of course the user drags it somewhere else).

I don't know if it matters, but for my specific project, I'll need it to go to the center of it's draggable area.

Any help would be appreciated - Thanks!

- Kent

How Do I Ease A Draggable Object?
Hi,

I'm trying to make a game at the moment. It's a pretty simple game, just a standard drag and drop.

I want the draggable mc to ease back into place when it is dragged to an empty part of the screen or the wrong target. I have no idea how to do this.

Here's the code for each draggable mc... (code is on the hotspot in the mc)


Code:
on (press) {
startDrag("", true);
if (eval(_root.drag1._droptarget) == _root.target3) {
}
}
on (release) {
stopDrag();
if (eval(_root.drag1._droptarget) == _root.target1) {
getProperty ( "_root.drag1", _x ) = _root.drag1x;
getProperty ( "_root.drag1", _y) = _root.drag1y;
_root.incorrect_audio.gotoAndPlay(2);

} else {
if (eval(_root.drag1._droptarget) == _root.target3) {
setProperty("_root.drag1", _x, getProperty ( "_root.target3", _x ));
setProperty("_root.drag1", _y, getProperty ( "_root.target3", _y ));
setProperty("_root.target3", _alpha, 0);
setProperty("_root.word_3", _alpha, 0);
gotoAndPlay(2);
_root.score = _root.score + 1;
} else {
getProperty ( "_root.drag1", _x ) = _root.drag1x;
getProperty ( "_root.drag1", _y) = _root.drag1y;
}

Boundaries For A Draggable Object
Hi

I've created a movie clip that is draggable. Just looking for some basic code to tell this clip how far within a window it is draggable, so it can't be dragged off the screen, into "no man's land".

Thanks.

Draggable Object With Buttons
I'm making a basic kinda thing or so I thought...

Its basically a weekly calender with event titles under a date.
When the user clicks on an event title an external .swf loads in the top level over the calender into an mc called movieloader. (this contains the event info)

In the external .swf there is a button that when clicked will close the loaded .swf with the unloadMovie function which works fine until...

I want the box to be draggable so the user can move it around the screen to view whats under it in the root level.
To do this I used this;

on(press) {
startDrag("movieloader");
}

on(release) {
stopDrag();
}

But when I include this action script the mc drags but the buttons in the mc become un active and I can't figure out a way around this using the drag function...

Any ideas anyone?

I can't get the .fla on here for a while unfortantly.

Hope some1 can help!

Thanks

Peter

Constraining A Draggable Object
Hi there,

I've been trying to figure out how to constrain an object in AS3. I know I'm supposed to use a rectangle object, but I cannot figure out the syntax. Can anyone post a quick sample? I want to only allow the panel below slide up and down, and only by Y number of pixels.


ActionScript Code:
function makeControlPanel() {addChild(controlP);controlP.controlPanel_btn.addEventListener(MouseEvent.MOUSE_DOWN,controlPanelDrag);controlP.controlPanel_btn.addEventListener(MouseEvent.MOUSE_UP,controlPanelStopDrag);}

Draggable Object Hotspot
Hi there

I'm having a empty loader fetching an outside swf, and I want to be able to drag it, so far i can make it, but I am able to drag this window clicking in any point of it, and I want to be able to do it if I drag it only from a top bar, as in Microsoft Windows (you can only drag a window if you drag it from the titlebar).

How can I define which area of the swf will trigger the drag function?

thanks a lot

Draggable Object Not Detected After Drop
I have a drag object that I want to kick back to the starting coordinates upon dragging another object to the same hit target. Problem is, Flash doesn't recognize the droptarget once it' s been dropped to send it back to it's place. Is there a way around this? Here'e the code:

First to set the x,y coords on main timeline I have this.

mc01x = _root.mc01._x
mc02x = _root.mc02._x

mc01y = _root.mc01._y
mc02y = _root.mc02._y

..obviously that sets the variable coords right there.


Then for the button code inside of mc02 is this:

on (press) {
startDrag (this);
}
on (release) {
stopDrag ();
if (this._droptarget == "/hitarget") {
_root.mc01, _x, _root.mc01x;
_root.mc01, _y, _root.mc01y;

} else {
this._x = _root.mc02x;
this._y = _root.mc02y;
}
}

Now if mc01 is already there at hitarget, it should get sent back when you drag mc02 there but Flash isn't seeing it, even tracing the coords.

Why is this? Is there another way to set the other mc back in place?



Cheers

Easy Way To Rotate A Draggable Object?
If I create a draggable object using actionscript and a movie clip. Is there an easy way to allow for a user to be able to rotate the object as little or as much as they want to after it has been deemed draggable? I am not looking to have the object free rotate by itself but for the user to rotate it on command. Does anyone know of an easy way to do this? Thanks in advance for your help.

Andrew

Orienting A Draggable Object To A Path
I have a minor problem, I need to orient an object to a drag path. for instance I have a imagae that is focused on a central point and would like to to drag it around a circle whilst always focussing in on the center of the circle. Is there any way to do this.

Thanks in advance for any help

Draggable Object, Please Check Script...
hey guys, i have searched this forum and a few others but i have come up blank. i have a set of 4 buttons and i have an arrow underneath them, so when the user scrolls over the button, the arrow eases underneath BUT i only want the arrow to move when the cursor is near the buttons, so when the mouse is all over the screen, the arrow will not move continuously all over the place. simple enough, should be the problem that i am having is that when i add my script ( that has easing AS in it) to the arrow, it moves all over the screen. i tried the hit test and constraining it and that works but the arrow will not "ease" into place. i know there's a ton of posts but i cant seem to add them together. here is the script on my button thus far:

onClipEvent (load) {
_x = 460;
_y = 530;
speed = 3.5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse = 530;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}

this eases my button fine and on the y axis, but how can i get it to only ease within a certain width of the x axis?

im not asking for a script, jsut guidance on where im going wrong with this

thanks for the help
Tracy

Draggable Object To Control Another Movie?
I was wondering if anyone could help me out...
I ultimately want to make an arrow button or movie that the user can drag along a path of semi-circle and in turn it would move the main movie (including itself)horizontally across the screen.

Does anyone have any ideas how this can be done???

Thanks in advance....

How Do I Scale A Draggable Object On Rollover?
Hey - and thanks to anyone who can help me!
I am creating a children's interactive click-and-drag activity. They will click on objects and drag them to the correct location. The only problem is I have so many objects that I had to scale them all down in order for them to all fit on the screen. How do I make it so when they rollover on the object, it increases to the correct scale (and stays that way) so they can then position it to the right place in the movie? Not sure if my objects need to be mc's or buttons for this to work. Any help MOST appreciated!

Clickable MC Inside A Draggable Object?
i have a box that the user can drag around. in the center of that box is a circle. i want the user to be able to click on that circle. sound simple but i can't do on(press)... because the parent MC, or the box, already has the on press for the drag. anyone have any ideas? if need be i can post a simple .fla/.swf example if anyone is willing to tackle this issue... thanks!

Really Simple: Clickable Draggable Object
Making a portfolio.

I want the pieces in my portfolio to be draggable in the space.

I also want the user to be able to click on them, with at gotoandplay() on a different point on the timeline.

I know how to do these things separately. I don't know how to put them together.

All the answers I'm finding are extremely specific to a certain project or are way off the mark. Please help.

Rollovers Disabled When Object Is Draggable
I have been searching and searching for a solution to this, but I can't seem to find any help. I have a movie clip that has rollovers in it. When I make the object startDrag, the rollovers no longer work. It is like the drag function takes over and disables the rollover. Is there a way to get rollovers to work in an object that can be dragged?

Draggable Object Within Stage Dimensions
I've got a simple draggable box, but when it's dragged about the stage, I don't want it to "disappear" if part of it is beyond the boundaries of the stage (in my case 780x412).  Is there any way to stop a draggable object from "vanishing" beyond the border?

Thanks!

Draggable Object Not Detected After Drop
I have a drag object that I want to kick back to the starting coordinates upon dragging another object to the same hit target. Problem is, Flash doesn't recognize the droptarget once it' s been dropped to send it back to it's place. Is there a way around this? Here'e the code:

First to set the x,y coords on main timeline I have this.

mc01x = _root.mc01._x
mc02x = _root.mc02._x

mc01y = _root.mc01._y
mc02y = _root.mc02._y

..obviously that sets the variable coords right there.


Then for the button code inside of mc02 is this:

on (press) {
startDrag (this);
}
on (release) {
stopDrag ();
if (this._droptarget == "/hitarget") {
_root.mc01, _x, _root.mc01x;
_root.mc01, _y, _root.mc01y;

} else {
this._x = _root.mc02x;
this._y = _root.mc02y;
}
}

Now if mc01 is already there at hitarget, it should get sent back when you drag mc02 there but Flash isn't seeing it, even tracing the coords.

Why is this? Is there another way to set the other mc back in place?



Cheers,
Jesci

Changing A Text_Input To A Draggable Object
I have a Text Input box and a button. I'm trying to make it so that the button changes the text_input box into a draggable object while preserving the information that was entered (into the text input box) as a String to be saved for JSON encoding.

This is my first Flash app, too, so plz talk to me like I'm a monkey. Thanks.

Buttons Not Working When Draggable Object Is Present
Help! I have a movie clip that I wanted to stay confined in an area but still follow the cursor position. I used the actionscript

onClipEvent (load) {
startDrag("", true, _x, _y-10, _x, _y+400);
}


But, I have simple buttons right next to this movie clip and they're not working--the hand doesn't appear when I mouse over and when I click nothing happens as well. Also, the actionscript I'm using for the mouse-following movie clip may be causing the error, it was an experimental script that happened to work. If anyone knows what I can do to make them work please email me! Kittiesister@hotmail.com

Thanks!
Kirsten

Creating A Draggable Object That Can Only Be Moved Left Or Right...
I'm trying to develop a quick and simple demonstration involving a draggable object, but I don't want the user to be able to go up or down, just left or right. Here's what I've got:


ActionScript Code:
import flash.events.EventDispatcher;

import flash.display.Sprite;

function dragMovie(event:MouseEvent):void
{
cross.startDrag();
}

cross.addEventListener(MouseEvent.MOUSE_DOWN,
dragMovie);

function dropMovie(event:MouseEvent):void
{
cross.stopDrag();
}

cross.addEventListener(MouseEvent.MOUSE_UP,
dropMovie);

Is there an easy way to modify this code to restrict movement on the y-axis? Or am I taking a totally wrong approach? All input is greatly appreciated, thank you.

Draggable Object Attached To Elastic Like Hose... Help
Hi,

This is my first post, I am trying to play with draw nodes and draw api actionscript. What I am trying to make is a gas pump in flash where the user can drag the nozzle off the pump with an elastic like hose attached to it.

I found this tutorial: http://www.emanueleferonato.com/2007...me-with-flash/ , which is exactly what I want except I want more of an elastic like feel to the hose... I also found this which has the elastic effect but it follows the mouse rather than drag and drop: http://www.kirupa.com/forum/showthread.php?t=210193

Any help would be greatly appreciated

PS: I would also like the nozzle to be limited!

Draggable Falling Object That Snaps Back If Released
Hi all,

As from my subject, I'm trying to make a draggable movieclip that, when released, should snap back to the position that it was first pressed on. And I can't seem to get it working.

The code below has the movieclip falling naturally. When the button inside the movieclip is pressed on, you can move the movieclip anywhere you want. However, when you release the button, it continues falling where you left it. I hope I'm making sense. But this isn't what I want.

Any suggestions? (code below)

Thanks very much in advance.


//---------functions on main timeline------------
function moveThis(MC){
MC._x = _xmouse;
MC._y = _ymouse;

}
function resetThis(MC) {
MC._x = oldX;
MC._y = oldY;
}
//--------script in movieclip----------------
onClipEvent (load) {
dy = 2;
falling = true;
}

onClipEvent (mouseMove) {
if ( (dragging == true) && (falling == false) ){
_root.moveThis(this);
updateAfterEvent();
}
}

onClipEvent (enterFrame) {
if (falling == true) {
this._y += dy;
if (this._y >380) {
this._y = 390;
}
}
else if ( (dragging == false) &&
(falling == false) ) {

_root.resetThis(this);
falling = true;
}
}
//---------script in button---------------
on(press){
oldX = this._x;
oldY = this._y;

dragging = true;
falling = false;
}

on(release,releaseOutside){
dragging = false;
falling = true;
}

I Wanna Make A Zoom To An Object From A Draggable Scrollbar
Hello, I realy need a little AS help with an object (a square) that I wanna zoom it (in and out), progresively, from a scrollbar. Let me be more specific:

There is a horizontal scroll bar and a blue square. When I drag my scroll to the right the sqoare needs to grow, and when I drag my scroll to the left my square needs to minimize.

Here is the file attached that I work with (or you can download it from http://www.zerosoft.ro/downloads/drag_and_zoom_help.zip). If anybody can help me please do it.


Thank you guys!

[F8] Using A Slider To Alter The Values Of An Object (draggable Movie Clip)
Hi, firstly im new here so hello!

Im not sure how much sense this is going to make, but what im wanting to do is to have a slider bar and another movie clip (for example a light bulb). The slider bar will then be used to change the light bulbs brightness, when the slider is at the bottom the bulb will be "off" and then as it is dragged up the bar, it will gradually light up (and then keep getting brighter) Now im guessing that im going to need the _alpha value to make this happen but im not entirely sure on how to get through this.

So if anyone could help out with a few pointers (and if it made any sense at all) i'd very much appreciate it!

cheers

Draggable Object "sticks" With Mouse
I'm currently working on an interactive quiz for kids. One quiz (www26.brinkster.com/mixdmdia/missing.html) makes use of the drag and drop technique. I'm having several problems with my movie, as follows:
a) one (draggable) object (the scissors) stays "glued" to the mouse and just won't release (my script, of course, includes on (release) { stopDrag(); } ).
b) another object (the placard) doesn't work the way it's been programmed (while another object - the eye - consistently does what it's supposed to do). It's supposed to make a MC (some text saying "wow") visible when dropped on a particular target (the lady).
All scripts have been double-checked and I still don't understand why this is so. I've attached the .fla file for reference (can also download at www26.brinskter.com/mixdmdia/missing.zip)
Please help...

Draggable Item On A Draggable Mask
hello, i was trying to make a sniping game, and i can get the mask to drag. but i want crosshairs and it won't appear in the mask, so i put it on a diff. layer and it still won't work. has anyone had this same problem, and if so, please help me.

Draggable
hmm can someone tell me or point me in the direction of how to make a mc draggable using flash 5...
thanks

More Than Just A Draggable Map
All I need here is just a small push in the right direction and I am sure it will all click.

I have been looking for some time to get a map that I am going to use for navigating through a site, to drag on both the _x and _y axes. however rather than just creating a dragabble MC I was hoping to have a controller to make the animation look that much smoother. Has anyone seen a good tutorial or example to assist me or can recommend a solution.

Any response are greatly appreciated.

Draggable Help
problem:
i want to have a toolbar where you click the button, a movie clip will appear, and the user can drag it to any location they want.

Extra Credit:
in a perfect world, i would love to have a save button, that would save where the user placed these movie clips as a seperate swf file.


anyone that can help please do so...
thanks!

Draggable Nav Bar
ive made nav bar which i want to be draggable on my site, i made the background, then the buttons, grouped them as a movie clip and gme them the actions

onClipEvent (mouseDown) {
this.startDrag(true);
}
onClipEvent (mouseUp) {
this.stopDrag();
}

the problem is when people click one of the buttons it picks up the nav bar to be dragged and also when some clicks anywhere on the screen, the bar jumps there. how can i limit the bar from moving to only when its clicked on it a certain place and not the buttons or any random place on the page?

--> Following A Draggable MC?
I've been experimenting for several weeks now and haven't been able to figure this out.

I would like to set up my flash movie so that when the user drags a movie clip, other movie clips will move along with it depending on which variables are set. I can get one movie clip to follow another when dragged (using onClipEvent(enterFrame), but I would like to set this up on the individual buttons and only have it run when the user is in the process of moving an MC.

----------------------------------CODE----------------------------
on (press) {
_global.depth = _global.depth + 1;
this.swapDepths(_global.depth);
startDrag(this);
}
on (release) {
stopDrag();
//If piece is placed in following location lock it so that it can't be moved
if(this._x>467.5 && this._x<487.5 && this._y>53.75 && this._y<73.75){
this._x=477.5;
this._y=63.75;
_root.piece1MC.piece1._visible=false;

// If MC is placed in this position, it should be locked to the piece it was next to
}else if (_root.piece1MC._x < (_root.piece2MC._x - 62) && _root.piece1MC._x > (_root.piece2MC._x - 82) && _root.piece1MC._y > (_root.piece2MC._y - 8) && _root.piece1MC._y < (_root.piece2MC._y +12)){
_root.onetwo = "true";
}
----------------------END CODE------------------------

This is the code I have one MC (they're all similar to this). When variable "_root.onetwo" is set, I would like piece1MC to follow piece2MC and vice versa. The code to do this must be placed on each individual piece, otherwise only one will work.

Any help is greatly appreciated!

Draggable Mc
Hi, i have a function which allows me to drag my mc's on the x axis, but i now want them to be draggable on the y axis too.... so they can be put anywhere. My code for the x axis is below, any thoughts as to how i can make it completely draggable, not just on the x axis?

I'm fairly new to flash, thanks for your help.



onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse, false) && _root.blocksDrag == false) {
this.startDrag(false, -800-this._width, this._y, 800, this._y);
}
}
onClipEvent (mouseUp) {
this.stopDrag();
}

Draggable MO + Following MC
Is there any simple actionscript to get a MC to follow a draggable MC.

Draggable MC
I basically need to drag a movie clip (just an image, nothing else) around the stage.. just did a search for it, but couldn't find anything in AS3.. anyone know where I would start?

Thanks!
Zg

Draggable MC Help
Hey folks,

I've been developing a little game thing...one part in particular is giving me problems.

There is a pic of a turtle, and a tortoise, and land and water. You're supposed to drag one of the two to its corresponding environment...if you're wrong, it goes back to the original spot, if it's right, it's supposed to stay.

It works on it's own (as seen here), but when loaded into the main container movie, they don't stay put.

Here's what i'm using on the MC's of the buttons of the turtles;


Code:


on (release) {
stopDrag ();
if (_parent.tortoise_drag._droptarget == "/tortoise_target") {
//_root.tortoise_target.gotoandStop("tortoise_hold");
_parent.tortoise_drag == stopDrag();
}
else {
this._x = 490//the old xposition of the MC
this._y = 145//the old yposition of the MC
}
}



I"m guessing i'm incorrectly using the _parent and _root somewhere, but not sure.

Thanks!

How Is This Done (Drag Object Anywhere Return To Origin), Object Follow Mouse On Lock
Both on same site,

1/. how did he do the dragable discs to the left of the introduction text?

2/. how did he make it so when you roll over a menu link, an object follows it underneath, but also stays there until you roll over the next?

Thanks

Draggable Mask?
I have tried but failed miserably to accomplish this task...

Using Startdrag, make a draggable mask layer to create a magnifier effect.

Can it be done?
Any hints?

Regards,

Draggable Pop Up Window
what I want to do is have a draggable window pop up at a certain location within the main movie when I press a button. what code do I attach to the button? I know the drag stuff, but how do i set the position?

Draggable Buttons - Help?
ive got a 'nav bar' (movie clip) on it are 7 buttons.
the 7 buttons are in the movie clip.
the nav bar is called 'menu'
i want to make the nav bar draggable and have the buttons clickable to go to 7 different scenes in the main movie.

help would be great as Im at work and struggling

Draggable Buttons
I have created a draggable button that works fine. The problem is that I created another button which leads to a URL that seems to get dragged along with the other button even though it is on a different layer and has no script. Does anyone know how to seperate the button behavior or keep the entire movie from being dragged with the draggable button? Thanks for your help
Terry C

Draggable Menu
Hi there,

Reading about inertia and dragging things in Foundation Actionscript (thank you mr. Sham Bhangal), I wanted to make a draggable menu. One button is used to move the menu, the menuitems are supposed to follow that button. My problem is that the menuitems aren't aligned after moving the menu around. Any suggestions?
http://users.skynet.be/sky39384/flash/drag_menu.fla
http://users.skynet.be/sky39384/flash/drag_menu.swf

Draggable Mask
Hey Guys,
Just wondering if it was possible to make a draggable mask. I tried making a mask, turning it into a button and then making it draggable but that didnt work since it takes everything below the mask with it. So when I just want to drag the mask, I end up dragging the maskED images as well. Any help would be greatly appreciated. Thanks guys
Don

Copyright © 2005-08 www.BigResource.com, All rights reserved