MACROMEDIA FLEX 2-TESTING FLEX APPLICATIONS WITH MERCURY QUICKTEST PROFESSIONAL Instrukcja Użytkownika Strona 9

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 27
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 8
488Debugging
But for more complex objects like
ArrayCollection
s, the
ObjectUtil
ActionScript
class has a
toString()
function that takes a reference of any other object and con-
verts it to a string.
In listing 23.3, the
ObjectUtil
class is used to display all the items in an
Array-
Collection
.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="trace(ObjectUtil.toString(myAC))">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.utils.ObjectUtil;
public var myAC:ArrayCollection = new ArrayCollection([
{label:"Jon Hirschi", data:"jhirschi"},
{label:"Tariq Ahmed", data:"tahmed"},
{label:"Frank Krul", data:"fkrul"}
] ) ;
] ] >
</mx:Script>
</mx:Application>
This code produces something like the log file shown in listing 23.4.
(mx.collections::ArrayCollection)#0
filterFunction = (null)
length = 3
list = (mx.collections::ArrayList)#1
length = 3
source = (Array)#2
[0] (Object)#3
data = "jhirschi"
label = "Jon Hirschi"
[1] (Object)#4
data = "tahmed"
label = "Tariq Ahmed"
[2] (Object)#5
data = "fkrul"
label = "Frank Krul"
uid = "70528450-89C6-9120-D5D4-847C1D8C3B70"
sort = (null)
source = (Array)#2
Another popular approach shows the value on screen via the
Alert.show()
function,
instead of dumping it to a log file. Here’s an example:
Alert.show(ObjectUtil.toString(myAC))
Listing 23.3 Using ObjectUtil to dump an object’s properties
Listing 23.4 Sample output from ObjectUtil
Przeglądanie stron 8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 ... 26 27

Komentarze do niniejszej Instrukcji

Brak uwag