using ColorMatrixFilter-Action-Script

Import an image into the flash
convert to movieclip
give identifier as sample

and here is the code


var img:sample = new sample();
addChild(img);

img.x = stage.stageWidth/2;
img.y = stage.stageHeight/2;

img.filters = [new ColorMatrixFilter([-1, 0, 0, 0, 255, 0, -1, 0, 0, 255, 0, 0, -1, 0, 255, 0, 0, 0, 1, 0])];

This movie requires Flash Player 9

draw Ellipse with flash action script

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

resizing DataGrid using flash actionscript


import fl.controls.DataGrid; 

var dg:DataGrid = new DataGrid();
dg.addColumn("Column1");
dg.addColumn("Column2");
dg.addItem({Column1:"Row 1 Col 1", Column2:"Row 1 Col 2"});
dg.addItem({Column1:"Row 2 Col 1", Column2:"Row 2 Col 2"});

dg.width = 100;
dg.setSize(100,20);
dg.rowCount = dg.length;
dg.move(10, 10);
addChild(dg);

DataGrid content using DataProvider with flash actionscript


import fl.controls.DataGrid;
import fl.data.DataProvider;

var dp:DataProvider = new DataProvider();
dp.addItem({Column1:"Row1 Col1", Column2:"Row1 Col2"});
dp.addItem({Column1:"Row2 Col1", Column2:"Row2 Col2"});

var dg:DataGrid = new DataGrid();
dg.addColumn("Column1");
dg.addColumn("Column2");
dg.rowCount = dp.length;
dg.dataProvider = dp;
dg.width = 200;
dg.move(10, 10);
addChild(dg);

add horizontal scroll to the DataGrid using flash actionscript


import fl.controls.DataGrid;
import fl.controls.ScrollPolicy; 

var dg:DataGrid = new DataGrid();
dg.addColumn("Column1");
dg.addColumn("Column2");
dg.addItem({Column1:"Row 1 Col 1", Column2:"Row 1 Col 2"});
dg.addItem({Column1:"Row 2 Col 1", Column2:"Row 2 Col 2"});

dg.horizontalScrollPolicy = ScrollPolicy.ON;
dg.width = 100;
dg.rowCount = dg.length;
dg.move(10, 10);
addChild(dg);

Load external swf file in AS 3.0 we need to define loader class

To Load external swf file in AS 3.0 we need to define loader class and URL path

var swfHolder:Loader = new Loader();

addChild(swfHolder);

var bgURL:URLRequest = new URLRequest(“loadSWF_File.swf”);

swfHolder.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

swfHolder.load(bgURL);

function loadComplete(e:Event):void {

	trace(" target file loaded");

}

indeterminate progress bar using flash actionscript

import fl.controls.CheckBox;
import fl.controls.ProgressBar;

var cB:CheckBox = new CheckBox();
cB.label = "indeterminate:";
cB.move(10, 10);
cB.addEventListener(Event.CHANGE, cB_change);
addChild(cB);

var pB:ProgressBar = new ProgressBar();
pB.mode="manual";
pB.indeterminate = cB.selected;
pB.setSize(100, 20);
pB.move(15, 40);
addChild(pB);

function cB_change(evt:Event):void {
    pB.indeterminate = cB.selected;
}

masked password in textArea with flash actionscript

import fl.controls.CheckBox;
import fl.controls.TextArea;

var cB:CheckBox = new CheckBox();
cB.label = "Display as Password";
cB.addEventListener(Event.CHANGE, cB_password);
cB.width = 200;
cB.move(10, 5);
addChild(cB);

var tA:TextArea = new TextArea();
tA.displayAsPassword = false;
tA.width = 125;
tA.move(15, 40);
addChild(tA);

function cB_password(evt:Event):void {
    tA.displayAsPassword = cB.selected;
}

scaling images with UILoader using lash actionscript


import fl.containers.UILoader;

var uiL:UILoader = new UILoader();
uiL.scaleContent = false;
uiL.source = "imagename here";
uiL.move(10, 10);
addChild(uiL);

how to use vertical slider in flash

This examples shows how to have vertical slider


import fl.controls.Slider;
import fl.controls.SliderDirection;

var slider:Slider = new Slider();
slider.direction = SliderDirection.VERTICAL;
slider.tickInterval = 1;
slider.move(20, 20);
slider.height = 90
addChild(slider);