dragging

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yuval
    New Member
    • Jun 2007
    • 5

    dragging

    hi! i'm trying to make a card game, and i would like to know how to press on a card and drag it to a specific place on the screen, can anyone give me a hand with the actionscript? thanks!
  • Atran
    Contributor
    • May 2007
    • 319

    #2
    Originally posted by Yuval
    hi! i'm trying to make a card game, and i would like to know how to press on a card and drag it to a specific place on the screen, can anyone give me a hand with the actionscript? thanks!
    Hello, try this:
    Code:
    mcCard.onPress = function(){
    	this.startDrag();
    }
    mcCard.onRelease = function(){
    	this.stopDrag();
    }
    But make the frame rate more than 12, it be better. I usually make that 24.

    Comment

    • Yuval
      New Member
      • Jun 2007
      • 5

      #3
      thanks for replying
      can you be a little more specific, i'm kind of new to actionscript.

      on whice object do i write the code? on the frame? or the cards?
      do i have to do anything else for the code to work? or does it work simply by writing what you told me...

      thanks again,
      yuval.

      Comment

      • Atran
        Contributor
        • May 2007
        • 319

        #4
        Originally posted by Yuval
        thanks for replying
        can you be a little more specific, i'm kind of new to actionscript.

        on whice object do i write the code? on the frame? or the cards?
        do i have to do anything else for the code to work? or does it work simply by writing what you told me...

        thanks again,
        yuval.
        Hello: (Another way)
        Select the Card (but make sure the card is a movieclip or a button) and bring the actions panel and write:
        Code:
        on(press){
        	this.startDrag();
        }
        on(release){
        	this.stopDrag();
        }
        Hope this help you.
        Any thing else: post again.

        Comment

        • Yuval
          New Member
          • Jun 2007
          • 5

          #5
          Originally posted by Atran
          Hello: (Another way)
          Select the Card (but make sure the card is a movieclip or a button) and bring the actions panel and write:
          Code:
          on(press){
          	this.startDrag();
          }
          on(release){
          	this.stopDrag();
          }
          Hope this help you.
          Any thing else: post again.
          ok, the first script you showd me worked very well on one of the cards, but when i tried it on another one in the the same screen it dosen't work.

          Comment

          • Atran
            Contributor
            • May 2007
            • 319

            #6
            Originally posted by Yuval
            ok, the first script you showd me worked very well on one of the cards, but when i tried it on another one in the the same screen it dosen't work.
            You must select every Card and bring the actions panel and write that code.
            I mean you must that code on every card by itself.

            Comment

            • Yuval
              New Member
              • Jun 2007
              • 5

              #7
              Originally posted by Atran
              You must select every Card and bring the actions panel and write that code.
              I mean you must that code on every card by itself.

              i did, i went on every card, went to the actions panel and wrote the code.
              it only let's me move one card, the other one does not respond.

              Comment

              • Atran
                Contributor
                • May 2007
                • 319

                #8
                Originally posted by Yuval
                i did, i went on every card, went to the actions panel and wrote the code.
                it only let's me move one card, the other one does not respond.
                If you want to drag one card and other cards drags with that card, read below:
                You must make an instance to every card, first select the card then go to the properties panel, in the properties panel you will see the instance textbox, so make to each card an instance name.
                I will call the cards instance's name: mcCard1, mcCard2, mcCard3........ ....
                Read this:
                Code:
                on(press){
                    //"this" keyword means the card you selected on it, and write the code on it.
                    this.startDrag();
                
                    mcCard2.startDrag();
                    mcCard3.startDrag();
                }
                on(release){
                    this.stopDrag();
                }

                Comment

                • Atran
                  Contributor
                  • May 2007
                  • 319

                  #9
                  Originally posted by Yuval
                  i did, i went on every card, went to the actions panel and wrote the code.
                  it only let's me move one card, the other one does not respond.
                  If you want to drag one card and other cards drags with that card, read below:
                  You must make an instance to every card, first select the card then go to the properties panel, in the properties panel you will see the instance textbox, so make to each card an instance name.
                  I will call the cards instance's name: mcCard1, mcCard2, mcCard3........ ....
                  Read this:
                  Code:
                  on(press){
                      //this keyword means the card you selected on it, and write the code on it.
                      this.startDrag();
                      //When you drag that card, these cards will drags too:
                      mcCard2.startDrag();
                      mcCard3.startDrag();
                  }
                  on(release){
                      this.stopDrag();
                      //And stop dragging.
                      mcCard2.startDrag();
                      mcCard3.startDrag();
                  }

                  Comment

                  • Yuval
                    New Member
                    • Jun 2007
                    • 5

                    #10
                    Originally posted by Atran
                    If you want to drag one card and other cards drags with that card, read below:
                    You must make an instance to every card, first select the card then go to the properties panel, in the properties panel you will see the instance textbox, so make to each card an instance name.
                    I will call the cards instance's name: mcCard1, mcCard2, mcCard3........ ....
                    Read this:
                    Code:
                    on(press){
                        //this keyword means the card you selected on it, and write the code on it.
                        this.startDrag();
                        //When you drag that card, these cards will drags too:
                        mcCard2.startDrag();
                        mcCard3.startDrag();
                    }
                    on(release){
                        this.stopDrag();
                        //And stop dragging.
                        mcCard2.startDrag();
                        mcCard3.startDrag();
                    }
                    it works! thanks alot!! i'll send you a link when i finish the game :)

                    Comment

                    • Atran
                      Contributor
                      • May 2007
                      • 319

                      #11
                      You're a really beginner, so you can check this link to learn ActionScript:
                      http://getebooks4free. com/actionscript_eb ooks.html

                      Hope this help you.

                      Comment

                      Working...