Posts

Showing posts from June, 2008

Flash CS3 - Custom Mouse Pointer

Click on each mouse pointer pointer.as package { import flash.display.*; import flash.events.*; import flash.filters.*; import flash.text.*; import flash.ui.Mouse; public class pointer extends Sprite { //you can see them on the stage var pnt_1= new Pointer_1(); var pnt_2= new Pointer_2(); var pnt_3= new Pointer_3(); //your current Mouse Pointer var CurrentPointer = new MovieClip(); var Text1:TextField = new TextField(); var Text2:TextField = new TextField(); var Text3:TextField = new TextField(); var DropShadow:DropShadowFilter = new DropShadowFilter(); public function pointer():void { //add three custom pointers on the stage AddPointers(); AddText(); //give them a shadow effect ApplyFilter(); //we use this id in function PointerListener() pnt_1.id=1; pnt_2.id=2; pnt_3.id=3; pnt_1.addEventListener(MouseEvent.CLICK, PointerListener); pnt_2.addEventListener(MouseEvent.CLICK, PointerListener); pnt_3.addEventListener(MouseEvent.CLICK, PointerListener); addChild(CurrentPointer); } private f

Flash CS3 - A Simple Game

game.as package { import flash.display.*; import flash.ui.Mouse; import flash.events.*; import flash.text.*; public class game extends Sprite { var hits:int=0; var misses:int=0; var shots:int=0; var cDepth:int=100; var level:int=1; var xSpeed:Number=3; var stageWidth:Number=550; var stageHeight:Number=300; var AirCraft_MC:MovieClip = new MovieClip(); var AimMC:MovieClip=new Aim_mc;//MovieClip to aim your gun - we import this MovieClip direct from Lib var stats_txt:TextField=new TextField;// create a text field to display the player's statistics. public function game():void { black_mc.start_btn.addEventListener(MouseEvent.MOUSE_DOWN ,StartFunction); black_mc.start_btn.buttonMode=true; } private function StartFunction(event:MouseEvent ):void { black_mc.visible =false; aim(); stats_txt_fn(); stage.addEventListener(MouseEvent.MOUSE_MOVE,HideMouse); stage.addEventListener(MouseEvent.MOUSE_DOWN,GunShot); stage.addEventListener(Event.ENTER_FRAME,addAirCrafts); } private function aim() { A

Flash CS3 and XML - Loading XML in Flash

View PersonalDetails.xml loadxml.as package { import flash.display.*; import flash.net.*; import flash.events.*; import fl.controls.DataGrid; import fl.containers.UILoader; import flash.text.*; public class loadxml extends Sprite { var xmlFile:String="PersonalDetails.xml"; var datagrid=new DataGrid; var imgLoader=new UILoader; var nameTxt=new TextField; var occupationTxt=new TextField; var ageTxt=new TextField; var emailTxt=new TextField; public function loadxml():void { callBtn.addEventListener(MouseEvent.CLICK,callServer); } function callServer(e:MouseEvent):void { var urlRequest:URLRequest=new URLRequest(xmlFile); var loader:URLLoader=new URLLoader; loader.addEventListener(Event.COMPLETE,xmlLoaded); loader.load(urlRequest); } function xmlLoaded(e:Event):void { var loader:URLLoader=URLLoader(e.target); var xml:XML=new XML(loader.data); createDataGrid(); createTextFields(); createImageLoader(); // loop through the details and insert each one into the DataGrid for each (var i

Flash CS3 and PHP - File Upload

ActionScript 3 package { import flash.display.Sprite; import flash.text.TextField; import flash.events.*; import flash.net.*; import fl.controls.Button; public class FileUpload extends Sprite { private var _output:TextField; private var _fileReference:FileReference; var browseButton:Button = new Button(); var uploadButton:Button = new Button(); public function FileUpload() { browseButton.move(10, 30); browseButton.buttonMode = true; browseButton.label = "Browse"; browseButton.addEventListener(MouseEvent.CLICK, browseHandler); addChild(browseButton); uploadButton.move(120,30); uploadButton.buttonMode=true; uploadButton.label ="Upload"; uploadButton.addEventListener(MouseEvent.CLICK, uploadHandler); uploadButton.visible = false; addChild(uploadButton); _output = new TextField(); _output.width = 400; _output.height = 400; _output.y = 75; addChild(_output); _fileReference = new FileReference(); _fileReference.addEventListener(Event.SELECT, selectHandler); _fileReference

Flash CS3 and PHP - Send and Receive data

Codes sendtophp.as package { import flash.display.*; import flash.events.*; import flash.net.*; import flash.text.*; public class sendtophp extends Sprite { var phpFile:String = "sendDataToServer.php"; public function sendtophp():void { callBtn.addEventListener(MouseEvent.CLICK, callServer); } function callServer(e:MouseEvent):void { var urlRequest:URLRequest = new URLRequest(phpFile); var urlParams:URLVariables = new URLVariables(); urlParams.sampleVal = sendTxt.text; urlRequest.method = URLRequestMethod.POST; urlRequest.data = urlParams; var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, serverResponse); loader.load(urlRequest); } function serverResponse(e:Event):void { var loader:URLLoader = URLLoader(e.target); var variables:URLVariables = new URLVariables(loader.data); responseTxt.text = variables.returnValue; } }//end of class sendtophp }//end of package sendDataToServer.php < ? php print "returnValue= Hi ".$_POST['sampleVal