How to use actionscript files




















Returns the string representation of this object, formatted according to locale-specific conventions. Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. Click for more information on events. Hide Inherited Events. Show Inherited Events. Property Detail. Implementation public static function get applicationDirectory : File More examples Pointing to the application directory.

Paths of File objects. The following code creates a File object pointing to the "images" subdirectory of the application storage directory. If an operating system does not support a cache directory, cacheDirectory is null Implementation public static function get cacheDirectory : File.

Implementation public static function get desktopDirectory : File More examples Pointing to the desktop directory. The following code outputs a list of files and directories contained in the user's desktop directory. The following code uses the File. This property is only meaningful on operating systems in which files can be flagged as downloaded: Windows XP service pack 2 and later, and on Windows Vista Mac OS Implementation public function get exists : Boolean Example How to use this example The following code creates a temporary file, then deletes it and uses the File.

Implementation public function get icon : Icon Example How to use this example The following code shows how to find the image in the icon array that has the greatest height, and it sets a Bitmap object to that image. Implementation public function get isDirectory : Boolean Example How to use this example The following code creates an array of File objects pointing to files and directories in the user directory and then uses the isDirectory property to list only those File objects that point to directories not to files.

Implementation public function get isHidden : Boolean Example How to use this example The following code creates an array of File objects pointing to files and directories in the user directory and then uses the isHidden property to list hidden files and directories.

On Mac OS, directories can be designated as packages and will show up in the Finder as a single file rather than as a directory. This property is set to true if the referenced directory is a package, and false if the file is not a directory, does not exist, or is not a package.

On other operating systems, this property is always set to false. Implementation public function get isPackage : Boolean More examples Working with packages and symbolic links. Implementation public function get isSymbolicLink : Boolean. Implementation public static function get lineEnding : String Learn more Getting file system information. The following code writes a string str to a text file and uses the File. It is far better to use the following static properties, which represent commonly used directories, and which are valid on all platforms: File.

Implementation public function get nativePath : String public function set nativePath value: String : void Throws ArgumentError — The syntax of the path is invalid. SecurityError — The caller is not in the application security sandbox. More examples Modifying File paths. The following code shows the difference between the nativePath property and the url property of a File object. The comments show results on an example Windows computer.

Implementation public function get parent : File Example How to use this example The following code uses the parent property to show the directory that contains a temporary file. Implementation public function get preventBackup : Boolean public function set preventBackup value: Boolean : void.

Implementation public static function get separator : String Learn more Getting file system information. The following code uses the getRelativePath method to get the relative path between a directory and a file. The code then uses the File. Implementation public function get spaceAvailable : Number More examples Determining space available on a volume. Implementation public static function get systemCharset : String Learn more Getting file system information. The following code opens a file a test.

The following code outputs a list of files and directories contained in the root level of the user directory: Copy. Pointing a File object to a file. Events cancel : Event — Dispatched when the user clicks the Cancel button in the Open File dialog box. SecurityError — The application does not have the necessary permissions. More examples Letting the user browse to select a directory.

When the directory is selected, the code lists the contents of the selected directory in the trace output. More examples Letting the user browse to select a file. When the file is selected, the code reads the file data into a string. When the files are selected, the code outputs the paths for the selected files.

Events cancel : Event — Dispatched when the user clicks the Cancel button in the Save File dialog box. When the files are selected, the code saves data to the selected file path. In addition, canonicalization converts short filenames to long filenames on Windows.

More examples Obtaining canonical versions of file names. The following code shows how to use the canonicalize method to find the correct capitalization of a directory name.

Before running this example, create a directory named AIR Test on the desktop of your computer. The following code shows how to use the canonicalize method to find the long name of a Windows directory based on its short name. Returns File. Throws IOError — The source does not exist; or the destination exists and overwrite is false ; or the source could not be copied to the target; or the source and destination refer to the same file or folder and overwrite is set to true.

On Windows, you cannot copy a file that is open or a directory that contains a file that is open. SecurityError — The application does not have the necessary permissions to write to the destination. More examples Copying and moving directories Copying and moving files.

The following code shows how to use the copyTo method to copy a file. Before running this code, create a test1. The resulting copied file is named test2. When you set the overwrite parameter to true , the operation overwrites any existing test2. The try and catch statements show how to respond to errors. Events complete : Event — Dispatched when the file or directory has been successfully copied.

Throws SecurityError — The application does not have the necessary permissions to write to the destination. More examples Copying and moving files. The following code shows how to use the copyToAsync method to copy a file.

Before running this code, be sure to create a test1. Throws IOError — The directory did not exist and could not be created. More examples Creating directories. The following code moves a file named test. The call to the createDirectory method ensures that the AIR Test directory exists before the file is moved. Returns File — A File object referencing the new temporary directory. More examples Creating a temporary directory. The following code uses the createTempFile method to obtain a reference to a new temporary directory.

Returns File — A File object referencing the new temporary file. More examples Creating a temporary file. The following code uses the createTempFile method to obtain a reference to a new temporary file. Throws IOError — The directory does not exist, or the directory could not be deleted. On Windows, you cannot delete a directory that contains a file that is open.

SecurityError — The application does not have the necessary permissions to delete the directory. More examples Deleting directory contents. The following code creates an empty directory and then uses the deleteDirectory method to delete the directory.

Events complete : Event — Dispatched when the directory has been deleted successfully. Throws SecurityError — The application does not have the necessary permissions to delete the directory. Throws IOError — The file does not exist or could not to be deleted. On Windows, you cannot delete a file that is currently open. SecurityError — The application does not have the necessary permissions to delete the file.

More examples Deleting a file. The following code creates a temporary file and then calls the deleteFile method to delete it. Events complete : Event — Dispatched when the file has been deleted successfully. Throws SecurityError — The application does not have the necessary permissions to delete the file. Returns Array — An array of File objects. More examples Working with packages and symbolic links Enumerating directories. The following code shows how to use the getDirectoryListing method to enumerate the contents of the user directory.

Events ioError : ErrorEvent — You do not have adequate permissions to read this directory, or the directory does not exist. The contents event includes a files property, which is the resulting array of File objects.

The following code shows how to use the getDirectoryListingAsync method to enumerate the contents of the user directory. Returns String — The relative path between this file or directory and the ref file or directory , if possible; otherwise null. Throws ArgumentError — The reference is null. More examples Finding the relative path between two files.

Returns Array — An array of File objects, listing the root directories. Learn more Pointing to the file system root. The following code outputs a list of root directories: Copy. The move process creates any required parent directories if possible. Their user interfaces are designed to look good and work well on a desktop or laptop computer.

Although the examples work on mobile devices, the Stage size and user interface design is not suitable to the small screen. Adobe recommends that you run the practical examples on a computer to learn the ActionScript, and then use pertinent code snippets in your mobile applications. To see the output, create an instance of the TextField class.

Then, append the text from the trace statements to the text property of the text field. For example, add this function to the document class as a private function. Then, in other methods of the document class, trace data with code like the following:.

The appendText method accepts only one value as a parameter. That value is a string either a String instance or a string literal. To print the value of a non-string variable, first convert the value to a String. Many examples use text fields to help illustrate a concept. Sometimes adjusting the size of the text in the text field provides better readability on a mobile device.

For example, if an example uses a text field instance named myTextField , change the size of its text with the following code:. The mobile operating system and browser capture some user input events that the SWF content does not receive.

Specific behavior depends on the operating system and browser, but could result in unexpected behavior when you run the examples on a mobile device. For more information, see KeyboardEvent precedence. Also, the user interfaces of many examples are designed for a desktop or laptop computer.

For example, most of the practical examples in the ActionScript 3. Furthermore, the examples are not designed to catch and handle scrolling or panning events. Adobe recommends that you run the examples on a computer to learn the ActionScript, and then use pertinent code snippets in your mobile applications.

For more information, see Panning and scrolling display objects. Some examples require you to give a field the focus. By giving a field the focus, you can, for example, enter text or select a button.

On some devices, tapping twice on a button selects it. For more information about focus, see Managing focus. Many examples listen for mouse events. On a computer, these mouse events can occur, for example, when a user rolls over a display object with the mouse, or clicks the mouse button on a display object.

On mobile devices, events from using pointer devices such as a stylus or finger, are called touch events. Flash Player Therefore, examples work when using a pointer device to select or drag a display object. Mobile devices have less processing power than desktop devices. Some CPU-intensive examples possibly perform slowly on mobile devices. For example, the example in Drawing API example: Algorithmic Visual Generator does extensive computations and drawing upon entering every frame.

Running this example on a computer illustrates various drawing APIs. However, the example is not suitable on some mobile devices due to their performance limitations. Deprecated with Animate Behaviors also let you add code to your file without writing it yourself. Behaviors are prewritten scripts for common tasks. You can add a behavior and then easily configure it in the Behaviors panel. Behaviors are available only for ActionScript 2. Writing your own ActionScript gives you the greatest flexibility and control over your document.

But, it requires you to become familiar with the ActionScript language and conventions. Components are prebuilt movie clips that enable you to implement complex functionality. A component can be a simple user interface control, such as a check box, or it can be a complicated control, such as a scroll pane.

Most components require you to write some ActionScript code of your own to trigger or control a component. For more information, see Using ActionScript 3. When you write ActionScript code in the authoring environment, you use the Actions panel or Script window. The Actions panel and Script window contain a full-featured code editor that includes code hinting and coloring, code formatting, and syntax highlighting features. It also contains debugging, line numbers, word wrapping, and support for Unicode.

Use the Actions panel to write scripts that are part of your Animate document that is, scripts that are embedded in the FLA file. The Actions panel provides features such as the Actions toolbox, which gives you quick access to the core ActionScript language elements. You get prompts for the elements that require to create scripts. Use the Script window if you want to write external scripts—that is, scripts or classes that are stored in external files.

You can also use a text editor to create an external AS file. The Script window includes code-assistance features such as code hinting and coloring, syntax checking, and auto-formatting.

Getting started with ActionScript 3. Creating a Document class using ActionScript 3. Creating an effective workflow between design and development CS3 The following articles and tutorials provide more detailed information about working with ActionScript:.

ActionScript 3 migration table Adobe. When you execute any doc type, the Output panel displays information or warning related to operations such as document conversions and publish.

To display this information, add trace statements to your code or use the List Objects and List Variables commands. If you use the trace statement in your scripts, you can send specific information to the Output panel when the SWF file runs.

It includes notes about the status of the SWF file status or the value of an expression. To find reference documentation for a specific ActionScript language element, do one of the following:. Open the ActionScript 3. Type the language element in the Actions panel, select it, then press F1 Press F1 immediately. Choose only one version for each FLA file you create.

Script navigator. Lists the scripts in your Animate document, and lets you move quickly between them. To view the script in the Script pane, click an item in the Script navigator. The Actions panel lets you access the code-assistance features that simplify and streamline coding in ActionScript. You can add non-frame specific global and third-party scripts that can be applied to the whole animation from within Animate.

For more information, see A dding G lobal a nd T hird- p arty s cripts section in this page. Add using wizard is a simplified user interface to add code to your compositions. Click Add using wizard in Actions panel as shown in the following screenshot. In the above screenshot, Get frame number action is selected and the corresponding code has been updated in action window.

Based on the action type you select, you can also choose the corresponding object for which you want to apply the action. You can search for specific objects on stage if the object has an instance name.

Also, you can apply the action on the current selection. Click Next to choose a triggering event. To edit an existing classpath folder, select the path in the Classpath list, click the Browse to Path button, browse to the folder to add, and click OK.

Alternatively, double-click the path in the Classpath list, type the desired path, and click OK. To delete a folder from the classpath, select the path in the Classpath list and click the Remove Selected Path button.

To add a folder to the source path, click the Source path tab and then click the Browse To Path button , browse to the folder to add, and click OK. To add a new line to the Source path list, click the Add New Path button. To edit an existing Source path folder, select the path in the Source path list, click the Browse To Path button, browse to the folder to add, and click OK.

Alternatively, double-click the path in the Source path list, type the desired path, and click OK. To delete a folder from the source path, select the path in the Source path list and click the Remove From Path button. External: The code resources found in the path are not added to the published SWF file, but the compiler verifies that they are in the locations you specified. You can use conditional compilation in ActionScript 3. For example, you can use conditional compilation to turn blocks of code throughout a project on of off, such as code that implements a certain feature or code used for debugging.

Using config constants that you define in the publish settings, you can specify whether certain lines of ActionScript code are compiled or not. Each constant takes the following form:. When the value of the constant is true, the line of code that follows the constant in ActionScript is compiled. When the value is false, the line of code that follows the constant is not compiled. For example, the following function has 2 lines of code that are compiled only if the value of the constant that precedes them is set to true in the publish settings:.

Ensure that the Script menu set to ActionScript 3. Type the name of the constant you want to add. You can add your own config namespaces by entering them with a constant name in the publish settings and adding them to your ActionScript code using the following syntax:. Enter the value you want for the constant, either true or false. You change this value in order to turn on or off compilation of specific lines of code. You can customize the standard context menu and the text-editing context menu that appears with SWF files in Flash Player 7 and later.

You can add custom items to this menu. You cannot customize this menu. For more information on using these objects, see ContextMenu in the ActionScript 2. Custom items are added to a context menu in the order in which they are created. You cannot modify this order after the items are created. Flash places several configuration folders on your system when you install the application.

The configuration folders organize files associated with the application into appropriate levels of user access. The configuration folders for Flash are as follows:. Because it is in the application level, non-administrative users do not have write access to this directory. This sibling to the application-level configuration folder facilitates sharing configuration files among users of the same computer.

Folders and files in the First Run folder are automatically copied to the user-level configuration folder.



0コメント

  • 1000 / 1000