Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drag & drop problem

Status
Not open for further replies.

Whiteybags

Technical User
May 18, 2004
18
IE
Hi,
If you look at
you can see what I have working so far. At the moment the test circuit button is 'animated' all the time. I need to change it so that it is still (just like the start again button) at the start. When the four items are dragged over the four target areas I need the button to animate then. I tried putting a function on the first frame of the scene but it didn't recognise it. I can't put the code on a target because I don't know which one will be the last one to be hit. Can anyone help?
Thanks
 
From what i can tell you have a hit test going on, right? what you can do, is make those button instances into movie clips, you can change that next to the instance name. then also give them instance names. when you have the hit test run itself, tell it to play the button.

For instance, your light bulb should be an actual movie clip. Inside the movie clip, make sure there is a stop(); so it doesn't play forward. On the stage, have the drag stuff going. say the instance name of this is bulb1, in the hit test, under the true section, tell it something like:

bulb1.gotoAndPlay(2);

this will then animate the item. so here should be some similiar code directly on the button/movieclip

if (i forget the syntax for the hit test, but test for bulb1 to target 1) {
this._x = same location;
this._y = same location;
this.gotoAndPlay(2);
}

alternatively you could always have each target have an animation inside itself. what i can do is download the file and break it down for my use. i will do that at some point and toy with it.

 
Hi Crazybeans128,
Thanks for your help I must not have explained myself properly. I have to have all four targets filled with the two wires, battery and bulb before the test button animates. To do it with the code you suggested I would have to know which item was dropped last which I will not know.

I am writing from an internet cafe and don't have the file with me. Brought snippets of code though. If this is any help this is the code i have on the TEST button and the BULB. The bulb is a button within a movie clip. The code is on the button.

My thoughts were that I could put a function on the first frame of the scene and call the function on the same first frame but this did not work.

I don't know if this helps any!

ON BUTTON - TEST

on (release) {
if ((_root.wire1._droptarget== "/target1") &&
(_root.bulb._droptarget== "/target2") &&
(_root.wire2._droptarget== "/target3") &&
(_root.battery._droptarget== "/target4"))
{
gotoAndPlay("rightanswer");
}

else if ((_root.battery._droptarget == "/target1") &&
(_root.wire2._droptarget == "/target2") &&
(_root.bulb._droptarget == "/target3") &&
(_root.wire1._droptarget == "/target4"))

{
gotoAndPlay("rightanswer");
}

SAME FOR ALL POSSIBLE RIGHT COMBINATIONS


else {
gotoAndPlay("wronganswer");
}

}


ON LIGHT BULB

on (press) {
this.startDrag ();
}

on (release) {
this.stopDrag();

if (_root.bulb._droptarget == "/target1") {
this._x=248.6;
this._y=85.3;
}

else if (_root.bulb._droptarget == "/target2") {
this._x=212.1;
this._y=120.3;
}
SAME FOR TARGET 3 & 4

else {
this._x=132.6;
this._y=205.9;
}

}

Thanks for trying to help anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top