adobe flex code keep loading

2972
4
Jump to solution
11-17-2014 05:44 PM
LiYao
by
New Contributor III

‌Hello everybody,

I am using adobe flash builder to create a widget. The widget should load a datagrid with the data retrieved by ASP.NET, but when I click the widget, it keeps loading.

My code is as the following:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">

  <mx:Script>

  <![CDATA[

  import mx.controls.Alert;

  import mx.rpc.events.FaultEvent;

  import mx.rpc.events.ResultEvent;

  public function init():void {

  // Get Data from WebService and fill datagrid when you first invoke the application

  ws.GetLoc();

  }

  public function GetLoc(event:ResultEvent):void {

  // Databind data from webservice to datagrid

  datagrid.dataProvider = event.result;

  }

  public function fault(event:FaultEvent):void {

  // Oppps some error occured

  Alert.show(event.toString());

  }

  ]]>

  </mx:Script>

  <mx:WebService id="ws" wsdl="http://localhost/TestWebService/Service.asmx?WSDL" fault="fault(event)">

  <mx:operation

  name="GetLoc"

  resultFormat="object"

  result="GetLoc(event)"

  />

  </mx:WebService>

  <mx:Panel x="41.5" y="66" width="714.5" height="237" layout="absolute" title="Results">

  <mx:HBox height="95%" width="95%" horizontalCenter="0" verticalCenter="0">

  <mx:DataGrid id="datagrid" width="680" height="100%">

  <mx:columns>

  <mx:DataGridColumn headerText="Item No" dataField="ItemNo"/>

  <mx:DataGridColumn headerText="Sub Type No" dataField="SubTypeNo"/>

  <mx:DataGridColumn headerText="Item Name" dataField="ItemName"/>

  <mx:DataGridColumn headerText="Arrival Date" dataField="ArrivalDate"/>

  </mx:columns>

  </mx:DataGrid>

  </mx:HBox>

  </mx:Panel>

</mx:Application>

No idea on it, is there anything wrong with my code? I am using Adobe flash builder 4.6

Thanks a lot.

Message was edited by: Robert Scheitlin, GISP

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Li Yao,

  Ok, you are mixing things up here. If you are talking about using any of this code in the ArcGIS Viewer for Flex, then you are in the wrong forum and your code is totally incorrect. If you are not talking about coding in the ArcGIS Viewer for Flex then a question of using the WidgetTemplate is irrelevant. If you are doing custom coding for the Flex API (not using ArcGIS Viewer for Flex) then you use the base component mx:Application is correct.

If you are just custom coding for the Flex API then here is your code updated to Spark (where appropriate):

<?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"

               minWidth="955" minHeight="600">

    <fx:Declarations>

        <mx:WebService id="ws" wsdl="http://localhost/TestWebService/Service.asmx?WSDL" fault="fault(event)">

            <mx:operation

                name="GetLoc"

                resultFormat="object"

                result="GetLoc(event)"/>

        </mx:WebService>

    </fx:Declarations>

    <fx:Script>

        <![CDATA[

            import mx.collections.ArrayCollection;

            import mx.rpc.events.FaultEvent;

            import mx.rpc.events.ResultEvent;

           

            import spark.components.Alert;

           

            public function init():void {

                // Get Data from WebService and fill datagrid when you first invoke the application

                ws.GetLoc();

            }

           

            public function GetLoc(event:ResultEvent):void {

                // Databind data from webservice to datagrid

                datagrid.dataProvider = new ArrayCollection(event.result as Array);

            }

           

            public function fault(event:FaultEvent):void {

                // Oppps some error occured

                Alert.show(event.toString());

            }

        ]]>

    </fx:Script>

   

    <s:Panel x="41.5" y="66" width="714.5" height="237" title="Results">

        <s:HGroup height="95%" width="95%" horizontalCenter="0" verticalCenter="0">

            <s:DataGrid id="datagrid" width="680" height="100%">

                <s:columns>

                    <s:ArrayList>

                        <s:GridColumn headerText="Item No" dataField="ItemNo"/>

                        <s:GridColumn headerText="Sub Type No" dataField="SubTypeNo"/>

                        <s:GridColumn headerText="Item Name" dataField="ItemName"/>

                        <s:GridColumn headerText="Arrival Date" dataField="ArrivalDate"/>

                    </s:ArrayList>

                </s:columns>

            </s:DataGrid>

        </s:HGroup>

    </s:Panel>

</s:Application>

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Li Yao,

  This one has me confused. Your title was "adobe flex widget keep loading", so I moved it to the ArcGIS Viewer for Flex‌ space then I see that the code has mx:Application (which means it is not a widget) so I moved it back to the ArcGIS API for Flex‌ space. But then I read more of you comments and you say

but when I click the widget, it keeps loading.

Which make me wander if you are actually talking about an ArcGIS Viewer for Flex widget and you just are very confused about widget development... Can you be more concise as to whether you are asking a question about an ArcGIS Viewer for Flex Widget or some custom Flex API code.

0 Kudos
LiYao
by
New Contributor III

Hi Robert,

I am asking the customized Flex API code.

Should I use WidgetTemplate instead of application.

Sorry for so many questions because I am just starting using Flex. Thanks a lot for the help.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Li Yao,

  Ok, you are mixing things up here. If you are talking about using any of this code in the ArcGIS Viewer for Flex, then you are in the wrong forum and your code is totally incorrect. If you are not talking about coding in the ArcGIS Viewer for Flex then a question of using the WidgetTemplate is irrelevant. If you are doing custom coding for the Flex API (not using ArcGIS Viewer for Flex) then you use the base component mx:Application is correct.

If you are just custom coding for the Flex API then here is your code updated to Spark (where appropriate):

<?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"

               minWidth="955" minHeight="600">

    <fx:Declarations>

        <mx:WebService id="ws" wsdl="http://localhost/TestWebService/Service.asmx?WSDL" fault="fault(event)">

            <mx:operation

                name="GetLoc"

                resultFormat="object"

                result="GetLoc(event)"/>

        </mx:WebService>

    </fx:Declarations>

    <fx:Script>

        <![CDATA[

            import mx.collections.ArrayCollection;

            import mx.rpc.events.FaultEvent;

            import mx.rpc.events.ResultEvent;

           

            import spark.components.Alert;

           

            public function init():void {

                // Get Data from WebService and fill datagrid when you first invoke the application

                ws.GetLoc();

            }

           

            public function GetLoc(event:ResultEvent):void {

                // Databind data from webservice to datagrid

                datagrid.dataProvider = new ArrayCollection(event.result as Array);

            }

           

            public function fault(event:FaultEvent):void {

                // Oppps some error occured

                Alert.show(event.toString());

            }

        ]]>

    </fx:Script>

   

    <s:Panel x="41.5" y="66" width="714.5" height="237" title="Results">

        <s:HGroup height="95%" width="95%" horizontalCenter="0" verticalCenter="0">

            <s:DataGrid id="datagrid" width="680" height="100%">

                <s:columns>

                    <s:ArrayList>

                        <s:GridColumn headerText="Item No" dataField="ItemNo"/>

                        <s:GridColumn headerText="Sub Type No" dataField="SubTypeNo"/>

                        <s:GridColumn headerText="Item Name" dataField="ItemName"/>

                        <s:GridColumn headerText="Arrival Date" dataField="ArrivalDate"/>

                    </s:ArrayList>

                </s:columns>

            </s:DataGrid>

        </s:HGroup>

    </s:Panel>

</s:Application>

0 Kudos
LiYao
by
New Contributor III

Hi Robert,

You are right, by using the updated code the problem not occur again. Thanks a lot.

0 Kudos