background image

Learning Flash Lite 1.X ActionScript

Summary of Contents for FLASH 8-LEARNING FLASH LITE 1.X ACTIONSCRIPT

Page 1: ...Learning Flash Lite 1 X ActionScript ...

Page 2: ...c Opera browser Copyright 1995 2002 Opera Software ASA and its suppliers All rights reserved Macromedia Flash 8 video is powered by On2 TrueMotion video technology 1992 2005 On2 Technologies Inc All Rights Reserved http www on2 com Visual SourceSafe is a registered trademark or trademark of Microsoft Corporation in the United States and or other countries Copyright 2005 Macromedia Inc All rights r...

Page 3: ...ionScript Primer 9 Getting and setting movie clip properties 9 Controlling other timelines 10 Using variables 11 Emulating arrays 11 Working with text and strings 12 Using the call function to create functions 13 Using the eval function 17 Chapter 3 Common Scripting Tasks 19 Determining device and platform capabilities 19 Opening a web page 20 Initiating a phone call 20 Initiating a text or multim...

Page 4: ...4 Contents ...

Page 5: ...e 1 x ActionScript consists of the following parts Flash Player 4 ActionScript This includes operators for example comparison and assignment operators movie clip properties for example _height _x and _y Timeline control functions for example gotoAndPlay or stop and network functions such as the loadVariables and loadMovie functions Flash Lite 1 1 only For a list of unsupported Flash 4 ActionScript...

Page 6: ... a network request Getting time and date information from the device Platform capability variables which provide information about the capabilities of the Flash Lite platform and of the device The fscommand2 function and its associated commands such as SetSoftKeys and FullScreen The scroll and maxscroll text field properties Flash 4 ActionScript not supported by Flash Lite 1 x ActionScript The fol...

Page 7: ...om functions However you can use the call function to execute code that resides on an arbitrary frame in the timeline For more information see Using the call function to create functions on page 13 Native arrays objects or other complex data types Flash Lite 1 x does not support native array data structures or other complete data types However you can emulate arrays using pseudo arrays a technique...

Page 8: ...8 About Flash Lite 1 x ActionScript ...

Page 9: ...lling other timelines 10 Using variables 11 Emulating arrays 11 Working with text and strings 12 Using the call function to create functions 13 Using the eval function 17 Getting and setting movie clip properties To get or set a movie clip property if settable you can use dot syntax or the setProperty or getProperty functions You can also use the tellTarget function To use dot syntax specify the m...

Page 10: ...timelines To specify a path to a timeline use slash syntax combined with dots to build the path reference You can also use _levelN _root or _parent from Flash 5 notation to refer to respectively a specific movie level the application s root timeline or the parent timeline For example suppose you had a movie clip instance named box on your SWF file s main timeline The box instance in turn contains ...

Page 11: ...wever Flash Lite 1 1 does not support native array data structures A common technique in Flash Lite and Flash 4 programming is to emulate arrays with string processing An emulated array is also called a pseudo array The key to pseudo array processing is the eval ActionScript function which lets you access variables properties or movie clips by name For more information see Using the eval function ...

Page 12: ...ovides some basic ActionScript commands and properties for working with text You can get and set the values of text fields concatenate strings URL encode or URL decode text strings and create scrolling text fields This section contains the following topics Concatenating strings on page 12 Scrolling text on page 12 Concatenating strings To concatenate strings in Flash Lite you use the add operator ...

Page 13: ...e frame labeled moveUp call moveUp The call function operates synchronously any ActionScript that follows a call function call won t execute until all of the ActionScript on the specified frame finishes executing To call ActionScript on another frame 1 In a new Flash document insert a keyframe on Frame 10 2 With the new keyframe selected open the Actions panel Window Actions and type the following...

Page 14: ...each layer the same name as the frame label you assign to the keyframe The following figure shows the Timeline of an example call clip The first keyframe of a call clip always contains a stop action which ensures that the playhead doesn t continually loop over the frames in its Timeline Subsequent keyframes contain code for each function Each function keyframe is labeled to identify what it does T...

Page 15: ... Actions panel 7 Add a stop action to the Actions panel 8 Select the keyframe on Frame 2 of the function1 layer and do the following a In the Property inspector type function1 in the Frame Label text box b In the Actions panel Window Actions type the following code trace function1 was called 9 Select the keyframe on Frame 3 of the function2 layer and do the following a In the Property inspector ty...

Page 16: ...ting the movie clip s registration point 13 In the Property inspector type callClip in the Instance Name text box 14 In the Timeline select Frame 1 on the layer named ActionScript 15 In the Actions panel enter the following code call callClip function1 call callClip function2 16 Test your application in the emulator Control Test Movie You should see the following text in the Output panel function1...

Page 17: ...able and assigns the result to nameValue name Jack nameValue eval name result nameValue Jack The eval function is often used with for loops and the add string concatenation operator to create string based arrays because Flash Lite doesn t support native array data structures For more information see Emulating arrays on page 11 You can also use eval to reference movie clip instances by name For exa...

Page 18: ...18 Flash 4 ActionScript Primer ...

Page 19: ...dia message 21 Initiating an e mail message 22 Loading external SWF files 22 Loading external data 22 Determining device and platform capabilities Flash Lite 1 1 includes a number of ActionScript variables that provide information about features and capabilities available to Flash Lite applications running on a particular device For example the _capLoadData variable indicates if the device support...

Page 20: ...and to open a web page in the device s web browser This is the same way you open a web page from a desktop Flash application For example the following opens the Macromedia web page getURL http www macromedia com Flash Lite processes only one getURL action per frame or per event handler Certain handsets restrict the getURL action to keypress events only in which case the getURL call is processed on...

Page 21: ...ication you use the getURL command passing it the sms or mms protocols in place of the standard http protocol and then the phone number to which you want to send the message getURL sms 555 1212 You can optionally specify the message body in the URL query string as the following code shows getURL sms 555 1212 body More info please To initiate an MMS message you use the mms protocol instead of sms a...

Page 22: ...generate a runtime error Flash Lite cannot directly load external image files such as JPEG or GIF images To load these types of media you need to convert the image data to the SWF file format You can do this manually with the Flash authoring tool by importing the image file into a new document and then exporting the file to a Flash Lite or Flash 4 SWF file There are also third party utilities that...

Page 23: ...ta over the network see the Flash Lite news reader in Flash Samples To create the data file 1 Using a text editor for example Notepad or SimpleText create a file that contains the following text item_1 Hello item_2 Bonjour item_3 Hola item_4 Buon giorno item_5 G day 2 Save the file as data txt To create the Flash Lite application to load the data 1 Create a new document from the Flash Lite 1 1 Sym...

Page 24: ...o that they re all selected and select Modify Convert To Symbol 8 In the Convert to Symbol dialog box select Movie Clip as the symbol type and click OK 9 Select the movie clip you just created and in the Property inspector type data_clip in the Instance Name text box 10 In the Timeline select Frame 1 of the Actions layer and open the Actions panel Window Actions 11 Type the following code in the A...

Page 25: ...a multimedia message with 21 starting a phone call with 20 starting a text message with 21 starting an e mail message with 22 I initiate messages 21 initiate phone calls 20 L load external data 22 load external SWF files 22 loadMovie function using 22 loadVariables function using 22 M movie clips getting and setting properties 9 referencing dynamically 17 multimedia message starting 21 O open a we...

Page 26: ...26 Index V variables dot syntax and slash syntax 11 referencing 11 referencing dynamically 17 W web page opening 20 ...

Reviews: