2 Replies Latest reply on Jun 25, 2009 2:13 PM by kingquattro

    Global/Application level variable

    kingquattro Level 1

      Hey guys

         I have been using sdk 3.0 so far, but now ran into a issue.  I wanted to create grouped data grid using AdvancedDataGrid, but when my data get loaded from CF, the AdvancedDataGrid does not update with newly acquired data.  I used

       

        [Bindable] public mydataprovider:ArrayCollection;

       

      and in result function have

       

          mydataprovider = new ArrayCollection(event.result as Array).

       

      All of this works but my datagrid remains empty, since there was no data when the component was created and added to the stage.  Turns out that this is a know issue and was fixed in subsequent DMV 3.0.2

       

      [link]http://bugs.adobe.com/jira/browse/FLEXDMV-1334?page=com.atlassian.jira.plugin.system.issue tabpanels:all-tabpanel[/link]

       

      So I installed sdk 3.3.  Now I have all sorts of errors.  Mainly this one.

       

      I have a utility.as file in which a var as bellow

       

      var app:[app name] = mx.Application.application as [app name]

       

      I am using this var (app) to access values that are set in different stages and also to dispatch and listen to events.  but now I can use it in 3.3

      I get an error


           Call to a possibly undefined method addEventListener through a reference with static type [app name]

       

      Now I think I know that I didn't use the best coding pratice, and made due with ad-hoc way of making app work.  But now I need some help to fix my hacks.

       

      So the question is how can I dispatch and listen for actions at a single point (I know that dispatched actions are suppose to bubble up till they are heard, but that for some reason didn't work for me from the start).  And how to I create application wide variables so I can access them anywhere and at anytime in my app.

       

      Sorry for such a long post, and thank you very much for all your help

       

      Jaysheel.

        • 1. Re: Global/Application level variable
          Flex harUI Adobe Employee

          You should not be getting that error if is the name of the mxml file of your application.  Maybe a name changed or something like that?

           

          Events do not bubble by default and bubbling events is a bad practice in situations where the dispatcher is known

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: Global/Application level variable
            kingquattro Level 1

            Hey Alex,

               The the app name is the exact same.  I have a file called virome.mxml which has my <mx:application> tag and my var "app" is of type virome.  I have check the spelling.  Any other ideas?

             

            oo good to know that I should try to avoid even bubbling, hehe at least I am doing something right.

             

            Jaysheel

             

            p.s if it helps here is the application tag

             

            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                            xmlns="*"
                            creationComplete="initApp()"
                            layout="absolute"
                            width="100%"
                            height="100%"
                            preloader="custom.preload.Preloader"
                            historyManagementEnabled="false"
                            modalTransparency="0.45"
                            modalTransparencyBlur="8"
                            modalTransparencyColor="#FF6600">

             

             

            and here is my declaration in utility.as

             

                 public var app:virome = mx.core.Application.application as virome;   

                 public const viromeLSO:SharedObject = SharedObject.getLocal("viromeLocalSharedObject");
                 private var parsing:Boolean = false;
                   
                 public function Utility(){
                      app = mx.core.Application.application as virome;
                 }