Posts

Showing posts from August, 2008

Flash CS3 - Text With Blur Effect - (Move your mouse over the text !!)

Move your mouse over the text !! ActionScript Code: stage.frameRate=30; var dragFactor:Number=.15; var newFormat:TextFormat = new TextFormat(); newFormat.size=20; newFormat.bold=true; newFormat.color=0xFF0000; newFormat.align=TextFormatAlign.LEFT; var MyTextField = new TextField(); MyTextField.text="AS3 ROCKS!!"; MyTextField.width=200; MyTextField.selectable=false; MyTextField.setTextFormat(newFormat); addChild(MyTextField); stage.addEventListener(Event.ENTER_FRAME,MOUSE_MOVE_Handler); function MOUSE_MOVE_Handler(e:Event):void { var xPos:Number=mouseX; var yPos:Number=mouseY; xPos=MyTextField.x; xPos -= (xPos-mouseX) * this.dragFactor; yPos=MyTextField.y; yPos -= (yPos-mouseY) * this.dragFactor; MyTextField.x=xPos; MyTextField.y=yPos; MyTextField.filters=[new BlurFilter(Math.abs(xPos-mouseX),Math.abs(yPos-mouseY),1)]; }

Flash CS3 - Sliding Menu

Download SlidingMenu.zip import fl.transitions.Tween; import fl.transitions.easing.*; import fl.transitions.TweenEvent; var i = new int; var MyRoot = root; //edit this no var BoxSize:Number = 100; //edit this no var BoxNum:Number = 4; var MainMenu = createManu(); var MenuMask = createBox(BoxSize,0xFFCC00); MainMenu.mask = MenuMask; MainMenu.animation=1; function createManu():MovieClip { var menu = new MovieClip(); for (i=0; i<BoxNum; i++) { var MenuItem = createBox(BoxSize,0xFFCC00/i); menu.addChild(MenuItem); MenuItem.x=BoxSize*i; var newFormat:TextFormat = new TextFormat(); newFormat.size=BoxSize; newFormat.color=0xFFFFFF; newFormat.align = TextFormatAlign.CENTER; var target = MenuItem.getChildAt(0); target.text = i; target.width = BoxSize; target.height = BoxSize; target.x=0; target.y=0; target.selectable = false; target.setTextFormat(newFormat); target.mouseEnabled = false; MenuItem.id=i; MenuItem.addEventListener(MouseEvent.CLICK,ClickHandler); MenuItem.buttonMode = true; }

Flash CS3 - Drag And Drop (Simple Game)

Download DragAndDrop.zip Paste this code in your AS panel . You dont need to create anything on the stage import fl.transitions.Tween; import fl.transitions.easing.*; stage.frameRate=30; var TargetCircle = CreateCircle(0x00FF00,100); TargetCircle.x=250; TargetCircle.y=200; addChild(TargetCircle); var SmallCircle = CreateCircle(0xFF6600,10); SmallCircle.x=50; SmallCircle.y=200; SmallCircle.buttonMode = true; SmallCircle.addEventListener(MouseEvent.MOUSE_DOWN,DOWNHandler); SmallCircle.addEventListener(MouseEvent.MOUSE_UP,UPHandler); addChild(SmallCircle); function DOWNHandler(e:MouseEvent) { e.target.startDrag(); } function UPHandler(e:MouseEvent) { e.target.stopDrag(); if (SmallCircle.hitTestObject(TargetCircle)==false) { TweenHandler(); } } function CreateCircle(color:Number,radius:Number):MovieClip { var circle:MovieClip = new MovieClip; circle.graphics.beginFill(color,1); circle.graphics.drawCircle(0,0,radius); circle.graphics.endFill(); return circle; } function TweenHandler() { var

Flash CS3 - Rotating Sunrays Animation

Copy and paste this AS3 code to the first frame of your flash CS3 document . You don't need to create anything on the stage ActionScript Code: function CreateRays():Shape { var ray:Shape = new Shape(); ray.graphics.beginFill(0xFF9900,.5); ray.graphics.lineStyle(1,0xFF9900,.5); ray.graphics.lineTo(600,-20); ray.graphics.lineTo(600,20); ray.graphics.lineTo(0,0); ray.graphics.endFill(); return ray; } var sun:Shape = new Shape(); sun.graphics.beginFill(0xFF9900,1); sun.graphics.drawCircle(0,0,30); sun.graphics.endFill(); //edit this no to change the no of rays :-) var SunaRays:Number=25; var rayShapes = new Shape(); var SunGlow:MovieClip = new MovieClip(); for (var i:int = 1; i<=SunaRays; i++) { rayShapes=CreateRays(); rayShapes.rotation=360/(SunaRays)*i; SunGlow.addChild(rayShapes); } SunGlow.addChild(sun); addChild(SunGlow); SunGlow.x=stage.stageWidth/2; SunGlow.y=stage.stageHeight/2; //you can change fps here stage.frameRate=30; stage.addEventListener(Event.ENTER_F

Flash CS3 - Flash website with a simple preloader

download preloader.zip ////////////////////////////////// stop(); var Circle = new Shape(); Circle.graphics.lineStyle(5,0x00FF00); Circle.graphics.drawCircle(100, 100, 50); var Line = new Shape(); Line.graphics.lineStyle(5,0x00FF00); Line.graphics.lineTo(0,-40); Line.x=100; Line.y=100; var Status = new TextField(); Status.autoSize =TextFieldAutoSize.CENTER; Status.selectable = false; Status.y = 100; Status.x = 100; addChild(Circle); addChild(Line); addChild(Status); function PreLoader() { this.loaderInfo.addEventListener(Event.COMPLETE, initApplication); this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress); } function showProgress(theProgress:ProgressEvent):void { var percent:Number =(theProgress.bytesLoaded) / (theProgress.bytesTotal)*100; Line.rotation=percent*3.6; Status.text = Math.round(percent)+" %"; } function initApplication(myEvent:Event):void { removeChild(Circle); removeChild(Line); removeChild(Status); gotoAndStop("frm_main"); } PreLoa

Flash CS3 - AS3 Counter

Copy and paste this AS3 code to the first frame of your flash CS3 document . You don't need to create anything on the stage import fl.transitions.Tween; import fl.transitions.TweenEvent; import fl.transitions.easing.*; var counter:int = 0; var MyFormat:TextFormat=new TextFormat; MyFormat.bold=true; MyFormat.font="Arial"; MyFormat.size=50; MyFormat.color=0x000000; function createShape():MovieClip { var shape = new MovieClip(); var shapeBG = new MovieClip(); var shapeMask = new MovieClip(); var shapeText = new TextField(); shapeText.defaultTextFormat=MyFormat; shapeText.text="0"; shapeText.autoSize =TextFieldAutoSize.CENTER; shapeText.selectable = false; shapeText.name = "shapeText"; shapeText.y = -5; shapeText.x = 10; shapeText.mask = shapeMask; shapeText.name = "shapeText"; shapeBG.graphics.beginFill(0xE6E6E6, 1); shapeBG.graphics.drawRoundRect(0, 0, 50, 50, 25, 25); shapeBG.graphics.endFill(); shapeBG.name = "shapeBG"; shapeMas

Flash CS3 - Random Image Loader With Progress Bar

ImageLoader.zip package { import flash.display.*; import flash.events.*; import flash.net.*; import flash.text.*; import fl.controls.*; import fl.transitions.Tween; import fl.transitions.easing.*; public class ImageLoader extends Sprite { var imageLoader:Loader = new Loader(); var imagesArr:Array=new Array("image1.jpg","image2.jpg","image3.jpg","image4.jpg","image5.jpg"); var mc_ProgressBar:MovieClip = new MovieClip(); var StatusBar:MovieClip = new MovieClip(); var txtStatus:TextField = new TextField(); var LoadBtn = new Button(); public function ImageLoader():void { addChild(imageLoader); addChild(mc_ProgressBar); addChild(LoadBtn); LoadBtn.y=270; LoadBtn.label ="Load Image"; LoadBtn.width = 80; imageLoader.alpha=0; DrawProgressBar(); imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler); LoadBtn.addEvent