Solved

Draggable Flash Button

Posted on 2010-09-19
2
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of the tutorial is to teach the user how to how to record live broadcast.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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