By Zevan | December 23, 2008
CLICK HERE FOR TODAY’S SNIPPET
In a recent kirupa thread, senocular posted an very useful snippet to aid in the creation of a two sided 3D MovieClip. The thread also contains an in depth description of polygon winding.
Description of Polygon Winding
I created a navigation demo using this technique.
Here is the source for the above demo
UPDATE
Justin Windle of soulwire has written a nice class called PaperSprite that uses this technique. The class is worth checking out - it’s nicely designed… read more about it here.
By Zevan | December 22, 2008
Actionscript:
-
var colors:Array = [0xFF0000, 0x666699, 0x223322, 0xCCCCDD, 0xFFEEFF];
-
var alphas:Array = [0, 1, 1, 1, 1];
-
var ratios:Array = [0, 50, 100, 200, 255]
-
var filter:GradientGlowFilter = new GradientGlowFilter(0, 0, colors, alphas, ratios, 30, 30, 1, 2, "full", true);
-
-
var circles:Shape = new Shape();
-
-
for (var i:int = 0; i<30; i++){
-
with(circles.graphics) beginFill(0xFF0000), drawCircle(Math.random()*500, Math.random()*400,10+Math.random()*40);
-
}
-
addChild(circles);
-
-
circles.filters = [filter];
I don't see GradientGlowFilter used much. But with some tweaking you can probably get some decent stuff out of it.
By Zevan | December 21, 2008
Actionscript:
-
mc.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
-
function onRollOver(evt:MouseEvent):void {
-
addChild(MovieClip(evt.currentTarget));
-
}
This one is very simple, but it's important to note that using addChild() on something that is already on the display list simply brings it to the top. Back in AS2 we used to do:
By Zevan | December 20, 2008
Actionscript:
-
var currentBtn:MovieClip;
-
-
var nav:Sprite = new Sprite();
-
nav.x = nav.y = 20;
-
addChild(nav);
-
-
createBtns();
-
-
nav.addEventListener(MouseEvent.CLICK, onClickBtn);
-
-
function createBtns():void{
-
for (var i:int = 0; i<10; i++){
-
var btn:MovieClip = new MovieClip();
-
with(btn.graphics) beginFill(0x666666), drawRect(-10,-10,20,20);
-
btn.x = i * (btn.width + 10);
-
btn.buttonMode = true;
-
btn.num = i;
-
btn.alpha = .5;
-
nav.addChild(btn);
-
}
-
}
-
-
function onClickBtn(evt:MouseEvent):void {
-
//
-
// this is the important part
-
//
-
if (currentBtn){
-
currentBtn.scaleX = currentBtn.scaleY = 1;
-
currentBtn.alpha = .5;
-
}
-
currentBtn = MovieClip(evt.target);
-
currentBtn.scaleX = currentBtn.scaleY = 1.3;
-
currentBtn.alpha = 1;
-
trace("current button:", currentBtn.num);
-
//
-
}
This code will create 10 boxes that represent buttons on a navigation. When you click a box it indicates that it is selected by scaling up and changing alpha. Simple enough...
The term Procedural Pattern is just a spin on the idea of Design Patterns. I've come up with lots of small patterns to solve simple recurring problems over the years. Most of these relate to things like drawing programs, ecards and games.