Flex summary 3

Source: Internet
Author: User

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 );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.