Here are a few things I learnt this evening – I should have remembered them as I’ve done them all before… but over time you forget things! If only I’d been blogging back then!
1. How to load a movie clip or graphic from the library
To do this, you first must right click the object in the library and choose Linkage.
Then check the export for actionscript box
Give the object a name (best if it doesn’t have spaces)
Then to load the object in ActionScript, use the attachMovie command.
Example:
attachMovie(”headMovie”, “avatar”, this.getNextHighestDepth(), {_x:10, _y:5, _xscale:40, _yscale:40});
2. how to mirror something in actionscript
For my movie, I wanted to create a mirror image of the eyes. To do this, set the _xscale to an appropriate negative value.
3. how to append a variable name to the end of a string so that it can be used to indicate a specific variable
Use the eval command.
Example:
eval(”_root.item” + counter)
4. how to do multiple things on the one object
Use the with command.
I actually used this in conjunction with number 3 and the reason I did it is I didn’t know how to tell my actionscript to tell _root.item1, then _root.item2, then _root.item3 to go and stop and different playheads… especially when I wanted the end of the variable name to come from a variable called counter.
Example:
with (eval(”_root.item” + counter)) {
_visible=true;
attachMovie(”headMovie”, “avatar”, this.getNextHighestDepth(), {_x:10, _y:5, _xscale:40, _yscale:40});
attachMovie(”hairMovie”, “hair”, this.getNextHighestDepth()+1, {_x:10, _y:5, _xscale:40, _yscale:40});
attachMovie(”eyesMovie”, “eye1″, this.getNextHighestDepth()+2, {_x:35, _y:25, _xscale:40, _yscale:40});
attachMovie(”eyesMovie”, “eye2″, this.getNextHighestDepth()+3, {_x:30, _y:25, _xscale:-40, _yscale:40});
attachMovie(”nose”, “nose”, this.getNextHighestDepth()+4, {_x:30, _y:35, _xscale:40, _yscale:40});
attachMovie(”mouth”, “mouth”, this.getNextHighestDepth()+5, {_x:27, _y:50, _xscale:40, _yscale:40});
}