5 Replies Latest reply on Aug 18, 2009 9:47 AM by cyber0897

    Preloader with webservice (introspection wizard) please help!

    cyber0897 Level 1

      hi guys, im having some trouble with displaying either a preloader, dosent matter if its eiter indefinite or definite.


      This is the code i have for my webservice, and Mxml.

       

      PageEditor.mxml :

       

      /***************************************************************************************** **************************************************************************/

      <?xml version="1.0" encoding="utf-8"?>
      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" width="100%" height="100%"
           initialize="init();">
          <s:layout>
              <s:BasicLayout/>
          </s:layout>
         
          <fx:Script source="mainPageEditorScript.as" />
          <mx:HDividedBox width="100%" height="100%">
              <mx:DataGrid id="pageList" height="100%" width="200" dataProvider="{modules.PageEditor.pageEditor.pageListData}"
                      itemClick="{modules.PageEditor.pageEditor.getPageInfo(pageList.selectedItem.Key)}">
                  <mx:columns>
                      <mx:DataGridColumn dataField="Value" />
                  </mx:columns>
              </mx:DataGrid>
             
              <mx:VBox width="100%" height="100%">
                  <mx:Accordion id="theAccordion" width="100%" height="100%">

                         .......

                         .......

                  </mx:Accordion>
              </mx:VBox>
          </mx:HDividedBox>
      </s:Group>

       

      /***************************************************************************************** **************************************************************************/

       

      inside my pageEditor class i have

      pageEditor.as

       

       

      // ActionScript file
      package modules.PageEditor{
          import flash.display.Loader;
         
          import mainScript.mainList;
         
          import mx.collections.ArrayCollection;
          import mx.controls.Alert;
          import mx.rpc.events.FaultEvent;
          import mx.rpc.events.ResultEvent;
         
          import services.pages.*;

       

      //    import services.main.*;

       

          [Bindable] public class pageEditor{
              // variables
              public static var pageListData:ArrayCollection;
              public static var pageInfo:Object;
              public static var pageService:Pages = new Pages();
              public static var pageDetails:Pages = new Pages();
             
              public static var loading:Loader = new Loader();
             
              public static var isUpdated:Boolean = false;
             
              public static function init():void{
                  pageService.addEventListener(ResultEvent.RESULT, resultReturn);
                  pageService.showBusyCursor = true;
                  pageService.addEventListener(FaultEvent.FAULT, faultEvent);
                  pageService.GetSitePages(mainScript.mainList.siteId);
                  //Alert.show("here");
              }
              public static function resultReturn(event:ResultEvent):void{
                  pageListData = event.result as ArrayCollection;
                  isUpdated = false;
              }
              public static function faultEvent(event:FaultEvent):void{
                  Alert.show(event.fault.faultCode);
                  Alert.show(event.fault.faultString);
              }
              public static function getPageInfo(id:int):void{
                  pageDetails.addEventListener(ResultEvent.RESULT, returnPageDetails);
                  pageDetails.addEventListener(FaultEvent.FAULT, faultEvent);
                  pageDetails.showBusyCursor = true;
                  pageDetails.GetPage(id);
              }
              public static function returnPageDetails(event:ResultEvent):void{
                  //pageDetails.showBusyCursor = false;
                  pageInfo = event.result;
              }
          }
         
      }

      /***************************************************************************************** **************************************************************************/

       

       

      I just want a preloader to pop up once the DataGrid with Id : pageList  is clicked.because once the item is clicked, it calls another webservice.

       

       

       

       

      ive spent over a week trying ot figure this out, but with no avail!!

       

      please help

        • 1. Re: Preloader with webservice (introspection wizard) please help!
          David_F57 Level 5

          On your click event rather than doing the service call you should call a function that firstly loads and shows the preloader(could be an animated swf or could be a custom component) then do the service call in that function. In the service call result remove the preloader.

           

          David

          1 person found this helpful
          • 2. Re: Preloader with webservice (introspection wizard) please help!
            cyber0897 Level 1

            hey david, thanks for the quick reply!!

             

            i had a similar idea... but i have no idea on how to pop up a pre loader

            if you could either show me or point me in the right direction, that would be GREAT!!

            • 3. Re: Preloader with webservice (introspection wizard) please help!
              cyber0897 Level 1

              oh, and also if someone could show me how to disable the entire application behind the preloader, so the user cannot click on anything while loading will also be great!!

               


              thank you soo much guys... appretiate all you help

              • 4. Re: Preloader with webservice (introspection wizard) please help!
                David_F57 Level 5

                Below is a simple app with a basic component that just flashes some text- hope this helps

                 

                Also the app can be disabled {FlexGlobals.topLevelApplication.enabled=false;} i commented this out in the code as it obviously won't allow you to press buttons

                 

                You could read up on popupmanager if you want to get into modal style window/dialog boxes.

                 

                David.

                 

                 

                 

                The App---

                 

                <?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/halo" width="385" height="400">

                     <fx:Script>

                          

                          <![CDATA[

                               

                               private var PreLoad:waitLoad = new waitLoad();

                               

                               protected function button1_clickHandler(event:MouseEvent):void

                               {

                                    myPanel.addElement(PreLoad); <---add the preloader

                                    //FlexGlobals.topLevelApplication.enabled=false;

                               }

                 

                               protected function button2_clickHandler(event:MouseEvent):void

                               {

                                    myPanel.removeElementAt(myPanel.getElementIndex(PreLoad)); <-- now remove it

                                    //FlexGlobals.topLevelApplication.enabled=true;

                               }

                          ]]>

                     </fx:Script>

                 

                     <s:Button label="Start" click="button1_clickHandler(event)" horizontalCenter="0" top="10"/>

                     <s:Button label="Stop" horizontalCenter="0" click="button2_clickHandler(event)" bottom="10"/>

                     <s:Group id="myPanel" width="208" height="148" horizontalCenter="0" verticalCenter="0">

                     </s:Group>     

                </s:Application>

                 

                 

                The Preloader  (waitLoad.mxml)

                 

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

                <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"

                           xmlns:s="library://ns.adobe.com/flex/spark"

                           xmlns:mx="library://ns.adobe.com/flex/halo" verticalCenter="0" horizontalCenter="0" width="200" height="46"

                               activate="group1_activateHandler(event)">

                     

                <fx:Declarations>

                     <s:Animate id="flasher" target="{st}" repeatCount="0" duration="1000" repeatBehavior="reverse">

                          <s:SimpleMotionPath property="alpha" valueFrom="0" valueTo="1.0"/>

                     </s:Animate>     

                </fx:Declarations>     

                <fx:Script>

                     <![CDATA[

                          

                 

                          protected function group1_activateHandler(event:Event):void

                          {

                            flasher.play();

                          }

                 

                     ]]>

                </fx:Script>     

                     <s:SimpleText id="st" text="Waiting..." fontFamily="Arial" fontSize="20" color="#DE1A1A" fontWeight="bold" textAlign="center"

                                      width="128" height="28" horizontalCenter="0" verticalCenter="0" alpha="0"/>

                </s:Group>

                 

                • 5. Re: Preloader with webservice (introspection wizard) please help!
                  cyber0897 Level 1

                  david... thank you sooo much!! i really appretiate all your help!!

                   

                  i figured out this following function yesterday.... it seems to be working... decently aswell... but the problem is... i need this function to be inside my package in which i have 2 static functions called getPageInfo which initiates the webservice call... and returnPageDetails which is called once i get the result from the webservice call... but unfortunately when i put the following code in my "getPageInfo" function it gives me an error saying

                   

                  "1042: The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code."

                   

                  i need this code to be in that package becasue it needs to remove the popup once i get the result. and i understand why the error message pops up. But i was wondering if there is any kind of workaround for this?? lol

                   

                   


                      var pb:ProgressBar = new ProgressBar();
                      pb.width = 200;
                      pb.labelPlacement = 'center';
                      pb.mode = ProgressBarMode.MANUAL;
                      pb.indeterminate = true;
                      pb.setStyle("borderColor", 0x000000);
                      PopUpManager.addPopUp(pb,this,true);
                      PopUpManager.centerPopUp(pb);
                      pb.setProgress(0,0);