Now in order to better see the effect of the script you should add a second frame to your movie and put a large image file so that you have the time to watch it load. Press Ctrl+Enter twice in order to simulate loading using the Show Streaming feature.
We've approximated our circle mask with a collection of 100 triangles with a sharp angle of 3.6 degrees. In order to keep track with what we've drawn and what we have not we set up two vars: loaded and oldLoaded. Then on each frame the enterFrame event is called: all triangles with numbers between the value oldLoaded and loaded are the drawn.
The drawing takes place inside the addSlice function. It uses the relations derived above to get the coordinates of each of the corners of the triangle. It then draws it using the same functions as before. By now you should be familiar with the standard procedure: set up an empty movie clip, set it as the mask of a target, then draw some shapes in it. Before I finish I should mention the use of _root.mask._yscale = -100. On a computer screen the positive y-axis does down, while in the Cartesian system it goes up. Therefore a reflection about the horizontal axis is necessary in order to keep our angle relations valid.
Conclusion
You now have plenty of tools for creating all kinds of masking effects. In this tutorial I've willfully avoided the more complex aspects of the drawing API such as drawing curves. This was done in order to show you that using the drawing API in drawing masks was really quite simple and natural.
If you've enjoyed this tutorial, please take the time to visit dakar.netqcca.com. I am participating in a project in international development in May and am in dire need of funding. I'm organizing an actionscript-o-thon and also accepting donations. See the URL above for details. Thanks.
| » Level Advanced |
|
Added: 2004-03-26 Rating: 8 Votes: 15 |
| » Author |
| Always looking for a new challenge, I'm going to Senegal this summer to lend my computer skills in a volunteering project. I'm sending you this tutorial as part of my fundraising campaign, see http://dakar.netqcca.com . Enjoy! |
| » Download |
| Download the files used in this tutorial. |
| Download (461 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!