Thursday, December 27, 2012

ActionScript 3.0 demo: sum of two numbers in Flash CS6

Below is the example to get the sum of two numbers in Flash CS6 using ActionScript 3.0.
1) Open Adobe Flash CS6 File->New->ActionScript 3.0
2) Stage width 500, height 350, File-> import to stage with background image (500*350) in layer 1.
Create static text, "SUM" and author name.  input web address under the author name link property.
3) Create layer 2. Using rectangular tool to create   a box.
4) Using component tool, under user interface in component tool, create three TextArea, name
them as tx1, tx3 and tx3. tx3 is output, uncheck editable under property.
Create a button using component tool, name it as "but" and change the label to "="
add static text "+"
5) Press F9 to input the following actionscritpt
 var sty1:TextFormat=new TextFormat();
function buttonclick1(event:MouseEvent):void
    var a:Number=Number(tx1.text);
    var b:Number=Number(tx2.text);
    var d:Number=a+b;

6) Export or test flash, done.

flash output


No comments:

Post a Comment