get Random Number Between using Actionscipt AS3

Posted by druva | Flash, as3, utils | Tuesday 2 February 2010 12:03 am

The below code shows how to use the class


import druva.NumberUtil;
trace(NumberUtil.getRand(5, 10));

This is the actual class for validation


package druva{
	import flash.display.Sprite;

	public class NumberUtil extends Sprite {
		public function NumberUtil() {
		}

		public static function getRand(min:Number, max:Number):Number {
			return Math.floor(Math.random()*(max+1-min))+min;
		}

	}
}
 

Load Date from XML File using flash actionscript AS3

Posted by druva | Experiments, Flash, Flex, as3, utils | Wednesday 27 January 2010 1:42 pm

Simple Example to show how to load xml

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    public class DocumentClass extends Sprite
    {
        private var loader:URLLoader;
        private var xmlPath:URLRequest;

        public function DocumentClass()
        {
	 xmlPath = new URLRequest("http://server.com/xml.xml")
	loader = new URLLoader(xmlPath);
            loader.addEventListener(Event.COMPLETE, completeListener);
            loader.addEventListener(ProgressEvent.PROGRESS, progressListener);
        }

        private function completeListener(event:Event):void
        {
            trace(" all done loading " + loader.data + " and here's the xml file we loaded ");
        }

        private function progressListener(event:Event):void
        {
            trace(" loading.... " + loader.bytesLoaded + " / " + loader.bytesTotal + " bytes");
        }
    }
}
 

How to use URLVariables() in Flash AS3?

Posted by druva | Flash, Flex, as3, utils | Monday 25 January 2010 10:26 pm

Using URLVariables in Flash or Flex we can send and receive data from server he is the example

This is the PHP Code nested in the server
Create a PHP file and place it in the server

<?php
 $email=$_POST['email'];
 $password=$_POST['password'];

echo "email=".$_POST['email']."&amp;password=".$password;
?>

Here is the code in Flash/Flex

//create URLRequest instace withe the target URL
var request:URLRequest = new URLRequest("http://www.example.com/data.php");

//create instance of the class
var variables:URLVariables = new URLVariables();

variables.email = druva.flash@gmail.com;
variables.password = 'dontexpectit';

//add the data to the URLRequest
request.data = variables;

//Choose a method as POST
request.method = URLRequestMethod.POST;

var loader:URLLoader = new URLLoader();
//Create EventListener
loader.addEventListener(Event.COMPLETE, handleComplete);

//send the request with URLLoader()
loader.load(request);

 function handleComplete(event:Event)  {
var loader:URLLoader = URLLoader(event.target);
var vars:URLVariables = new URLVariables(loader.data);

//Read data for the result
trace("vars.email: "+vars.email);
trace("vars.password: "+vars.password);
 }
 

Create Color Wheel using Flex (Actionscript) AS3

Posted by druva | Flash, Flex, MXML, as3, utils | Sunday 24 January 2010 9:34 am

Working on color wheel i hope it looks good.
Cick to view working sample

 

Create Color Picker like Photoshop Color Picker using Flex and Actionscript 3 (AS3)

Posted by druva | Flash, Flex, MXML, as3, utils | Friday 15 January 2010 12:30 pm

Recently started making a color picker which is similar to photoshop color picker

 

Determine Easily What Image Formats the Target Device Supports

Posted by druva | Flash, as2, as3, utils | Tuesday 22 December 2009 1:12 am

You can check before loading the image with System.capabilities

if (System.capabilities.imageMIMETypes[&quot;image/png&quot;]) {
 loadMovie(&quot;images/image.png&quot;, &quot;mc_myPngImage&quot;);
}
 

How to Draw a Circle with Flash Actionscript 3.0 – AS3

Posted by Vineela | Flash, Flex, as3, utils | Sunday 4 January 2009 1:14 pm
package druva {

 import flash.display.*;

 public class drawCircle extends Sprite {

 public function drawCircle() {
 var canvas:Shape = new Shape(  );
 canvas.graphics.lineStyle(3, 0xFF0000);
 canvas.graphics.drawCircle(100,100,50);
 addChild(canvas);

 }
 }
}