Jump to content


Drag and drop links


  • You cannot reply to this topic
6 replies to this topic

#1 Wazzup

    Young Padawan

  • Members
  • Pip
  • 217 posts

Posted 04 April 2006 - 09:51 AM

hey,

I wanted to create a little interactive flash clip. The concept is as follows:

Posted Image

If you drag one on of the dots to the hole, with ur mouse and release it there, there should happen something, in my case it should jump to a frame in the timeline that displays a movie on the background. This image just to clarify things. So i would very much like if someone could explain this to me, or make a simple flash animation with dots that you can drag and drop in an determined location. When u drop it there the timeline should jump to another frame. So i can review the flash animation and learn from it. When u drop it somewere else the dot should stay at that location, and nothing should happen.

#2 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 04 April 2006 - 02:12 PM

Something like this should work, put it in your main timeline:

yourMC.onPress = function(){
	startDrag(this, false);
}

yourMC.onRelease = function(){
		stopDrag();		
		if (this.hitTest(hitMC) == true){ //hitMC is a transparent movieclip which resides on the target spot
//your code here
}

Edited by funkysoul, 04 April 2006 - 02:16 PM.


#3 FlawedKid

    Young Padawan

  • Members
  • Pip
  • 36 posts

Posted 04 April 2006 - 02:13 PM

Hi Wazzap.

This Drag and Drop effect your refering to can be done by using the eval and _droptarget functions. Here is an example of what I think you want to create:

VIEW EXAMPLE

OK so I guess I’ll walk you through it.

On your main timeline create these layers

Actions
Button 1
Button 2
Button 3
Hole Mc


Now place a stop; action on the 1st frame of the actions layer

Now create a new MovieClip and place a shape of your choice inside it. Note: The shape you create will be the shape of the button

Give it an instance name of mc_btn1

Repeat this step for your other 2 buttons and give the MovieClips an instance name of.

mc_btn2
mc_btn3


Now just use a bit of common sense and place the clips on their Layers.

Create a MovieClip and place your hole graphic inside it. Give that clip and instance name of hole_mc and place it on its Layer

Ok so your sage is setup, now for the ActionScript.

Actions for > mc_btn1

onClipEvent (load) {
	this.onPress = function() { 
	this.startDrag();
}
	this.onRelease = function() { 
	this.stopDrag();
	if (eval(this._droptarget) == _root.hole_mc) { 
	this._visible = false; 
	_root.gotoAndStop("animation1"); 
	} else {
	this._visible = true; 
	}
};
}

Actions for > mc_btn2

onClipEvent (load) {
	this.onPress = function() { 
	this.startDrag();
}
	this.onRelease = function() { 
	this.stopDrag();
	if (eval(this._droptarget) == _root.hole_mc) { 
	this._visible = false; 
	_root.gotoAndStop("animation2"); 
	} else {
	this._visible = true; 
	}
};
}

Actions for > mc_btn3

onClipEvent (load) {
	this.onPress = function() { 
	this.startDrag();
}
	this.onRelease = function() { 
	this.stopDrag();
	if (eval(this._droptarget) == _root.hole_mc) { 
	this._visible = false; 
	_root.gotoAndStop("animation3"); 
	} else {
	this._visible = true; 
	}
};
}

Note: You will need to specify what frame should be stopped at once the button has been dropped in the hole by changing the code:

_root.gotoAndStop("animation1");
_root.gotoAndStop("animation2");
_root.gotoAndStop("animation3");

to either

_root.gotoAndStop("yourFrameName"); or
_root.gotoAndStop(2);
// A frame ‘2’ on the main timeline

That’s it! Test ya movie and hopefully it works.
If ya have trouble heres an example source I whipped up. Nothing special but it does what you need!

Source Files

FlawedKid :)

Edited by FlawedKid, 04 April 2006 - 02:20 PM.


#4 Wazzup

    Young Padawan

  • Members
  • Pip
  • 217 posts

Posted 05 April 2006 - 12:17 PM

Exactly what i meant, that is some great help there. Im getting on it this week. I have to create a clip with a guy in it behind a table were are sorts of drugs on. When u put one of the drugs in his mouth, you see the ´effect´ of that drug, and a description of that drug. I think it´s going to work well. I thank you again very much! im one lucky guy that you would help me.

#5 FlawedKid

    Young Padawan

  • Members
  • Pip
  • 36 posts

Posted 06 April 2006 - 02:14 AM

Lol drugs ay ;) Give me a PM when you've made it. I wouldn't mind seeing it when your done.
Good Luck

FlawedKid :(

#6 Wazzup

    Young Padawan

  • Members
  • Pip
  • 217 posts

Posted 06 April 2006 - 06:56 AM

sure its done before next weeks thursday. if i can find a way to upload it, cause from next saturday im without internet at home :) And can i have your source file 2 from the clip you created?

ho sry didnt notice your example at the bottom, but do i have to create the actionscript in the 3 code frames you posted on the first frame of each layer it belongs to?

Edited by Wazzup, 06 April 2006 - 07:14 AM.


#7 FlawedKid

    Young Padawan

  • Members
  • Pip
  • 36 posts

Posted 06 April 2006 - 02:55 PM

Just download the source file, and look at my code. Cut and pasted the code from the buttons, holdMC, and frames to your MCs/frames. That'l b easier than me tryin to explain it you.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users