/** * 25-Line ActionScript Contest Entry * * Project: Falling Leaves * Author: Jeremy P. Holland * Date: 11/15/2008 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ // 3 free lines! Alter the parameters of the following lines or remove them. // Do not substitute other code for the three lines in this section [SWF(width=550, height=400, backgroundColor=0xffffff, frameRate=24)] stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; // 25 lines begins here! var leafVector:Vector. = new Vector.(); var leafAttVector:Vector. = new Vector.(); var counter:int = 0; for (var i:int = 0; i < 20; i++) { leafVector.push(addChild(new Sprite())); leafVector[i].rotation = leafVector[i].rotationX = leafVector[i].rotationY = Math.random()*360; leafVector[i].x = Math.random()*stage.stageWidth; leafVector[i].y = -100; leafAttVector.push({angleX:0,angleY:0,centerX:Math.random()*stage.stageWidth,centerY:Math.random()*-stage.stageHeight,rangeX:Math.random()*100 + 100,rangeY:Math.random()*30 + 20,rotSpeed:Math.random()*5}); var timer:Timer = new Timer(Math.random()*3500,1); timer.addEventListener(TimerEvent.TIMER,handleLeafFallStart); timer.start();} function handleLeafFallStart(e:TimerEvent) { leafVector[counter].graphics.beginFill(0x000000); leafVector[counter].graphics.drawEllipse(0,0,40,20); leafVector[counter].addEventListener(Event.ENTER_FRAME,handleLeafFall); counter++;} function handleLeafFall(e:Event):void { e.target.rotationX = e.target.rotationY = e.target.rotation += leafAttVector[leafVector.indexOf(e.target as Sprite)].rotSpeed; e.target.x = leafAttVector[leafVector.indexOf(e.target as Sprite)].centerX + Math.sin(leafAttVector[leafVector.indexOf(e.target as Sprite)].angleX)*leafAttVector[leafVector.indexOf(e.target as Sprite)].rangeX; e.target.y = leafAttVector[leafVector.indexOf(e.target as Sprite)].centerY + Math.sin(leafAttVector[leafVector.indexOf(e.target as Sprite)].angleY)*leafAttVector[leafVector.indexOf(e.target as Sprite)].rangeY; leafAttVector[leafVector.indexOf(e.target as Sprite)].angleX += .07; leafAttVector[leafVector.indexOf(e.target as Sprite)].angleY += .14; leafAttVector[leafVector.indexOf(e.target as Sprite)].centerY += 1; ((leafAttVector[leafVector.indexOf(e.target as Sprite)].centerY - leafAttVector[leafVector.indexOf(e.target as Sprite)].rangeY - (e.target.height/2)) > stage.stageHeight)?leafAttVector[leafVector.indexOf(e.target as Sprite)].centerY = -40:null;} // 25 lines ends here!