perlinNoise using Flash ActionScript

Posted by druva | Flash, Flex, MXML, as3, utils | Friday 29 January 2010 2:47 pm

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

 

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

 

Add Background Image for AIR Application

Posted by Vineela | AIR, Flash, MXML | Tuesday 12 January 2010 11:23 am

background image for AIR application


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication name="WindowedApplication_backgroundImage_test"
        xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle">

    <mx:Style>
        WindowedApplication {
            backgroundColor: white;
            backgroundImage: ClassReference("mx.skins.halo.ApplicationBackground");
        }
    </mx:Style>

</mx:WindowedApplication>
 

validate email with ReqExp

Posted by druva | Flash, Flex, MXML, as2, as3, utils | Thursday 26 March 2009 12:26 am

The below code shows how to use the class


import druva.emailValidator;

trace('druva.flash@gmail.com > '+emailValidator.isValidEmail('druva.flash@gmail.com'));
// true
trace('druva.flash@gmail > '+emailValidator.isValidEmail('druva.flash@gmail'));
// false
trace('druva.@.com > '+emailValidator.isValidEmail('druva.@.com'));
//false
trace('druva.@gmail.com > '+emailValidator.isValidEmail('druva.@gmail.com'));
//true
trace('.aa@gmailcom > '+emailValidator.isValidEmail('.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 isValidEmail(email:String):Boolean {
		var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
		return emailExpression.test(email);
	}
 

Remove White spaces from string in flash – Actionscript 3 (AS3)

Posted by druva | Flash, Flex, MXML, as3, utils | Monday 12 January 2009 4:06 am

This examples shows how to remove white spaces from the string


 public function removeSpaces(str:String):String {
 if (str == null) { return ''; }
 return str.replace(/\s+/g, '');
 }

This is the complete flex example


<?xml version="1.0" encoding="utf-8"?>
<mx:Application
 xmlns:mx="http://www.adobe.com/2006/mxml"
 layout="absolute">
 <mx:Script>
 <![CDATA[

 public function removeSpaces(str:String):String {
 if (str == null) { return ''; }
 return str.replace(/\s+/g, '');
 }
 public function on_trim_button():void {
 reultText.text = removeSpaces(originalText.text);
 }
 ]]>
 </mx:Script>
 <mx:Button x="74" y="101" label="Trim Spaces" click="on_trim_button()"/>
 <mx:TextArea x="74" y="42" id="originalText" />
 <mx:TextArea x="74" y="157" id="reultText" />
 <mx:Label x="74" y="16" text="Enter Text" width="160"/>
 <mx:Label x="74" y="131" text="Enter Text" width="160"/>
</mx:Application>
 

Representational State Transfer (REST)

Posted by druva | Flash, Flex, MXML, as3 | Monday 20 October 2008 1:41 am

Representational State Transfer(REST), This is a method that can identify by a URI.

IT supports HTTP methods GET, POST, PUT, DELETE, HEAD and OPTIONS.

It is possible to do everything that you can do with RPC web service with REST.

Problem with flash and REST is Flash support only GET and POST

Air Supports few more read this document URLRequest
for further information read this link NPAPI

 

Flex Accordion Header Color

Posted by druva | Flex, MXML, as3, utils | Tuesday 14 October 2008 1:32 am

This examples shows how to control accordion header text color

here is the complete example in flex –


<?xml version="1.0" encoding="utf-8"?>
<mx:Application
 xmlns:mx="http://www.adobe.com/2006/mxml"
 width="600"
 height="600"
 >

 <mx:Script>
 <![CDATA[
 public function setColors():void {
 myAcc.getHeaderAt(0).setStyle('color', 0xFF0000);
 myAcc.getHeaderAt(1).setStyle('color', 0x00FF00);
 myAcc.getHeaderAt(2).setStyle('color', 0x0000FF);
 }
 ]]>
 </mx:Script>

 <mx:Accordion id="myAcc" width="300" height="300" creationComplete="setColors()">
 <mx:VBox label="Container 1">
 <mx:Text text="123456"/>
 </mx:VBox>

 <mx:VBox label="Container 2">
 <mx:Text text="123456890"/>
 </mx:VBox>

 <mx:VBox label="Container 3">
 <mx:Text text="123456890 123456"/>
 </mx:VBox>
 </mx:Accordion>
</mx:Application>