Detailed instructions for use are in the User's Guide.
[. . . ] Flex ActionScript Language Reference
Trademarks ActiveEdit, ActiveTest, Add Life to the Web, Afterburner, Aftershock, Andromedia, Allaire, Animation PowerPack, Aria, Attain, Authorware, Authorware Star, Backstage, Blue Sky Software, Blue Sky, Breeze, Bright Tiger, Clustercats, ColdFusion, Contents Tab Composer, Contribute, Design In Motion, Director, Dream Templates, Dreamweaver, Drumbeat 2000, EDJE, EJIPT, Extreme 3D, Fireworks, Flash, FlashHelp, Flash Lite, FlashPaper, Flex, Flex Builder, Fontographer, FreeHand, Generator, Help To Source, HomeSite, Hotspot Studio, HTML Help Studio, JFusion, JRun, Kawa, Know Your Site, Knowledge Objects, Knowledge Stream, Knowledge Track, LikeMinds, Lingo, Live Effects, MacRecorder Logo and Design, Macromedia, Macromedia Action!, Macromedia Central, Macromedia Flash, Macromedia M Logo and Design, Macromedia Spectra, Macromedia xRes Logo and Design, MacroModel, Made with Macromedia, Made with Macromedia Logo and Design, MAGIC Logo and Design, Mediamaker, Movie Critic, Open Sesame!, RoboDemo, RoboEngine JFusion, RoboHelp, RoboHelp Office, RoboInfo, RoboInsight, RoboPDF, 1-Step RoboPDF, RoboFlash, RoboLinker, RoboScreenCapture, ReSize, Roundtrip, Roundtrip HTML, Shockwave, Sitespring, Smart Publishing Wizard, Software Video Camera, SoundEdit, Titlemaker, UltraDev, Web Design 101, what the web can be, WinHelp, WinHelp 2000, WinHelp BugHunter, WinHelp Find+, WinHelp Graphics Locator, WinHelp Hyperviewer, WinHelp Inspector, and Xtra are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally. [. . . ] If you later move the original SWF file to another location, then not even that SWF file will be able to access the data already stored in the shared object. You can reduce the likelihood that you will inadvertently restrict access to a shared object by using the localpath parameter. The most permissive option is to set the localPath parameter to "/", which makes the shared object available to all SWF files in the domain, but will increase the likelihood of name collisions with other shared objects in the domain. More restrictive options are available to the extent that you can append the localPath parameter with folder names that are contained in the full path to the SWF file. For example, your localPath parameter options for the portfolio shared object created by the SWF file at www. myCompany. com/apps/ stockwatcher. swf are: "/"; "/apps"; or "/apps/stockwatcher. swf". You will need to determine which option provides enough flexibility for your application.
Example
The following example creates a shared object that stores text typed into a TextInput component instance. The resulting SWF file will load the saved text from the shared object when it starts playing. Every time the user presses Enter, the text in the text field is written to the shared object. // create the shared object and set localpath to server root
var my_so:SharedObject = SharedObject. getLocal("savedText", "/"); // load saved text from shared object into myText_ti TextInput component myText_ti. text = my_so. data. myTextSaved; // assign an empty string to myText_ti if the shared object is undefined // to prevent the text input box from displaying "undefined" when // this script is first run. if (myText_ti. text == undefined) { myText_ti. text = ""; } // create listener object and function for <enter> event var textListener:Object = new Object();
404
Chapter 6: ActionScript Core Classes
textListener. enter = function(eventObj:Object) { my_so. data. myTextSaved = eventObj. target. text; my_so. flush(); }; // register listener with TextInput component instance myText_ti. addEventListener("enter", textListener);
SharedObject. getSize()
Availability
Flash Player 6.
Usage myLocalSharedObject. getSize() : Number Parameters
None.
Returns
A numeric value specifying the size of the shared object, in bytes.
Description
Method; gets the current size of the shared object, in bytes. Flash calculates the size of a shared object by stepping through each of its data properties; the more data properties the object has, the longer it takes to estimate its size. For this reason, estimating object size can have significant processing time. Therefore, you might want to avoid using this method unless you have a specific need for it.
Example
The following example gets the size of the shared object my_so:
var items_array:Array = new Array(101, 346, 483); var currentUserIsAdmin:Boolean = true; var currentUserName:String = "Ramona"; var my_so:SharedObject = SharedObject. getLocal("superfoo"); my_so. data. itemNumbers = items_array; my_so. data. adminPrivileges = currentUserIsAdmin; my_so. data. userName = currentUserName; var soSize:Number = my_so. getSize(); trace(soSize);
SharedObject. getSize()
405
SharedObject. onStatus
Availability
Flash Player 6.
Usage myLocalSharedObject. onStatus = function(infoObject:Object) { // your statements here } Parameters infoObject Returns
A parameter defined according to the status message.
Nothing.
Description
Event handler; invoked every time an error, warning, or informational note is posted for a shared object. If you want to respond to this event handler, you must create a function to process the information object generated by the shared object.
onStatus
The information object has a code property containing a string that describes the result of the handler, and a level property containing a string that is either "Status" or "Error".
In addition to this onStatus handler, Flash also provides a super function called System. onStatus. If onStatus is invoked for a particular object and no function is assigned to respond to it, Flash processes a function assigned to System. onStatus, if it exists. The following events notify you when certain SharedObject activities occur:
Code property
SharedObject. Flush. Failed
Level property Meaning Error A SharedObject. flush() command that returned "pending" has failed (the user did not allot additional disk space for the shared object when Flash Player showed the Local Storage Settings dialog box). A SharedObject. flush() command that returned "pending" has been successfully completed (the user allotted additional disk space for the shared object).
SharedObject. Flush. Success
Status
Example
The following example displays different messages based on whether the user chooses to allow or deny the SharedObject object instance to write to the disk.
var message_str:String; this. createTextField("message_txt", this. getNextHighestDepth(), 0, 0, 300, 22); message_txt. html = true;
406
Chapter 6: ActionScript Core Classes
this. createTextField("status_txt", this. getNextHighestDepth(), 10, 30, 300, 100); status_txt. multiline = true; status_txt. html = true; var items_array:Array = new Array(101, 346, 483); var currentUserIsAdmin:Boolean = true; var currentUserName:String = "Ramona"; var my_so:SharedObject = SharedObject. getLocal("superfoo"); my_so. data. itemNumbers = items_array; my_so. data. adminPrivileges = currentUserIsAdmin; my_so. data. userName = currentUserName; my_so. onStatus = function(infoObject:Object) { status_txt. htmlText = "<textformat tabStops='[50]'>"; for (var i in infoObject) { status_txt. htmlText += "<b>"+i+"</b>"+"\t"+infoObject[i]; } status_txt. htmlText += "</textformat>"; }; var flushResult = my_so. flush(1000001); switch (flushResult) { case 'pending' : message_str = "flush is pending, waiting on user interaction. "; break; case true : message_str = "flush was successful. Requested storage space approved. "; break; case false : message_str = "flush failed. User denied request for additional storage. "; break; } message_txt. htmlText = "<a href=\"asfunction:System. showSettings, 1\"><u>"+message_str+"</u></a>"; See also SharedObject. getLocal(), System. onStatus
SharedObject. onStatus
407
String class
Availability
CHAPTER 6 ActionScript Core Classes
Flash Player 5 (became a native object in Flash Player 6, which improved performance significantly).
Description
The String class is a wrapper for the string primitive data type, and provides methods and properties that let you manipulate primitive string value types. You can convert the value of any object into a string using the String() function. All the methods of the String class, except for concat(), fromCharCode(), slice(), and are generic, which means the methods call toString() before performing their operations, and you can use these methods with other non-String objects.
substr(),
Because all string indexes are zero-based, the index of the last character for any string x is
x. length - 1.
You can call any of the methods of the String class using the constructor method new String or using a string literal value. If you specify a string literal, the ActionScript interpreter automatically converts it to a temporary String object, calls the method, and then discards the temporary String object. [. . . ] If your system is not powerful enough, you might experience difficulties playing back video with this filter enabled.
Example
The following example plays video1. flv in the my_video video object, and lets the user change the deblocking filter behavior on video1. flv. Add a video object called my_video and a ComboBox instance called deblocking_cb to your file, and then add the following ActionScript to your FLA or AS file.
var deblocking_cb:mx. controls. ComboBox;
804
Chapter 7: ActionScript for Flash
var my_video:Video; // my_video is a Video object on the Stage var my_nc:NetConnection = new NetConnection(); my_nc. connect(null); var my_ns:NetStream = new NetStream(my_nc); my_video. attachVideo(my_ns); my_ns. play("video1. flv"); deblocking_cb. addItem({data:0, label:'Auto'}); deblocking_cb. addItem({data:1, label:'No'}); deblocking_cb. addItem({data:2, label:'Yes'}); var cbListener:Object = new Object(); cbListener. change = function(evt:Object) { my_video. deblocking = evt. target. selectedItem. data; }; deblocking_cb. addEventListener("change", cbListener);
Use the ComboBox instance to change the deblocking filter behavior on video1. flv.
Video. height
Availability
Flash Player 6.
Usage my_video. height:Number Description
Property (read-only); an integer specifying the height of the video stream, in pixels. For live streams, this value is the same as the Camera. height property of the Camera object that is capturing the video stream. For FLV files, this value is the height of the file that was exported as FLV. [. . . ]