Layout Types Available in Flex 4.5 for mobile Development

Here is the list of Layout types available for the layout development

DataGroup
Group
HGroup
Scroller (supports touch scrolling, includes scroll indicator)
Spacer
TileGroup
VGroup

Controls Available in Flex 4.5 for mobiles

Hi All,

Here is the list of controls available in Flex 4.5 for mobiles.

BusyIndicator
Button
ButtonBar
CheckBox
HSlider
Image
Label
List
RadioButton / RadioButtonGroup
TextArea
TextInput

Get Even or Odd – getParity using Action Script AS

The below code shows how to use the class


import druva.NumberUtil;

trace('500', NumberUtil.getParity(500));
// true
trace('489', NumberUtil.getParity(489));
// false
trace('5', NumberUtil.getParity(5));
//false
trace('1', NumberUtil.getParity(1));
//true
trace('400', NumberUtil.getParity(400));
//false

This is the actual class


package druva {
  import flash.display.Sprite;

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

    public static function getParity(num:Number):String {
		return (num % 2) ? 'odd' : 'even';
	}

  }
}

perlinNoise using Flash ActionScript

Simple Example to show how to use perlinNoise in Flash ActionScript

In the below example the stage is divided into two parts with two different effects

example

import flash.display.*;
import flash.events.Event;
import flash.geom.Point;

var _bitmap1:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight/2, true, 0xCCCCCC);
var _bitmap2:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight/2, true, 0xCCCCCC);

function perlinNoise() {
addChild(new Bitmap(_bitmap1));
_bitmap1.perlinNoise(10, 10, 2, 50, false, true,1, true);

var b:Bitmap = new Bitmap(_bitmap2);
b.y = stage.stageHeight/2;
addChild(b)
}

perlinNoise();

var t:Timer = new Timer(50)
t.addEventListener(TimerEvent.TIMER , onTimer);
var Size = 0;
var xPos = 0;
var yPos = 0;
function onTimer (e:TimerEvent) {
var point:Point=new Point(++xPos,++yPos);
_bitmap1.perlinNoise(10, 10, 2, 50, false, true,1, true, [point, point]);
++Size;
_bitmap2.perlinNoise(Size,Size, 2, 50, false, true,1, true, [point, point]);
if(Size > 50){
Size = 0;
}
}

t.start();

(more…)

Load Date from XML File using flash actionscript AS3

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?

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

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)

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

Validate Email without RegExp in AS2 and AS3 in Flash

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

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