dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: an educational game - drag and drop

  1. #1
    Member
    Join Date
    Oct 2004
    Location
    Valencia Spain
    Posts
    48

    an educational game - drag and drop

    Hi guys. Please forgive my naivity.
    I'm making drag and drop games. In this one you have to drag hamburgers or chips in the right sequence. ie: Hamburger, hambueger, chips . into squares.
    BUT as the hamburger has the same name I have problems when I stop it's dtag properties. ALL of them stop. But if I give them all different names it's a pain as well. I have a hitzone in the square.

    onClipEvent(enterFrame){
    if(this.hitzone4.hitTest(_root.Hamburger)) {
    _root.Hamburger.stopDrag();
    _root.Hamburger._x = 62;
    _root.Hamburger._y = 60.5;

    updateAfterEvent();
    }
    }
    Do I give all the hamburgers different names and if so how does the swaure know what is being dropped on it - would I loo through or something.
    Another thing is that I have to specify the coordinates otherwise the hamburger doesn't get left in the centre of the square.

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Wrong forum, moved to Actionscript.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Member
    Join Date
    Apr 2006
    Posts
    50
    There are quite a few ways to go about this, but look into these thoughts...

    Try not to name them all the same thing. Name them like:
    hamburger1, hamburger2, ect. ect. Make sure all the names end up unique.

    Now.. you can add dynamic codes to each object added to the flash application.
    Code:
    var current_burger = false;
    
    function blahfunc() {
      current_burger = false;
    }
    function blahfuntwo(){
      current_burger = false;
    }
    _root.["hamburger1"].onMouseDown() = blahfunc();
    _root["hamburger1"].onRelease() = blahfunctwo();
    
    // do this for every hamburger added!
    _root.hamburger[2].onClipEvent(enterFrame) = function(){
      if(this.hitzone4.hitTest(current_burger)) {
        this.stopDrag();
        this._x = 62;
        this._y = 60.5;
    
      updateAfterEvent();
      }
    }
    This should give you an idea.... just look at the code and play around with it. And, I think the _root["hamburger1"].onMouseDown() and such should just be like _root.["hamburger1"].onMouseDown(), but it's been a long time since I had to do anything like that.... so I forget.
    Last edited by LifeToTake; 05-17-2008 at 06:16 AM.

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