A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Collision

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    1

    Collision

    I am new to flash. I would like to drag and drop multiple objects and on collision activate/play a video clip.

    Pls show me what AS3 I can use?

    Thanks.

    Mgeni

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    I would start at the drag and drop level. So a search for drag and drop using your preferred actionscript version and go from there. Don't try to do both functions from the start, learn as you go.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Senior Member guardiankitty's Avatar
    Join Date
    Dec 2006
    Location
    Here
    Posts
    215
    Quote Originally Posted by mgeni View Post
    I am new to flash. I would like to drag and drop multiple objects and on collision activate/play a video clip.

    Pls show me what AS3 I can use?

    Thanks.

    Mgeni

    I would use something like:

    Actionscript Code:
    var DraggingObject:*;

    function GK_startDrag(drag):void{
        DraggingObject = drag;
        addEventListener(Event.ENTER_FRAME, GK_moveObject);
        hitManager.addEventListener('HIT', GK_onHit);
    }
    function GK_stopDrag():void{
        DraggingObject = null;
        removeEventListener(Event.ENTER_FRAME, GK_moveObject);
        hitManager.removeEventListener('HIT', GK_onHit);
    }

    function GK_onHit(e:Event):void{
        GK_stopDrag();
        //Play a movie
        //or do anything!
        trace('BUMP!');
    }


    var hitManager:EventDispatcher = new EventDispatcher();



    function GK_moveObject(e:Event):void{
        DraggingObject.x = mouseX;
        DraggingObject.y = mouseY;
        CheckHit();
       
       
    }

    function CheckHit():void{
        //make logic for all of for everything you want to check if it hits
        //for loop is your best bet
        if(DraggingObject.hitTestObject(box2)){
            hitManager.dispatchEvent(new Event('HIT'));
        }
    }



    GK_startDrag(box1)


    Your lucky I love you so much,...

    Here is a FLA showing it in action:
    http://craigavenue.com/forumpics/DragExample.fla


    it should be easy enough to follow what is going on here, but if not let me know!


    Hope this helps!
    -GK>'.'<

  4. #4
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    You are very kind....GK
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center