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

 

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

 

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 Snowfall Easily in Flash CS4

Posted by druva | Flash, as3, utils | Thursday 31 December 2009 1:51 pm

This code show how to create snowfall in flash cs4

u can also use the code for cs3

package {

	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import druva.NumberUtil;
	import flash.utils.Timer;
	import flash.events.*;

	public class snowfall extends MovieClip {

		private var t:Timer;

		public function snowfall():void {
			t=new Timer(80);
			t.addEventListener(TimerEvent.TIMER, createParticle);
			t.start();
		}

		private function createParticle(e:TimerEvent) {

			var mc_particle:MovieClip =new MovieClip();
			mc_particle.graphics.beginFill(0xFFFFFF,1);
			mc_particle.graphics.drawCircle(0, 0, NumberUtil.getRand(3,5));
			mc_particle.graphics.endFill();

			mc_particle.x=NumberUtil.getRand(-60,600);
			mc_particle.wind = (NumberUtil.getRand(0,1) == 1) ?  'left' : 'right';
			mc_particle.filters=[new BlurFilter(10,10,2)];
			mc_particle.addEventListener(Event.ENTER_FRAME, moveParticle);
			addChild(mc_particle);

		}

		function moveParticle(e:Event):void {
			var targ:MovieClip=MovieClip(e.target);

			if (targ.y&gt;400) {
				targ.removeEventListener(Event.ENTER_FRAME,moveParticle);
				removeChild(targ);
				return;
			}

			targ.y += 1;

			if (targ.wind=='left') {
				targ.x += 0.4;
			} else if (targ.wind== 'right') {
				targ.x -= 0.4;

			}

		}

	}
}

This movie requires Flash Player 9

 

Flash as3 TextField alpha Tweening

Posted by druva | Flash, as2, as3, utils | Monday 21 December 2009 10:15 am
var tf:TextField = new TextField();
tf.text = "Hello Hello";
tf.width = 650;

var format1:TextFormat = new TextFormat();
format1.color = 0xFF0000;
format1.size = 80;

tf.setTextFormat(format1);

addChild(tf);
tf.alpha = .1;

import flash.display.BlendMode;
tf.blendMode = BlendMode.LAYER;

import fl.transitions.Tween;
import fl.transitions.easing.*;
new Tween(tf, "alpha", Elastic.easeOut, 0, 1, 200, false);
 

inverse kinematic (IK) animations

Posted by druva | uncompleted | Wednesday 18 November 2009 6:08 am

k@i@r/developer/flashcs4/using_bone_tool_shapes_pg1.htm

 

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

 

using multiple values in trace()

Posted by druva | Flash, as3, utils | Tuesday 19 May 2009 12:50 am

in as3 trace you can pass multiple values without using ‘+’ operator

var a =1;
var b=2;
var c = 3;

trace(a, b, c);
//ouput 1 2 3

 
« Previous PageNext Page »