Drag

11 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€64.82
List Price:  €92.61
You save:  €27.78
£55.75
List Price:  £79.64
You save:  £23.89
CA$95.67
List Price:  CA$136.67
You save:  CA$41
A$105.86
List Price:  A$151.24
You save:  A$45.37
S$94.70
List Price:  S$135.29
You save:  S$40.59
HK$546.72
List Price:  HK$781.06
You save:  HK$234.34
CHF 63.51
List Price:  CHF 90.74
You save:  CHF 27.22
NOK kr756.09
List Price:  NOK kr1,080.17
You save:  NOK kr324.08
DKK kr483.66
List Price:  DKK kr690.98
You save:  DKK kr207.31
NZ$116.24
List Price:  NZ$166.07
You save:  NZ$49.82
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳8,184.61
List Price:  ৳11,692.81
You save:  ৳3,508.19
₹5,845.20
List Price:  ₹8,350.65
You save:  ₹2,505.44
RM330.31
List Price:  RM471.90
You save:  RM141.58
₦104,423.68
List Price:  ₦149,183.08
You save:  ₦44,759.40
₨19,463.92
List Price:  ₨27,806.80
You save:  ₨8,342.87
฿2,565.83
List Price:  ฿3,665.63
You save:  ฿1,099.80
₺2,257.71
List Price:  ₺3,225.44
You save:  ₺967.73
B$360.94
List Price:  B$515.65
You save:  B$154.71
R1,287.99
List Price:  R1,840.06
You save:  R552.07
Лв126.81
List Price:  Лв181.17
You save:  Лв54.35
₩95,704.32
List Price:  ₩136,726.31
You save:  ₩41,021.99
₪259.82
List Price:  ₪371.20
You save:  ₪111.37
₱4,043.91
List Price:  ₱5,777.27
You save:  ₱1,733.35
¥10,948.60
List Price:  ¥15,641.53
You save:  ¥4,692.93
MX$1,174.48
List Price:  MX$1,677.91
You save:  MX$503.42
QR255.13
List Price:  QR364.49
You save:  QR109.35
P950.42
List Price:  P1,357.81
You save:  P407.38
KSh9,133.69
List Price:  KSh13,048.69
You save:  KSh3,915
E£3,278.83
List Price:  E£4,684.25
You save:  E£1,405.41
ብር4,017.07
List Price:  ብር5,738.92
You save:  ብር1,721.84
Kz58,375.85
List Price:  Kz83,397.65
You save:  Kz25,021.80
CLP$64,738.65
List Price:  CLP$92,487.75
You save:  CLP$27,749.10
CN¥506.34
List Price:  CN¥723.38
You save:  CN¥217.03
RD$4,071.75
List Price:  RD$5,817.04
You save:  RD$1,745.28
DA9,401.76
List Price:  DA13,431.66
You save:  DA4,029.90
FJ$157.21
List Price:  FJ$224.60
You save:  FJ$67.38
Q543.50
List Price:  Q776.46
You save:  Q232.96
GY$14,642.77
List Price:  GY$20,919.14
You save:  GY$6,276.37
ISK kr9,755.90
List Price:  ISK kr13,937.60
You save:  ISK kr4,181.70
DH702.55
List Price:  DH1,003.69
You save:  DH301.13
L1,243.38
List Price:  L1,776.34
You save:  L532.95
ден3,995.02
List Price:  ден5,707.42
You save:  ден1,712.39
MOP$562.80
List Price:  MOP$804.03
You save:  MOP$241.23
N$1,285.58
List Price:  N$1,836.62
You save:  N$551.04
C$2,575.01
List Price:  C$3,678.75
You save:  C$1,103.73
रु9,348.21
List Price:  रु13,355.17
You save:  रु4,006.95
S/259.92
List Price:  S/371.34
You save:  S/111.41
K271.44
List Price:  K387.79
You save:  K116.35
SAR262.48
List Price:  SAR374.99
You save:  SAR112.50
ZK1,799.51
List Price:  ZK2,570.84
You save:  ZK771.33
L322.59
List Price:  L460.87
You save:  L138.27
Kč1,603.70
List Price:  Kč2,291.10
You save:  Kč687.39
Ft25,046.65
List Price:  Ft35,782.47
You save:  Ft10,735.81
SEK kr759.74
List Price:  SEK kr1,085.39
You save:  SEK kr325.65
ARS$61,888.08
List Price:  ARS$88,415.34
You save:  ARS$26,527.25
Bs483.35
List Price:  Bs690.53
You save:  Bs207.18
COP$271,323.12
List Price:  COP$387,621.07
You save:  COP$116,297.95
₡35,845.23
List Price:  ₡51,209.67
You save:  ₡15,364.43
L1,728.98
List Price:  L2,470.08
You save:  L741.10
₲525,197.80
List Price:  ₲750,314.73
You save:  ₲225,116.93
$U2,696.53
List Price:  $U3,852.35
You save:  $U1,155.82
zł276.95
List Price:  zł395.67
You save:  zł118.71
Already have an account? Log In

Transcript

Hello, and welcome to our Ohio media's new video tutorial. This tutorial is all about object oriented start and stop drag ActionScript in Adobe Flash so let's get started. Jump into flash and create any shape and converted into a movie clip. we name it object and keep its registration point to exact center. This movie clip or say object is supposed to be dragged on mouse click. That means this object will need an instance name for ActionScript.

We name it as object underscore MC, also name its layer as object. Add a New Layer named buttons where the actual start drag and stop drag buttons will be pleased. Get the button from Window menu components you The interface and place it on the stage. Again, visit windows menu, component Inspector, or simply press Shift plus f7 shortcut key and change its level. To start drag. give it an instance name, drag underscore btn.

Add one more layer as action, where we will start giving actions to the button. Select action layers blank frame and press f9 for the action panel, get started with the function to happen. Within the curly brackets introduced the object which is to be dragged for that objects instance name is used, which is the identity of that object. Then type the action on the button on which the about function will take place. Now, test the movie. And yes, after the click on Star drag button, the object starts moving along with the mouse from its current position.

So this is done. But this way, the object will keep moving along with mouse. So, we'll also learn how to stop that dragging using one more button. For that, get one more button on the button land and change its level to stop drag. Also give it an instance name as drag, underscore stop underscore btn. Now, time to open the action panel again, to apply the function of stop drag.

Object underscore MC should get stopped. No apply this function to drag underscore stop underscore btn That's the movie now. The object starts moving on one click of the start drag button and stops dragging on one click of the stop drag button. Note that onstop the object doesn't go to its default position to stop, but stops at its current position. It's done successfully. Now, do the important steps of all that is save you a file, we name it, drag underscore 01.

Now, we have seen how to drag the object along with the mouse and also how to stop it. Now, let's see one more style of dragging of the object where the object gets attached to the center of the mouse. On the buttons. Click That means the object movie clip will get bound with the mouse. The start is the same. Get a movie clip of any object on one layer and a button on another layer.

On the third action layer, the action script will be added. Open the action panel and start with the function. Now, in curly brackets, after start drag, you see the option available of lock center which can be applied by true or false value. We keep it true as we want to bind the object to the mouse and now apply that function to that button. This the movie. On one click of the button, the object gets bound with the mouse to its center and gets dragged along with the mouse.

So adding a small change of lock center value in the ActionScript gives you a different style of object drag output. We are not finished yet. create one more Flash file to see how to drag any movie clip within a decided boundary. Start with a layer named object and draw an object. We take a circle keep its width and height to exact 50 by 50 pixels. Similarly, set it's excellent Y coordinates x equals to 150 and y equals to 200.

Now convert this object into a movie clip, check its registration point is on the top left corner, name it object. Select the object and provide an instance name to it, object underscore MC. We need to draw a boundary named the layer as boundary and draw a rectangle on the stage. Remove the fill color and keep the outline says boundary. Set the rectangle parameters to width equal to 250 pixels height equal to 150 pixels and also set the XY coordinates x equals to 150 Y equals to 200. These x y coordinates are similar to the objects XY coordinates.

That means the object and boundary start at the same point, and the object movie clip should drag only within this boundary. So, let's start with the action script part. Add a new layer as action and press f9 for action panel. Write the function first. In this, we don't want to use lock center. So give it a false value.

To drag the object within a boundary, let's set an attribute new rectangle and then in open brackets type the rectangle values start with the x coordinates value, where the rectangle begins that is 150 then the y coordinates value where the rectangle begins that is 200 then the width of the rectangle that is 200 and at last the height of the rectangle that is 150. We are setting these values which are supposed to be bounding area values for the object. So, logically to move the object within that area, the objects width and height should also be calculated. So, we will minus the objects 50 by 50 pixels width and height values from rectangles width and height. So, now, the ActionScript the vast Have the new rectangle changes to 201 hundred x&y coordinate values remains the same. Moving ahead let's add an event listener to call the abound function on object underscore MC.

This the movie on object click, the object is moving along with the mouse but not leaving it set boundary area in any direction. So the calculation we did was absolutely perfect. We kept the x&y coordinates for the object and boundary same and to set the dragging area, actual objects width and height was also calculated in the boundaries width and height. The output is pretty good. Hope this animation was fun. Thank you for watching this video tutorial presented by our Roja media.

See you next time with some more ActionScript material. Till then keep exploring

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.