Just completed the Inigo Montoya’s tutorial on scripting mask. (Very nice). However, I noticed two things I wanted to improve on.
First:
The camera gadget movie clip slides beyond the bounds of the the pictures. I modified the script in the following way:
//------------------------------------------------------
onClipEvent(enterFrame){
getlimits=_root.normalpic.getBounds(_root);
if(_root._xmouse>=getlimits.xMin + 60 &&
_root._xmouse<=getlimits.xMax - 60 &&
_root._ymouse>=getlimits.yMin &&
_root._ymouse<=getlimits.yMax){
this._x=_root._xmouse;
}
}
I added (and subtracted) 60 pixels from the x coordinates and it works. But is this is good scripting technique or not?
Second:
The slider always loads to the far left outside of the bounds of the picture until the pointer enters the movie. How would one correct this??
Adding and subtracting 60 pixels should be okay: if it works, it works! The only reason (that I can think of) one would want to avoid this is because you don’t know how big or small the clip being masked is. Suppose you used this script for another movie, one where that 60 pixel padding was needed. In that case you might find your mask too small to cover everything. That’s why using getBounds() will work for any clip, no matter how big or small it is (although, as you’ve probably noticed, getBounds() can tend to be slightly inaccurate). The idea is have your scripts be as portable as possible: if you can write scripts that you can use again and again without having to modify a single line of the code, then that’s excellent scripting.
I glanced at the tutorial quickly, so I may be wrong on this, but it looks like you author the movie to have the square slider begin on the far left. So when the movie is published, that’s where it appears. You can have it move wherever you want it to in the authoring tool, and when the movie is published, that’s where the clip will be. Or you can add some actionscript at the beginning of the movie that will place the clip at the x, y coordinates you want it: