Winter 01 | Flash(back)

duplicateMovieClip


You see three options: target, newName and Depth.
The target is the movieclip which you will duplicate. When you have made a new copy you must assign a new name, because no double instancenames may occure. The duplicate is copied in the same layer as the original MC. Flash creates within this layer new layers, this is called "depth". There can exist never more than one movieclip on a certain depth. When you nevertheless put more MC's there, flash will replace the old movieclip with the new one.

When you fill in these three options, tou wil see the following:
On (release){
         duplicateMovieClip("instancename", "newname", 10);
}
This is however not yet sufficient. Afterwards you still must modify some properties of the new movieclip. It gets, as it happens, automatic all properties of its predecessor. This means that you cannot see the new copy, because it lies exactly on top of the original. Therefore we adjust the coordinates a little.
On (release){
    duplicateMovieClip("instancename", "newname", 10);
    newname._x = 30
}  


createEmptyMovieClip

Here two MC's are used. One movie is loaded into the other. One MC is called hoofdmovie and the other laadmovie. this way you know which MC I talk about. The hoofdmovie gets for instance a button and the laadmovie a photograph or animation.

The button in the hoofdmovie has the next script:

on (release) {
   createEmptyMovieClip("movie01", 1);
   loadMovie("lmovie.swf", movie01);
   _root.movie01._x = 200;
}             

Create emptymovieclip. does what the name says already. It creates an empty movieclip to hold the loaded MC. Immediately a name is given to the MC; Movie01. This is skilful because then you can address the movieclip. It is now an ordinary component that belongs to the hoofdmovie.

The function loadMovie (); loads the MC in the hoofdmovie and says immediately that the MC must be charged in the new movieclip . Afterwards you can simply address the movieclip. For example to change the x position of the MC.


attachMovie

Except that you can duplicate a movieclip, you can also obtain a movieclip from the library by means of action script and link it to a movieclip on your stage. Because of this, you can make small and dynamic SWF's. if you have enough material in your library, you can dynamicly change your SWF under the influence of the user, or under the influence of your content. For example a menu, depending on the content it may become larger, or under the influence of the user it may look totaly different. Because your script obtains simply other components from the library. You can also use attach instead of duplicate.

The largest difference is that the object that your will copy, wil not be on the stage but in your library,
Open the properties, by clicking the right mousebutton, go to advanced and finch export for action script. Be sure to give it a good name and remember or copy it.
Now open the actionscript under the button: and replace the duplicate script for:
In this case "circle" is the linkage identifier.

on (release) {
   thing.attachMovie( "circle", "circle1", 2 ); 
}

Possibly if there is time :
Run your buttons from the time line!

btn_name.onRelease = function(){
   // put your script here 
} 
   

Array

// simple array
myList = Array("one", "two", "three");
trace(myList);
//array with variables
var one = "orange";
var two = "green";
var three = "purple";
myList = Array(one, two, three);
trace(myList);
// array with array's
een = Array("one", "two", "three");
twee = Array("orange", "green", "purple");
drie = Array("house", "tree", "beast");
myList = Array(one, two, three);
trace(myList);
//value from array 
test = one[0]; 
test = myList[0][2]; 

explanation
The first value in Array is always zero. Therefore always begin to count from zero . When you change the zero between the square hooks to 1 or 2, flash shows the second or third value from the row. This way you can always get the desired value. If there is an array in an array, then the first value between the square brackets retrieve the array, and with the second square brackets the value (1st, 2e or 3e) in that array;


Auteur: Barend Hendriks
Seizoen: winter
Lesnummer: 01
Datum: 16-10-2005
Type les: MME