Life Cycle of flex application
—
Here is the list of 4 events that sets the Life Cycle of flex application.
preinitialize
Presinitialize event is triggered / Dispatched before any other events
initialize
Dispatched when the component has finished its constructions and has all initialization properties set, this is done after all the other components have initialized themselves.
creation complete
Dispatched when the component has finished its construction, property processing, measuring, layout, and drawing. This is done when all components have completed their creation.
application complete (where applicable)
Dispatched after the Application has been initialzed
Apart from above these methods are triggered internally. You can override these methods to have better understanding
override protected function createChildren():void
{
super.createChildren();
}
override protected function childrenCreated():void
{
super.childrenCreated()
}
override protected function commitProperties():void
{
super.commitProperties();
}
override protected function measure():void
{
super.measure();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
}
list of flex testing frameworks
This is the list of flex testing frameworks Which I came Across
FlexUnit (Adobe Open Source)
FlexPMD (Adobe Technical Services)
Funit (Open Source)
asUnit (Open Source)
fluint (Open Source)
FlexMonkey (Open Source)
Selenium (Open Source)
FlashSelenium (Open Source)
HP QuickTest Professional 9.5
mock-as3 (Open Source)
FlexCover (Open Source)
FunFX
Mock4AS
ASMock
Mockito
How to remove White Box between the scrollers using action script
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
<mx:Script>
<![CDATA[
override public function validateDisplayList():void {
super.validateDisplayList();
for (var i:Number=0; i<rawChildren.numChildren; i++) {
if ((rawChildren.getChildAt( i ) as DisplayObject).name == "whiteBox" ) {
((rawChildren.getChildAt( i ) as DisplayObject) as Shape).graphics.clear();
}
}
}
]]>
</mx:Script>
<mx:Text text="1221sdfsdfssdfs
sdfsdf
sdfs
fs
fsd
fsd
fsd
fsd
fsd
fsd
fsd
fs
df
sdf
sdfdfs d
|sdfsdfsdfsdfsdf sdf sdf sd fsdfsdfsdsdfsfsdfsfdsfdffsdf sdf sdf sdf sdfsdsdfsfsdf
sdfsdfsdfsdfs
sdf
sdfsd
fsd
f
sdfsd
f
sfd fsdfdsfsdfsdffsd sdf sdffs dfdf"/>
</mx:Canvas>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
<local:myCanvas>
</local:myCanvas>
</mx:Application>
Flash CS4 TextElement TextBlock FontDescription TextBlock TextLine
This code show how to use TextElement, TextBlock, FontDescription, TextBlock, TextLine
package druva{
import flash.display.Sprite;
import flash.text.engine.*;
public class TextTest extends Sprite {
public function TextTest() {
for (var j:int=0; j<=10; j++) {
var myString:String="Flashallys";
var myFormat:ElementFormat = new ElementFormat();
var myFontDesc:FontDescription=new FontDescription('Georgia','normal','italic','device');
myFormat.fontSize=2+2*j;
myFormat.fontDescription=myFontDesc;
myFormat.color = Math.random() * 0xFFFFEE;
var textElement:TextElement=new TextElement(myString, myFormat);
var textBlock:TextBlock = new TextBlock();
textBlock.content=textElement;
var myTextLine:TextLine=textBlock.createTextLine(null,300);
myTextLine.x = 30+(3*(j*(j+1)/2));
myTextLine.y = 150;
addChild(myTextLine);
myTextLine.addEventListener(Event.ENTER_FRAME, onLoop);
}
}
import flash.events.*;
private function onLoop(e:Event) {
e.currentTarget.rotationY += 3;
e.currentTarget.rotation = mouseX;
}
}
}
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';
}
}
}
How to Convert TextField to Bitmap using Flash and AS3
Convert TextField to Bitmap
package {
import flash.display.*;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
public class BitmapUtils extends Sprite {
public function BitmapUtils() {
addChild(tf2bm('Druva'));
}
public function tf2bm(str:String) {
var fmt:TextFormat;
var bmd:BitmapData;
var bm:Bitmap;
var tf:TextField;
fmt = new TextFormat();
fmt.font='Verdana';
fmt.size=30;
tf = new TextField();
tf.text=str;
tf.setTextFormat(fmt);
tf.autoSize=TextFieldAutoSize.LEFT;
bmd=new BitmapData(tf.width,tf.height,true,0);
bmd.draw(tf);
bm=new Bitmap(bmd);
bm.smoothing=true;
return bm
}
}
}
How to know box radius using action script
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
xmlns:local="*">
<mx:Box width="250" height="250"
cornerRadius="{cRadius.value}"
borderStyle="solid"
borderColor="0xFF0000"
backgroundColor="0xFFFFFF"
borderThickness="0" y="10" x="39">
</mx:Box>
<mx:HSlider id="cRadius"
value="20"
width="200"
snapInterval="1"
minimum="0" maximum="125"
liveDragging="true"/>
</mx:Application>
BlurFilter for Images using Flash ActionScript
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.flashallys.com/blog/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];
}
}
}