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!
dragging
Collapse
X
-
Hello, try this:Originally posted by Yuvalhi! 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!
But make the frame rate more than 12, it be better. I usually make that 24.Code:mcCard.onPress = function(){ this.startDrag(); } mcCard.onRelease = function(){ this.stopDrag(); } -
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
-
Hello: (Another way)Originally posted by Yuvalthanks 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.
Select the Card (but make sure the card is a movieclip or a button) and bring the actions panel and write:
Hope this help you.Code:on(press){ this.startDrag(); } on(release){ this.stopDrag(); }
Any thing else: post again.Comment
-
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.Originally posted by AtranHello: (Another way)
Select the Card (but make sure the card is a movieclip or a button) and bring the actions panel and write:
Hope this help you.Code:on(press){ this.startDrag(); } on(release){ this.stopDrag(); }
Any thing else: post again.Comment
-
You must select every Card and bring the actions panel and write that code.Originally posted by Yuvalok, 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.
I mean you must that code on every card by itself.Comment
-
Originally posted by AtranYou 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
-
If you want to drag one card and other cards drags with that card, read below:Originally posted by Yuvali 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.
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
-
If you want to drag one card and other cards drags with that card, read below:Originally posted by Yuvali 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.
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
-
it works! thanks alot!! i'll send you a link when i finish the game :)Originally posted by AtranIf 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
Comment