Flex technology in ArcGIS Flex API (III)-asynchronous feature

Source: Internet
Author: User

 

Author: Flyingis
Flex is inherently capable of asynchronous calling, so that Flex can well adapt to common functions in webgis applications. In ArcGIS Flex API, the most typical is dynamic display of geographical element information, for example, if you move the cursor over a geographical element to display the basic information of the element, the "Show InfoWindow on mouse hover" section of ArcGIS Flex API Demo is used as an example.

Code
<! [CDATA [
Import com. esri. ags. geometry. MapPoint;
Import com. esri. ags. Graphic;
Private const m_content: infowindowrolovercontent = new infowindowrolovercontent ();

Override protected function createChildren (): void
{
Super. createChildren ();
Map. infoWindow. content = m_content;
Map. infoWindow. labelVisible = false;
Map. infoWindow. closeButtonVisible = false;
}

Private function roloverhandler (event: MouseEvent): void
{
Const graphic: Graphic = Graphic (event.tar get );
Const mapPoint: MapPoint = MapPoint (graphic. geometry );
M_content.lat = mapPoint. y. toFixed (3 );
M_content.lon = mapPoint. x. toFixed (3 );
Map. infoWindow. show (mapPoint );
}

Private function rollOutHandler (event: MouseEvent): void
{
Map. infoWindow. hide ();
}
]>


When you move the cursor over a geographical element (point, line, and surface), The roloverhandler method is called to display the x/y coordinates of the geographical element, and then the result is cleared by rollOutHandler, all maps are not refreshed synchronously throughout the process. The features of the Flex asynchronous call and the single-thread mechanism make it common to use the callback function method in Flex, such as the previously written event listening:

Code
<? Xml version = "1.0"?>
<! -- Events/SimpleEventHandler. mxml -->
<Mx: Application xmlns: mx = "http://www.adobe.com/2006/mxml" creationComplete = "initApp ();">
<Mx: Script> <! [CDATA [
Import mx. controls. Alert;

Private function initApp (): void {
B1.addEventListener (MouseEvent. CLICK, myEventHandler );
}

Private function myEventHandler (event: Event): void {
Alert. show ("An event occurred .");
}
]> </Mx: Script>

<Mx: Button id = "b1" label = "Click Me"/>
</Mx: Application>


If you want to implement synchronization in Flex, you can consider WebService Components. asynchronous calling is initially a performance-based design. Now, changing to WebService seems to go to another extreme, the design is as follows: "When Using RemoteObject for data interaction, the invoke event is triggered, the screen is locked, and the result is unlocked. "
However, this only means that the RemoteObject is synchronized in data interaction, and the action on the screen still exists asynchronously. For map interaction, the asynchronous design is closer to the actual application.

 

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.