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

Do a addition with out adding any buttons and text boxes in Actionscript 3.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

Comments (0)