-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.as
99 lines (81 loc) · 2.6 KB
/
Main.as
1
// BlendModes// Author : Andy Lyon// Date : 11/04/2008//// This work is licensed under a Creative Commons 2.0 License.//// Full details at// http://creativecommons.org/licenses/by/2.0/uk/package { import flash.display.*; import flash.events.*; import flash.text.*; import flash.filters.*; import gs.TweenLite; import fl.motion.easing.Elastic; import flash.utils.*; public class Main extends Sprite { private var size:Number = 100; private var firstSprite:Sprite; private var secondSprite:Sprite; private var thirdSprite:Sprite; private var holderSprite:Sprite; public function Main() { init(); } private function init():void { // Run Init funtions initGraphics(); initListeners(); } private function initGraphics():void { // Make the circles... holderSprite = new Sprite(); holderSprite.x = stage.stageWidth * 0.5; holderSprite.y = stage.stageHeight * 0.5; firstSprite = new Sprite(); firstSprite.graphics.beginFill(0xFF0000); firstSprite.graphics.drawCircle(0, 0, size); firstSprite.graphics.endFill(); holderSprite.addChild(firstSprite); secondSprite = new Sprite(); secondSprite.graphics.beginFill(0x00FF00); secondSprite.graphics.drawCircle(0, 0, size); secondSprite.graphics.endFill(); holderSprite.addChild(secondSprite); thirdSprite = new Sprite(); thirdSprite.graphics.beginFill(0x0000FF); thirdSprite.graphics.drawCircle(0, 0, size); thirdSprite.graphics.endFill(); holderSprite.addChild(thirdSprite); firstSprite.blendMode = BlendMode.ADD; secondSprite.blendMode = BlendMode.ADD; thirdSprite.blendMode = BlendMode.ADD; var blur:BlurFilter = new BlurFilter(3, 3, 2); var filterArray:Array = new Array(blur); holderSprite.filters = filterArray; this.addChild(holderSprite); } private function initListeners():void { holderSprite.addEventListener( MouseEvent.MOUSE_OVER, mouseOver_el ); holderSprite.addEventListener( MouseEvent.MOUSE_OUT, mouseOut_el ); } private function mouseOver_el(e:MouseEvent):void { TweenLite.to(firstSprite, 1, { x:-(size*0.5), y:-(size*0.5), ease:Elastic.easeOut} ); TweenLite.to(secondSprite, 1, { x:(size*0.5), y:-(size*0.5), ease:Elastic.easeOut} ); TweenLite.to(thirdSprite, 1, { x:0, y:(size*0.5), ease:Elastic.easeOut} ); } private function mouseOut_el(e:MouseEvent):void { TweenLite.to(firstSprite, 1, { x:0, y:0, ease:Elastic.easeOut} ); TweenLite.to(secondSprite, 1, { x:0, y:0, ease:Elastic.easeOut} ); TweenLite.to(thirdSprite, 1, { x:0, y:0, ease:Elastic.easeOut} ); } }}