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;
		}

	}
}
 

BlurFilter for Images using Flash ActionScript

Posted by druva | Flash, Flex, as2, as3, utils | Saturday 30 January 2010 12:44 pm
package {

import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.geom.*;
import flash.events.*;
import flash.filters.*;

public class DocumentClass_blurfilter extends MovieClip {

private var urlLoader:URLLoader = new URLLoader();
private var mc:MovieClip = new MovieClip();

public function DocumentClass_blurfilter() {
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load(new URLRequest('http://www.totusinfo.com/blogsamples/rotary-phone1.jpg'));
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
blurX.addEventListener(Event.CHANGE , onChange);
blurY.addEventListener(Event.CHANGE , onChange);
}

private function completeHandler(event:Event):void {
var loader:Loader = new Loader();
loader.loadBytes(urlLoader.data);

mc.addChild(loader);
addChild(mc);

blurX.value = 10;
blurY.value = 10;

blurX.minimum = 0;
blurY.minimum = 0;

blurX.maximum = 100;
blurY.maximum = 100;

Blur_Filter();
}

private function onChange(e:Event) {
Blur_Filter();
}

private function Blur_Filter() {
var blur:BlurFilter = new BlurFilter();
blur.blurX=blurX.value;
blur.blurY=blurY.value;
blur.quality=BitmapFilterQuality.LOW;
mc.filters=[blur];
}
}
}

(more…)

 

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 Text Effects in Flash and AS3 (Actionscript 3.0)

Posted by druva | Flash, as3, utils | Thursday 7 January 2010 3:45 pm

Just playing with Text and this is my first version of text effects

This movie requires Flash Player 9

sample 0.1

 

Create Rounded Corners Rectangle with Actionscript 3.0 – AS3

Posted by druva | Flash, Flex, as3, utils | Saturday 7 November 2009 8:14 am

Rounded Corner Rectangle

import flash.display.*;

function round_rectangle(){

var shape:Shape = new Shape();
addChild(shape);

shape.graphics.beginFill(0xFF0000FF, 1.0);

shape.graphics.drawRoundRect(50, 10, 200, 100, 30, 30);

shape.graphics.endFill();
}

round_rectangle();

(more…)

 

How to Draw a Square with Flash Actionscript 3.0 – AS3

Posted by druva | Flash, as3, utils | Monday 5 January 2009 1:03 pm

simple Example to draw square using flash actionscript

this example show how to use lineStyle, drawRect, Shape

package druva {

import flash.display.*;

public class drawSquare extends Sprite {

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

}
}
}