Skip to content

primer

ActionScript is based upon the scripting syntax used for JavaScript. ActionScript follows most of the same syntax and formatting rules.

At simple level you can see it here with the following script:

var myVarOne=5;
var myVarTwo=7;
var myVarThree=myVarOne*myVarTwo;
document.write(myVarThree);Above is a simple JavaScript. You are taking two variables and creating the value of myVarThree from those. The document.write passes that value to the web page. Below is the Flash ActionScript version. You will see it is almost identical:

var myVarOne=5;
var myVarTwo=7;
var myVarThree=myVarOne*myVarTwo;
txt.text=myVarThree;The difference is in the passing of data to the stage through the txt.text method instead of the browser window with the document.write method.

To get us started place a text field onto the stage and in the properties panel name this text field answer_txt
You will need to make this a dynamic text filed by changing the drop down below the instance name where you would of just typed in the name above.

make a new layer in the timeline and name the layer code by double clicking where the layer name is. This is just so that you know where all your code is.

Place the following code in code layer you just made:

var myVarOne=5;
var myVarTwo=7;
var myVarThree=myVarOne*myVarTwo;
answer_txt.text=myVarThree;

When you run the move you will see the answer 35 in the text box showing you the code has worked.

here is the tutorial file for you to look at: tut1.zip

Have a play withe files and see if you can have 3 text boxes which you can type in two of them and get the answer in the 3rd. Hint: You will need to make the first text boxes input text boxes and you will need to makea button that reads what is in them and display the answer in the final one.

good luck 🙂