Those of you who have been coding with earlier versions of Flash such as Flash MX or before will find this section very useful; it covers some of the differences and advantages in ActionScript 2.0. But not to worrythose of you still wanting to code in ActionScript 1.0 (Flash MX style coding) still have this option as you can see in Figure 8.2. Go to the publish settings; choose File>Publish Settings (Ctrl+Shift+F12), choose the Flash tab, and choose ActionScript 1.0. Be warned, it's not only possible, but likely that you will run into conflicts using ActionScript 1.0 with ActionScript 2.0 anywhere in the file. You can also see which version of ActionScript you are running in your file by selecting the stage and viewing the Properties Inspector as in Figure 8.3. Figure 8.2. Use the Publish Settings dialog box to set which version of ActionScript you would like your file to support.Figure 8.3. Use the Properties Inspector to quickly see which version of ActionScript you are using.But the first feature we will discuss in ActionScript 2.0 is the case-sensitive structure. Back in ActionScript 1.0, you could easily declare a variable myVariable and then call it by using MYVARIABLE; they both would have been considered the same variable. But now, all internal and external ActionScript is case sensitive. For example, in ActionScript 1.0, you would write this: var myVariable = "test"; trace(MYVARIABLE); //Output: test In ActionScript 2.0, you would write this: var myVariable = "test"; trace(MYVARIABLE); //Output: undefined It is the same when passing parameters into functions: //create the function function myFunction(sample){ trace(SAMPLE); } //call the function myFunction("testing"); //Output: undefined As you can see, in ActionScript 2.0, the preceding code would return undefined. So remember to always check your letter casing. Declaring Variables and Instance NamesOther features of ActionScript 2.0 that bring it more in line with ECMA standards are shown in Table 8.1.
|