473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

dragging

5
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!
Jun 21 '07 #1
10 1785
Atran
319 100+
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:
Expand|Select|Wrap|Line Numbers
  1. mcCard.onPress = function(){
  2.     this.startDrag();
  3. }
  4. mcCard.onRelease = function(){
  5.     this.stopDrag();
  6. }
  7.  
But make the frame rate more than 12, it be better. I usually make that 24.
Jun 21 '07 #2
Yuval
5
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.
Jun 21 '07 #3
Atran
319 100+
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:
Expand|Select|Wrap|Line Numbers
  1. on(press){
  2.     this.startDrag();
  3. }
  4. on(release){
  5.     this.stopDrag();
  6. }
  7.  
Hope this help you.
Any thing else: post again.
Jun 21 '07 #4
Yuval
5
Hello: (Another way)
Select the Card (but make sure the card is a movieclip or a button) and bring the actions panel and write:
Expand|Select|Wrap|Line Numbers
  1. on(press){
  2.     this.startDrag();
  3. }
  4. on(release){
  5.     this.stopDrag();
  6. }
  7.  
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.
Jun 21 '07 #5
Atran
319 100+
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.
Jun 21 '07 #6
Yuval
5
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.
Jun 21 '07 #7
Atran
319 100+
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:
Expand|Select|Wrap|Line Numbers
  1. on(press){
  2.     //"this" keyword means the card you selected on it, and write the code on it.
  3.     this.startDrag();
  4.  
  5.     mcCard2.startDrag();
  6.     mcCard3.startDrag();
  7. }
  8. on(release){
  9.     this.stopDrag();
  10. }
  11.  
  12.  
Jun 21 '07 #8
Atran
319 100+
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:
Expand|Select|Wrap|Line Numbers
  1. on(press){
  2.     //this keyword means the card you selected on it, and write the code on it.
  3.     this.startDrag();
  4.     //When you drag that card, these cards will drags too:
  5.     mcCard2.startDrag();
  6.     mcCard3.startDrag();
  7. }
  8. on(release){
  9.     this.stopDrag();
  10.     //And stop dragging.
  11.     mcCard2.startDrag();
  12.     mcCard3.startDrag();
  13. }
  14.  
  15.  
Jun 21 '07 #9
Yuval
5
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:
Expand|Select|Wrap|Line Numbers
  1. on(press){
  2.     //this keyword means the card you selected on it, and write the code on it.
  3.     this.startDrag();
  4.     //When you drag that card, these cards will drags too:
  5.     mcCard2.startDrag();
  6.     mcCard3.startDrag();
  7. }
  8. on(release){
  9.     this.stopDrag();
  10.     //And stop dragging.
  11.     mcCard2.startDrag();
  12.     mcCard3.startDrag();
  13. }
  14.  
  15.  
it works! thanks alot!! i'll send you a link when i finish the game :)
Jun 21 '07 #10
Atran
319 100+
You're a really beginner, so you can check this link to learn ActionScript:
http://getebooks4free.com/actionscript_ebooks.html

Hope this help you.
Jun 21 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Sparky | last post by:
Does anyone know if dragging the URL from Internet Explorer and dropping it into a text box in my own program is possible? erm ..and if so, how? Failing that, is there some other method I can use...
5
by: joe | last post by:
I have an image database that I'd like to populate by dragging an image off the desktop and dropping onto a form (cut/paste would work equally as well) Any suggestions? Thanks, Joe
0
by: Sin Jeong-hun | last post by:
If FlowLayoutPanel's AutoScroll is set to true, there appears a scroll bar on the right. Normally, users would expect the contents is scrolled while they are dragging the scroll bar. Well, it does,...
2
by: Christian Blackburn | last post by:
Hi Gang, I would like to be able to drag and drop documents onto my application and have them open immediately thereafter. Can somebody point me towards a KB article or example? I could find a...
16
by: Geoff Jones | last post by:
Hiya Could anybody direct me to some examples of code to do the following: Display a bitmap on a form which can then be moved about i.e. dragged, using the left down button of the mouse. ...
3
by: Liz | last post by:
I need to implement dragging a borderless form by clicking/dragging on the form surface. Using the "standard" approach (setting "CanMove" flag on MouseDown, moving the form by the delta of the...
2
by: Tull Clancey | last post by:
Does anyone have, or can anyone suggest a URL for code to drag a control around a form at run time? VB.Net 2003. I have written stuff in VB6 to do this before, but a long time ago and I don't...
0
by: ravishankar Maduri | last post by:
Hi Freinds if any one knows how to disable the dragging of images to the address bar In my project i implemented the dragging feature by using the cropped images, its working finebut when we...
4
by: kimiraikkonen | last post by:
Hi, On my system which is 2.4GHZ P4 CPU, 1GB memory + 64MB DDR graphic card, if i create a simple picturebox docked on a form sized about 500x350 or less or more, doesn't matter, and also if i...
2
EinToR
by: EinToR | last post by:
I'm trying to set the opacity = .50 when dragging a windows form. Here's what I've got: public Form1() { InitializeComponent(); this.Move += new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.