Ultrashock Forums > Flash > Flash Newbie
Dragable flash?

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Dragable flash?
Old 2006-03-11

I came across this website (http://www.conceptm.nl) and I was wondering if anyone knew of any tutorials out there on how to make a site that you can drag just like this. I can't seem to find any good help. Thanks!
hi
postbit arrow 9 comments | 366 views postbit arrow Reply: with Quote   
Registered User
kallok is offline
seperator
Posts: 9
2002-01-12
Age: 25
seperator

Ultrashock Member Comments:
bambi bambi is offline 2006-03-12 #2 Old  
ActionScript Code:
  1. class Draggable extends MovieClip{
  2.  
  3.   var down : Boolean = false;
  4.  
  5.   function onMouseDown(Void):Void{
  6.     down = hitTest(_root._xmouse,_root._ymouse);
  7.   }
  8.  
  9.   function onMouseUp(Void):Void{
  10.     down = false;
  11.   }
  12.  
  13.   function onMouseMove(Void):Void{
  14.     if(down){
  15.       _x = _parent._xmouse;
  16.       _y = _parent._ymouse;
  17.     }
  18.   }
  19.  
  20. }
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2006-03-12 #3 Old  
You could also have a look at MovieClip.startDrag() and MovieClip.stopDrag() methods in the Flash Help docs.

If you set Flash's wmode parameter in your HTM file though then I would use a custom class like bambi's up there^ to avoid a little Firefox/Mozilla bug.
Reply With Quote  
bambi bambi is offline 2006-03-12 #4 Old  
yeah, and you can't use easing with startDrag (afaik).
Reply With Quote  
kallok kallok is offline 2006-03-12 #5 Old  
thanks, that helped!
Reply With Quote  
kallok kallok is offline 2006-03-12 #6 Old  
Actually, I'm still having big problems, I'm a bit rusty with my Actionscripting . I had it working then it decided to just not drag at all. I also can get the MovieClip.startDrag() and MovieClip.stopDrag() to work, but I want it to have the easing. If anyone could just look at my file and get it working, that would be great.

http://www.indieyoungstown.f2o.org/drag.fla
Reply With Quote  
bambi bambi is offline 2006-03-12 #7 Old  
there's no code in that file
Reply With Quote  
kallok kallok is offline 2006-03-12 #8 Old  
I know I removed it because it was a mess. I don't even know where to begin.
Reply With Quote  
bambi bambi is offline 2006-03-12 #9 Old  
my code above is a subclass of MovieClip.

in your file, the clip on the stage needs to be draggable. take my code, create an as file and save it as Draggable.as in the folder with the fla.

go to the clip in the library, and rename it Draggable. then right click on it and select Linkage... enter Draggable for both the identifier and the AS 2.0 class. check "export for actionscript" if necessary.
Reply With Quote  
kallok kallok is offline 2006-03-12 #10 Old  
yes! I did the part about saving it as Deaggable.as wrong. This was bugging me all day, thanks again!
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: