Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Draggable Flash Button

Posted on 2010-09-19
2
Medium Priority
?
229 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 2000 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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 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