Functions of array indexof In Flex

Source: Internet
Author: User

Functions of array indexof In Flex


1. Description

Indexof is used to search for indexes from small to large. If the index value is queried,-1 is returned if the index value is not found;


2. Instance

(1) design source code

<? 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) "> <s: layout> <s: basiclayout/> </s: layout> <FX: SCRIPT> <! [CDATA [import MX. events. flexevent;/*** initialization function * indexof is used to search for indexes from small to large. * if it is obtained, the index value is returned, -1 */protected function creationhandler (Event: flexevent): void {var array: array = ["Peach Tree", "Pear Tree", "Pine Tree ", "camphor tree"]; If (array. indexof ("Lishu ")! =-1) {trace ("query by index from small to large:" + array. indexof ("Lishu");} If (array. indexof ("camphor tree", 3 )! =-1) {trace ("starting from the third element, querying by index from small to large:" + array. indexof ("camphor tree", 3) ;}]]> </FX: SCRIPT> <FX: declarations> <! -- Place non-visual elements (such as services and value objects) Here --> </FX: declarations> </S: Application>

(2) execution result

Query by index from small to large: 1
Starting from the third element, query by index from small to large: 3

Functions of array indexof In Flex

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.