Tutorials Home
What's New
Top Rated
Submit
myTutes
Random!
Create a Dynamic Drag and Drop Movie
Author: Bob Skidmore
| Website: http://www.fuzzypickle.com |
Code Movie Clip (cont)
The second function is using attachMovie to build your screen elements. You set how many elements you wanted in the variable _root.howmany now you are looping through that many times to place your targets and objects on the screen at the X Y coordinates you specified in your first function.
function placement() {
for (i = 0; i <_root.howmany; i ++) {
this._parent.attachMovie("target", "t" + i, i);
this._parent.attachMovie("object", "o" + i, i + _root.howmany);
_root["t" + i]._x = _root.targetX; setting the X placement of your target
_root["t" + i]._y = _root.targetY; setting the Y placement of your target
_root["o" + i]._x = _root.objectX; setting the X placement of your object
_root["o" + i]._y =_root.objectY; setting the Y placement of your object
_root.targetY = _root.targetY + _root.spacing; setting target spacing
_root.objectY = _root.objectY + _root.spacing; setting object spacing
}
}

<%brk%>
Code Movie Clip (cont)
The next 2 functions work together to build the arrays that hold the actual X Y positions of you targets and your objects. These arrays are used to place the objects back into position.
function x_y(my_x,my_y) {
this.my_x = my_x;
this.my_y = my_y;
}
function setcoords() {
for (var i = 0; i <_root.howmany; i++ ) {
target_array[i] = new x_y (getProperty (_root["t" + i],_x),getProperty (_root["t" + i],_y));
object_array[i] = new x_y (getProperty (_root["o" + i],_x),getProperty (_root["o" + i],_y));
cover[i] = 0
<%brk%>
Code Movie Clip (cont)
Lets see how these work together…..

| » Level Intermediate |
|
|
Added: : 2000-12-12
Rating: 6.40 Votes: 124
Hits: 2558
|
| » Author |
|
No information about the author has been provided
|
| » Download |
|
Download the files used in this tutorial.
|
|
Download (65 kb)
|
|
Get conversion and unzipping tools
for PC and Mac here!
|
| » Forums |
|
More help? Search our boards for quick answers!
|
|
Please rate this tutorial, 10 is the top rating, you can also click the
comments link to read/write a review.
|
|
|