Example of the indexof of array in Flex introduction _flex

Source: Internet
Author: User
Tags pear xmlns

The role of the indexof of Array in Flex

1, the description

IndexOf used in the index from small to large lookup, if found on the return index value, can not find the return-1;

2. Example

(1) Design source

Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<s:application xmlns:fx= "http://ns.adobe.com/mxml/2009"
Xmlns:s= "Library://ns.adobe.com/flex/spark"
xmlns:mx= "Library://ns.adobe.com/flex/mx"
Width= "100%" height= "100%" creationcomplete= "Creationhandler" (event) >
<! [cdata[
Import mx.events.FlexEvent;

* Initialization function
* IndexOf used to find from small to large in the index
* If you can find it, return the index value, and then return-1
protected function Creationhandler (event:flexevent): void
var array:array = ["Peach tree", "Pear Tree", "Pine", "camphor Tree"];
if (Array.indexof ("Pear Tree")!=-1)
Trace ("By index from small to large check:" +array.indexof ("Pear Tree"));
if (Array.indexof ("Camphor Tree", 3)!=-1)
Trace ("Starting from the third element, by index from small to large check:" +array.indexof ("Camphor Tree", 3));

<!--place non-visual elements (such as services, value objects) here-->

(2) Operation result

By index from small to large check: 1
Starting from the third element, by index from small to large: 3

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.