Solved

Draggable Flash Button

Posted on 2010-09-19
2
224 Views
Last Modified: 2013-11-11
I have simple tweened diagram. The only actionscript is start(); and stop(); set at intervals to seperate the tweened animations (boxes appearing).

I have a movie clip which is draggable. I need it to be draggable so that it can be dragged around out of the way so the diagram can be read (its quite a big diagram). Also, when it is clicked, it takes the root timeline to the next frame, so it plays until it hits a stop(); and so on.

At the moment it will go to the next frame as soon as the mouse button is released, no matter if the button is dragged or not. However I would like to sperate these two actions.

Ideally, I would like the movie clip to make the root/main timeline go to the next frame if the mouse button is double clicked (or held down for less than 1 second) and dragged if single clicked (or held down for more than 1 second).

I am willing to use whichever method is easiest. Here is the code that is attached to the movieclip (AS2 I'm afraid)

Thanks to all.

on (press) {
     startDrag ("", false, left, top, right, bottom);
     dragging=true;
      
}
on (release) {
     stopDrag ();
     dragging=false;
     _root.nextFrame();
}
onClipEvent (load) {
    top=_y-364;
    bottom=_y+364;
    left=_x-149;
    right=_x+149;
}



 Flash code and timeline
0
Comment
Question by:eLearningDevo
2 Comments
 
LVL 19

Accepted Solution

by:
moagrius earned 500 total points
ID: 33814879
instead of using on(handler), use frame actions.  Add the following snippet to the actions panel of frame 1 of the timeline containing the button.  this assumes the button has an instance name of buttonInstance - if using a different name, update each reference to buttonInstance to properly reflect that name.
buttonInstance.onMouseDown = function(){
	var timer = setTimeout(function(){
		buttonInstance.startDrag();
		buttonInstance.onRelease = function(){
			buttonInstance.stopDrag();
		}
	}, 1000);
	_root.onMouseUp = function(){
		clearTimeout(timer);
		delete buttonInstance.onRollOut;
		delete this.onMouseUp;
	}
	this.onRollOut = function(){
		clearTimeout(timer);
		delete this.onRollOut;
		delete _root.onMouseUp;
	}
	this.onRelease = function(){
		clearTimeout(timer);
		trace('nextFrame');
		_root.nextFrame();
	}
}

Open in new window

0
 

Author Closing Comment

by:eLearningDevo
ID: 33826938
Thankyou.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question