Solved

Draggable Flash Button

Posted on 2010-09-19
2
222 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now