User manual MACROMEDIA FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0

DON'T FORGET : ALWAYS READ THE USER GUIDE BEFORE BUYING !!!

If this document matches the user guide, instructions manual or user manual, feature sets, schematics you are looking for, download it now. Diplodocs provides you a fast and easy access to the user manual MACROMEDIA FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0. We hope that this MACROMEDIA FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 user guide will be useful to you.


MACROMEDIA FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 : Download the complete user guide (3613 Ko)

Manual abstract: user guide MACROMEDIA FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0

Detailed instructions for use are in the User's Guide.

[. . . ] Programming ActionScript 3. 0 Adobe Flex 2 ® TM © 2006 Adobe Systems Incorporated. Flex 2 Programming ActionScript 3. 0 If this guide is distributed with software that includes an end-user agreement, this guide, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written permission of Adobe Systems Incorporated. Please note that the content in this guide is protected under copyright law even if it is not distributed with software that includes an end-user license agreement. [. . . ] Internally, the PlayList class keeps track of its songs using a private Array variable: public class PlayList { private var _songs:Array; private var _currentSort:SortProperty = null; private var _needToSort:Boolean = false; . . . } In addition to the _songs Array variable, which is used by the PlayList class to keep track of its list of songs, two other private variables keep track of whether the list needs to be sorted (_needToSort) and which property the song list is sorted by at a given time (_currentSort). Example: PlayList 249 As with all objects, declaring an Array instance is only half the job of creating an Array. Before accessing an Array instance's properties or methods, it must be instantiated, which is done in the PlayList class's constructor. public function PlayList() { this. _songs = new Array(); // Set the initial sorting. this. sortList(SortProperty. TITLE); } The first line of the constructor instantiates the _songs variable, so that it is ready to be used. In addition, the sortList() method is called to set the initial sort-by property. Adding a song to the list When a user enters a new song into the application, the code in the data entry form calls the PlayList class's addSong() method. /** * Adds a song to the playlist. */ public function addSong(song:Song):void { this. _songs. push(song); this. _needToSort = true; } Inside addSong(), the _songs array's push() method is called, adding the Song object that was passed to addSong() as a new element in that array. With the push() method, the new element is added to the end of the array, regardless of any sorting that might have been applied previously. This means that after the push() method has been called, the list of songs is likely to no longer be sorted correctly, so the _needToSort variable is set to true. In theory, the sortList() method could be called immediately, removing the need to keep track of whether the list is sorted or not at a given time. In practice, however, there is no need for the list of songs to be sorted until immediately before it is retrieved. By deferring the sorting operation, the application doesn't perform sorting that is unnecessary if, for example, several songs are added to the list before it is retrieved. 250 Working with Arrays Sorting the list of songs Because the Song instances that are managed by the playlist are complex objects, users of the application may wish to sort the playlist according to different properties, such as song title or year of publication. In the PlayList application, the task of sorting the list of songs has three parts: identifying the property by which the list should be sorted, indicating what sorting options need to be used when sorting by that property, and performing the actual sort operation. Properties for sorting A Song object keeps track of several properties, including song title, artist, publication year, filename, and a user-selected set of genres in which the song belongs. As a matter of convenience for developers, the example includes the SortProperty class, which acts as an enumeration with values representing the properties available for sorting. public static const TITLE:SortProperty = new SortProperty("title"); public static const ARTIST:SortProperty = new SortProperty("artist"); public static const YEAR:SortProperty = new SortProperty("year"); The SortProperty class contain three constants, TITLE, ARTIST, and YEAR, each of which stores a String containing the actual name of the associated Song class property that can be used for sorting. Throughout the rest of the code, whenever a sort property is indicated, it is done using the enumeration member. For instance, in the PlayList constructor, the list is sorted initially by calling the sortList() method, as follows: // Set the initial sorting. this. sortList(SortProperty. TITLE); Because the property for sorting is specified as SortProperty. TITLE, the songs are sorted according to their title. Example: PlayList 251 Sorting by property and specifying sort options The work of actually sorting the list of songs is performed by the PlayList class in the sortList() method, as follows: /** * Sorts the list of songs according to the specified property. var sortOptions:uint; switch (sortProperty) { case SortProperty. TITLE: sortOptions = Array. CASEINSENSITIVE; break; case SortProperty. ARTIST: sortOptions = Array. CASEINSENSITIVE; break; case SortProperty. YEAR: sortOptions = Array. NUMERIC; break; } // Perform the actual sorting of the data. this. _songs. sortOn(sortProperty. propertyName, sortOptions); // Save the current sort property. this. _needToSort = false; } When sorting by title or artist, it makes sense to sort alphabetically, but when sorting by year, it's most logical to perform a numeric sort. The switch statement is used to define the appropriate sorting option, stored in the variable sortOptions, according to the value specified in the sortProperty parameter. Here again the named enumeration members are used to distinguish between properties, rather than hard-coded values. With the sort property and sort options determined, the _songs array is actually sorted by calling its sortOn() method, passing those two values as parameters. [. . . ] Function calls from ActionScript cause the Shockwave Flash ActiveX control to dispatch its FlashCall event, so a class (such as the ExternalInterfaceProxy class) that intends to receive calls from a SWF file needs to define a handler for that event. In the ExternalInterfaceProxy class, the event handler function is named _flashControl_FlashCall(), and it is registered to listen for the event in the class constructor, as follows: private AxShockwaveFlash _flashControl; public ExternalInterfaceProxy(AxShockwaveFlash flashControl) { _flashControl = flashControl; _flashControl. FlashCall += new _IShockwaveFlashEvents_FlashCallEventHandler(_flashControl_FlashCall); } . . . private void _flashControl_FlashCall(object sender, _IShockwaveFlashEvents_FlashCallEvent e) { // Use the event object's request property ("e. request") // to execute some action. // Return a value to ActionScript; // the returned value must first be encoded as an XML-formatted string. [. . . ]

DISCLAIMER TO DOWNLOAD THE USER GUIDE MACROMEDIA FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0




Click on "Download the user Manual" at the end of this Contract if you accept its terms, the downloading of the manual MACROMEDIA FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 will begin.

 

Copyright © 2015 - manualRetreiver - All Rights Reserved.
Designated trademarks and brands are the property of their respective owners.