How to use BlurFilter with flash actionscript

Posted by druva | Flash, Flex, JS, as3, utils | Thursday 28 January 2010 1:38 pm

Simple Example to show How to use BlurFilter

example

import flash.display.*;
import flash.filters.*;

var _rectData:BitmapData = new BitmapData(200, 200);

function drawRectangle():void {
	_rectData.fillRect(new Rectangle(40, 0, 150, 150), 0xFF0000FF);

	var rect:Sprite = new Sprite();
	addChild(rect);

	var bitmap:Bitmap = new Bitmap(_rectData);
	rect.addChild(bitmap);
}

function Blur_Filter() {
	drawRectangle();
	var filter:BitmapFilter = getBitmapFilter();
	var myFilters:Array = new Array();
	myFilters.push(filter);
	filters = myFilters;
}

function getBitmapFilter():BitmapFilter {
	var blurX:Number = 60;
	var blurY:Number = 60;
	return new BlurFilter(blurX, blurY, BitmapFilterQuality.HIGH);
}

Blur_Filter();

(more…)

 

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

 

Flash CS4 Text Effects 0.2

Posted by druva | Flash, Flex, as3, utils | Thursday 14 January 2010 2:03 pm

Just playing with Text this is my first update for the previous post
view previous post

This movie requires Flash Player 9

sample 0.2

 

Validate Email without RegExp in AS2 and AS3 in Flash

Posted by druva | Flash, Flex, as2, as3, utils | Tuesday 5 January 2010 12:22 am

The below code shows how to use the class


import druva.emailValidator;

trace('druva.flash@gmail.com &gt; '+emailValidator.isValid('druva.flash@gmail.com'));
// true
trace('druva.flash@gmail &gt; '+emailValidator.isValid('druva.flash@gmail'));
// false
trace('druva.@.com &gt; '+emailValidator.isValid('druva.@.com'));
//false
trace('druva.@gmail.com &gt; '+emailValidator.isValid('druva.@gmail.com'));
//true
trace('.aa@gmailcom &gt; '+emailValidator.isValid('.aa@gmailcom'));
//false

This is the actual class for validation


package druva {
  import flash.display.Sprite;

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

    public static function isValid(em:String):Boolean {

        var sEmail:String = new String(em);
        var validEmail:Boolean = true;
        var numDotPos:int = sEmail.indexOf(&quot;@&quot;);
        var nDotIndex:int = sEmail.lastIndexOf(&quot;.&quot;);
        if(numDotPos == -1 || nDotIndex == -1) {
          validEmail = false;
        }
        if(!(numDotPos &gt; 0)) {
          validEmail = false;
        }
          if(!(nDotIndex &gt; numDotPos)) {
        validEmail = false;
        }
        if(!(numDotPos &lt; sEmail.length - 1) || !(nDotIndex &gt; numDotPos + 1)) {
          validEmail = false;
        }
        return validEmail;
    }

  }
}
 

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…)

 

draw Ellipse with flash action script

Posted by Vineela | Flash, Flex, as3, utils | Saturday 20 June 2009 7:26 am
package druva {

 import flash.display.*;

 public class drawEllipse extends Sprite {

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

 }
 }
}

(more…)

 

isBetween Number validation for as3

Posted by druva | Flash, Flex, as2, as3, utils | Thursday 14 May 2009 1:33 am

The below code shows how to use the class


import druva.NumberUtil;
trace(NumberUtil.isBetween(5, 10,100));
// 10

trace(NumberUtil.isBetween(5, 10,100, 50));
// 50

This is the actual class for validation


package druva{
	import flash.display.Sprite;

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

		public static function isBetween(number:Number, min:Number, max:Number, def:Number=0):Number {
				return ((number >= min ) && (number <= max )) ? number : ((def == 0) ? min : def);
		}

	}
}
 
« Previous PageNext Page »