Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,399 Programmers. There are 1,483 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Drag a basket..! im lost with this simple task

 
Reply to this topicStart new topic

Drag a basket..! im lost with this simple task

hollsmeags
post 17 Apr, 2008 - 11:46 AM
Post #1


D.I.C Head

**
Joined: 29 Mar, 2007
Posts: 86



I need to simply get a ball to drop into a basket....and be able to drag and drop basket...
i have
soccer.as // teh ball
soccerdc.as
soccermain.fla
target.as // the basket
tempcode.as



when would i put the functionality to drag the basket to catch the ball?

here is my target file, would it be here?

package {
import flash.display.*;
import flash.events.*;
import flash.utils.getTimer;

public class target extends MovieClip {

myTarget.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
myTarget.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function pickUp(event:MouseEvent):void {
event.target.startDrag(true);
}
function dropIt(event:MouseEvent):void {
event.target.stopDrag();
}
myTarget.buttonMode = true;

}

}



}
//end function
// End class
//end package
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


theRemix
post 17 Apr, 2008 - 12:46 PM
Post #2


D.I.C Regular

***
Joined: 19 Oct, 2005
Posts: 359

QUOTE(hollsmeags @ 17 Apr, 2008 - 11:46 AM) *

I need to simply get a ball to drop into a basket....and be able to drag and drop basket...
i have
soccer.as // teh ball
soccerdc.as
soccermain.fla
target.as // the basket
tempcode.as



when would i put the functionality to drag the basket to catch the ball?

here is my target file, would it be here?

package {
import flash.display.*;
import flash.events.*;
import flash.utils.getTimer;

public class target extends MovieClip {

myTarget.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
myTarget.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function pickUp(event:MouseEvent):void {
event.target.startDrag(true);
}
function dropIt(event:MouseEvent):void {
event.target.stopDrag();
}
myTarget.buttonMode = true;

}

}



}
//end function
// End class
//end package


shouldn't these:
CODE
myTarget.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
myTarget.addEventListener(MouseEvent.MOUSE_UP, dropIt);

be in soccer.as ?

target.as does not need any listeners. you just need to make sure they can "talk" and an easy way for AS2 is to know what the target's instance name is and relation to _root so in soccer.as

CODE
//in function dropIt(){ ... }
//if the target instance is _root.target_mc
if( this.hitTest(_root.target_mc)){
    // do something with _root.target_mc like an animation
}


hope this helps
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

hollsmeags
post 22 Apr, 2008 - 02:57 AM
Post #3


D.I.C Head

**
Joined: 29 Mar, 2007
Posts: 86

Thanks.....

Im dealing with actionscipt 3 not 2.any tips for that ?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

hollsmeags
post 1 May, 2008 - 04:14 PM
Post #4


D.I.C Head

**
Joined: 29 Mar, 2007
Posts: 86

QUOTE(hollsmeags @ 22 Apr, 2008 - 02:57 AM) *

Thanks.....

Im dealing with actionscipt 3 not 2.any tips for that ?



Can someone please help... ive attached the files for this actionscript 3 project. I just need to drop the balll and drag and drop the guy to kick the ball......
I cant figure it out.. ...

thank you kindly!Attached File  Project3.zip ( 99.87k ) Number of downloads: 8
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 06:20AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month