1 Timer class application
// create a 500-millisecond interval, 10 times timer
var curtimer: timer = new timer (500, 10 );
// Add an event listener to call the output method at each arrival interval
curtimer. addeventlistener (timerevent. timer, output);
// Add an event listener so that after all timer calls are completed, the timercomplete function is called.
curtimer. addeventlistener (timerevent. timer_complete, timercomplete);
// call at the start interval
curtimer. start ();
}< br> Public Function output (EVT: timerevent ): void
{
// number of output calls
trace ("output times" + evt.tar get. currentcount);
}< br> Public Function timercomplete (EVT: timerevent ): void
{< br> // output after the call is completed
trace ("call completed");
}
2 XML-related
adding nodes and attributes for XML
var flexxml: xml =
flexxml. flash = "hello";
mailto: flexxml. @ name = % 22 flashplayer ";
Hello
Access to the required node:
VaR flexxml: xml =
<Ria>
<Flashplayer>
<Flash>
<Name> Flash CS3 </Name> <version> 9 </version> <price> 1000 </price>
</Flash>
<Flash>
<Name> flash 8 </Name> <version> 8 </version> <price> 1000 </price>
</Flash>
<Flash>
<Name> flash 2004mx </Name> <version> 7 </version> <price> 1000 </price>
</Flash>
</Flashplayer>
</Ria>
VaR ABC: xmllist = flexxml. Child ("flashplayer"); access the child node of Flash Player
The @ symbol is used to access the specified attribute of an element, for example:
Trace (flexxml. flashplayer. @ version );
You can also access it using attribute attributes, as shown in figure
Trace (flexxml. flashplayer. Attribute ("version "));
Search nodes in XML:
For example:
VaR flexxmlstr: String = "<Ria>"
+ "<Flashplayer>"
+ "<Flash version = '9'> Flash CS3 </flash>"
+ "<Flash version = '8'> flash 8 </flash>"
+ "<Flash version = '7'> flash
2004mx </flash>"
+ "<Flex> flex3 </flex>"
+ "</Flashplayer>"
+ "<Ajax>"
+ "<Googleajax> googleajax1.0 </googleajax>"
+ "</Ajax>"
+ "</Ria> ";
VaR flexxml1: xml = New XML (flexxmlstr );
Trace (flexxml1.flashplayer. Flash. (attribute ('version')> 7 ));
Find the node where the version attribute is greater than 7.
Use hasownproperty to check whether the node exists.
Trace (flexxml1.flashplayer. Flash. (hasownproperty ("company") & @ version> 7 ));
For loop output:
For (var I: Int = 0; I <flexxml. Child ("flashplayer"). Child ("Flash"). Length (); I ++)
{
Trace (flexxml. Child ("flashplayer"). Child ("Flash ")
[I]. Name + ":" + flexxml. Child ("flashplayer"). Child ("Flash") [I]. version );
}