ࡱ> Root EntryRoot Entryp|YrRASHPContents$vPage 1X"Symbol 8  !"#%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_CPicPage CPicLayer CPicFrame ?initA// // Array for FlashLite // Simulates arrays in FlashLite. // Copyright (c) 2005 Aral Balkan. // Released under the open-source MIT license. // http://flashant.org // stop(); // // Properties // name = ""; value = ""; item = ""; index = ""; ?pushe"// // Method: push() // // Parameters: // // name: Name of the array to use // item: Item to push to the end of the array // // Note: We cannot check for undefined in FlashLite so I'm // checking for an empty string instead. if ( eval ( name add "LastIndex" ) eq "" ) { // The <name>LastIndex variable doesn't exist. This means that // the array hasn't been created yet. Create it by creating the // last index variable and initializing it to zero. eval ( name add "LastIndex" ) = 0; } else { // Update the last index for this array eval ( name add "LastIndex" )++; } // Add the item to the last index eval (name add eval ( name add "LastIndex" ) ) = item;  ?popt~m// // Method: pop() // // Parameters: // // name: Name of the array to use // // Returns: // // item: Item at last index (or "" if not such index exists) // // Note: We cannot check for undefined in FlashLite so I'm // checking for an empty string instead. value = eval ( name add eval ( name add "LastIndex" ) ); eval ( name add "LastIndex" )--; ?existsPu// // Method: exists() // // Parameters: // // name: Name of the array to use // // Returns: // // value: True if it exists, False if it doesn't // value = eval ( name add "LastIndex" ) ne "";  ?lookUp9// // Method: lookUp() // Looks up the value at the passed index on the requested Array. // // Parameters: // // name: Name of the array to use // index: Index to look up // // Returns: // // value: The value contained in the index (or "" if no value exists) // value = eval ( name add index );  ?assignh$// // Method: assign() // Assigns the value to the passed index on the passed Array. // // Parameters: // // name: Name of the array to use // index: The index to place the value in // value: The value to store // // Returns: // // Nothing // if ( index > eval ( name add "LastIndex" ) ) { // If the index is higher than the current last index, update it eval ( name add "LastIndex" ) = index; } eval ( name add index ) = value;  ?length}Z0// // Method: length() // // Parameters: // // name: Name of the array to use // // Returns: // // value: 0 if array doesn't exist, non-zero positive integer giving // the length of the array if it does // value = eval ( name add "LastIndex" ) eq "" ? 0 : eval ( name add "LastIndex" ) + 1; ?iteratorG< index = 0;  ?next%index++; Functions3 CPicShape3sl 0`0`0CPicText   _sans(Array?, PreviewOOCPicPage CPicLayer CPicFrame CPicSpritem iArray<component metaDataFetched='true' schemaUrl='' schemaOperation='' sceneRootLabel='Scene 1' oldCopiedComponentPath='1'> </component> ?7  Array instance3?6CI// // For loop // trace("Examples:"); /* // // The iterator method (below) is faster // t = getTimer(); for ( i = 0; i < 10000; i++ ) { eval ( "/Array:index" ) = i; eval ( "/Array:value" ) = "Element " add i; tellTarget ( "Array" ) { name = "example"; call ( "assign" ); } } trace ("Populating 1000 items took: " add ( getTimer() - t ) ); */ t = getTimer(); call ( "/Array:iterator" ); for ( i = 0; i < 1000; i++ ) { eval ( "/Array:value" ) = "Element " add i; tellTarget ( "Array" ) { name = "example"; call ( "assign" ); } call ("/Array:next" ); } trace ("Populating 1000 items with iterator took: " add ( getTimer() - t ) ); // Lookup t = getTimer(); for ( i = 0; i < 1000; i++ ) { eval ( "/Array:index" ) = i; tellTarget ( "Array" ) { name = "example"; call ( "lookUp" ); } } trace ("Looking up and 1000 items took: " add ( getTimer() - t ) ); // // Note: Simple simulated arrays are much faster: // t = getTimer(); for ( i = 0; i < 1000; i++ ) { eval ( "example" add i ) = "Element " add i; } trace ("Populating 1000 items without the Array class took: " add ( getTimer() - t ) ); t = getTimer(); for ( i = 0; i < 1000; i++ ) { eval ( "example" add i ); } trace ("Looking up 1000 items without the Array class took: " add ( getTimer() - t ) );  ExamplesO?g // // Unit test: Array // Copyright (c) 2005 Aral Balkan // Released under the open-source MIT license. // http://flashant.org // passed = 0; failed = 0; // // Setup: Initialize the array // tellTarget ( "Array") { call ("init"); } // // testPush() - See testLookUp for the asserts // tellTarget ( "Array" ) { // Add first item, the string "Hello" name = "myArray"; item = "Hello"; call ("push"); // Add second item, the string "There" item = "There"; call ( "push" ); } // // testLookUp() // tellTarget ( "Array" ) { index = 0; call ( "lookUp" ); } // Assert that the value at index 0 is "Hello" if ( eval ( "/Array:value" ) ne "Hello" ) { trace ( "Assert failed on testLookUp: Value should be \"Hello\"" ); failed++; } else passed++; tellTarget ( "Array" ) { index = 1; call ( "lookUp" ); } // Assert that the value at index 1 is "There" if ( eval ( "/Array:value" ) ne "There" ) { trace ( "Assert failed on testLookUp: Value should be \"There\"" ); failed++; } else passed++; // // testPop() // // Assert that pop should return "There" call ( "/Array:pop" ); if ( eval ( "/Array:value" ) ne "There" ) { trace ( "Assert failed on testPop: Value should be \"There\"" ); failed++; } else passed++; // Assert that pop should return "Hello" call ( "/Array:pop" ); if ( eval ( "/Array:value" ) ne "Hello" ) { trace ( "Assert failed on testPop: Value should be \"Hello\"" ); failed++; } else passed++; // Assert that pop should return "" (does not exist) call ( "/Array:pop" ); if ( eval ( "/Array:value" ) ne "" ) { trace ( "Assert failed on testPop: Value should be \"\"" ); failed++; } else passed++; // // testAssign // tellTarget ( "Array" ) { index = 4; value = "Skipped four"; call ( "assign" ); value = ""; call ( "lookUp" ); } // Assert that the element at index 4 should be "Skipped four" if ( eval ( "/Array:value" ) ne "Skipped four" ) { trace ( "Assert failed on testAssign: Value should be \"Skipped four\"" ); failed++; } else passed++; // // testLength // call ( "/Array:length" ); // Assert that there are five elements in the array if ( eval ( "/Array:value" ) != 5 ) { trace ( "Assert failed on testLength: Value should be 5" ); failed++; } else passed++; // // Unit test results // trace ( failed + passed add " asserts ran." ); trace ( passed add " passed." ); trace ( failed add " failed." );  Tests8 CDocumentPagePage 1Scene 1iD>.yBSymbol 8ArrayxBSymbol 1.yB  @hhhhhb>Format-Verffentlichungseigenschaften einstellen::projectorMac0;RNWK Verffentlichungseigenschaften einstellen::mediaAuthor;Html Verffentlichungseigenschaften einstellen::StartPaused0=Format-Verffentlichungseigenschaften einstellen::gifFileNameSiemens_SX1_template.gif7JPEG-Verffentlichungseigenschaften einstellen::Quality80:RNWK Verffentlichungseigenschaften einstellen::exportSMIL1Format-Verffentlichungseigenschaften einstellen::jpegFileNameSiemens_SX1_template.jpg6Format-Verffentlichungseigenschaften einstellen::html1>PNG Verffentlichungseigenschaften einstellen::RemoveGradients04Html Verffentlichungseigenschaften einstellen::Loop1;RNWK Verffentlichungseigenschaften einstellen::exportAudio17PNG Verffentlichungseigenschaften einstellen::BitDepth24-bit mit Alpha8PNG Verffentlichungseigenschaften einstellen::Interlace08GIF Verffentlichungseigenschaften einstellen::MaxColors2557Html Verffentlichungseigenschaften einstellen::Quality4?RNWK Verffentlichungseigenschaften einstellen::showBitrateDlog1@GIF Verffentlichungseigenschaften einstellen::TransparentOption9RNWK Verffentlichungseigenschaften einstellen::speed384K08GIF Verffentlichungseigenschaften einstellen::LoopCount6Html Verffentlichungseigenschaften einstellen::Height2274PNG Verffentlichungseigenschaften einstellen::Width2087GIF Verffentlichungseigenschaften einstellen::Animated08RNWK Verffentlichungseigenschaften einstellen::speed28K1;Format-Verffentlichungseigenschaften einstellen::generator05PNG Verffentlichungseigenschaften einstellen::Smooth1?GIF Verffentlichungseigenschaften einstellen::TransparentAlpha1284Format-Verffentlichungseigenschaften einstellen::qt05Html Verffentlichungseigenschaften einstellen::Scale0:GIF Verffentlichungseigenschaften einstellen::PaletteName>RNWK Verffentlichungseigenschaften einstellen::mediaCopyright(c) 2000Format-Verffentlichungseigenschaften einstellen::rnwkFileNameSiemens_SX1_template.smil>Format-Verffentlichungseigenschaften einstellen::projectorWin0>Format-Verffentlichungseigenschaften einstellen::defaultNames1:Html Verffentlichungseigenschaften einstellen::DeviceFont0CHtml Verffentlichungseigenschaften einstellen::HorizontalAlignment15JPEG-Verffentlichungseigenschaften einstellen::Width2087Format-Verffentlichungseigenschaften einstellen::flash1>Format-Verffentlichungseigenschaften einstellen::htmlFileNameSiemens_SX1_template.html;RNWK Verffentlichungseigenschaften einstellen::audioFormat0:PNG Verffentlichungseigenschaften einstellen::PaletteName8RNWK Verffentlichungseigenschaften einstellen::speed56K1>GIF Verffentlichungseigenschaften einstellen::RemoveGradients0FFormat-Verffentlichungseigenschaften einstellen::projectorMacFileNameSiemens_SX1_template.hqx5Html Verffentlichungseigenschaften einstellen::Units0