Solved

Draggable Flash Button

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Script refinement question. 1 61
Automate PC's, Laptop to correct OU 4 54
Powershell GUI 11 95
Need PSEXEC help to deploy .exe and .reg files to client machines 13 103
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

739 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