Flash actionscript 3.0: September 2008

Local file Browser in action script 3.0

6

Posted by Sankar.G | Posted in | Posted on 12:37 AM

you can able to browse the files in local use below codings in Action Script 3.0

AS3.0
Code:
b1_btn.addEventListener(MouseEvent.CLICK,fun);
function fun(e:Event)
{
var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png");
var docFilter:FileFilter = new FileFilter("Documents", "*.pdf;*.doc;*.txt");
var a:FileFilter=new FileFilter("mp3 files","*.mp3;");
var myFileReference:FileReference = new FileReference();
myFileReference.browse([imagesFilter, docFilter,a]);

}
this is the code you can able to browse the file locally by b1_btn button name

how to play and pause a external mp3 file in flash using actionscript 3.0

3

Posted by Sankar.G | Posted in | Posted on 9:01 AM

you can load a external mp3 file using Action script 3.0
AS3.0
Code:
var req:URLRequest=new URLRequest("E:/Songs/sound.mp3");
var s:Sound=new Sound();
var so:SoundChannel=new SoundChannel();
var pos:Number;
b1_btn.addEventListener(MouseEvent.CLICK,fun);
b2_btn.addEventListener(MouseEvent.MOUSE_DOWN,fun1);
b2_btn.addEventListener(MouseEvent.MOUSE_UP,fun2);
function fun2(e2:Event)
{
so=s.play(pos);
}
function fun1(e1:Event)
{
pos=so.position;
trace("position:"+pos);
so.stop();
}
function fun(e:Event)
{
s.load(req);
so=s.play();
}
This is the code you can play a sound from any location but dont forget to put right slash to get the file from local

Do a addition with out adding any buttons and text boxes in Actionscript 3.0

0

Posted by Sankar.G | Posted in | Posted on 11:53 PM

we can able to do addition with out any designing
and we create a text boxes and button dynamically using action script 3.0
AS3.0
Code:
var a:TextField=new TextField();
var a1:TextFormat=new TextFormat();
a.text=" ";
a.type=TextFieldType.INPUT;
a.border=true;
a.height=30;
a.width=150;
a.x=300;
a.y=40;
a1.size=20;
a.setTextFormat(a1);
var b:TextField=new TextField();
var b1:TextFormat=new TextFormat();
b.text="First Number";
b.border=false;
b.height=25;
b.width=125;
b.y=40;
b1.size=20;
b.setTextFormat(b1);
var c:TextField=new TextField();
c.text="Second Number";
c.border=false;
c.height=25;
c.width=130;
c.y=150;
c.setTextFormat(b1);
var d:TextField=new TextField();
d.text=" ";
d.type=TextFieldType.INPUT;
d.border=true;
d.height=30;
d.width=150;
d.x=300;
d.y=150;
d.setTextFormat(a1);
var e:TextField=new TextField();
e.text="Result";
e.border=false;
e.height=25;
e.width=125;
e.y=250;
e.x=20;
e.setTextFormat(b1);
var f:TextField=new TextField();
f.type=TextFieldType.DYNAMIC;
f.border=true;
f.height=30;
f.width=150;
f.x=300;
f.y=250;
var btn:SimpleButton=new SimpleButton();
btn.upState=up();
btn.downState=down();
btn.hitTestState=hit();
btn.overState=over();
btn.addEventListener(MouseEvent.CLICK,fun);
function fun(e:Event)
{
var nu:Number;
var num:Number;
nu=Number(a.text);
num=Number(d.text);
f.text=Number(nu+num).toString();
}
function up()
{
var bt:Shape=new Shape();
bt.graphics.beginFill(0x000000);
bt.graphics.drawRect(150,300,100,50);
return(bt);
}
function down()
{
var bt:Shape=new Shape();
bt.graphics.beginFill(0x000000);
bt.graphics.drawRect(150,300,100,50);
return(bt);
}
function hit()
{
var bt:Shape=new Shape();
bt.graphics.beginFill(0x000000);
bt.graphics.drawRect(150,300,100,50);
return(bt);
}
function over()
{
var bt:Shape=new Shape();
bt.graphics.beginFill(0x000000);
bt.graphics.drawRect(150,300,100,50);
return(bt);
}
addChild(btn);
addChild(b);
addChild(a);
addChild(c);
addChild(d);
addChild(e);
addChild(f);


this is the code we create a text boxes and button dynamically with out any designing in action script 3.0