Access a SharedObject Between Multiple Flash Applications : SharedObject « Data Model « Flex






Access a SharedObject Between Multiple Flash Applications

Access a SharedObject Between Multiple Flash Applications
         

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

    <mx:Script>
        
            import mx.events.BrowserChangeEvent;
            import mx.managers.IBrowserManager;
            import mx.managers.BrowserManager;
            import mx.utils.URLUtil;

            private var bm:IBrowserManager= BrowserManager.getInstance();

            private function onCreationComplete():void
            {
                bm.init();

                var o:Object = URLUtil.stringToObject(bm.fragment);
                firstName.text = o.firstName;
                lastName.text = o.lastName;

                bm.addEventListener( BrowserChangeEvent.BROWSER_URL_CHANGE, onURLChange );
            }

            private function updateURL():void
            {
                bm.setFragment( "firstName=" + firstName.text + ";lastName=" + lastName.text );
            }

            private function onURLChange( event : BrowserChangeEvent ):void
            {
                var o:Object = URLUtil.stringToObject(bm.fragment);
                firstName.text = o.firstName;
                lastName.text = o.lastName;
            }
      
    </mx:Script>

    <mx:TextInput x="10" y="10" id="firstName" change="updateURL()" />
    <mx:TextInput x="10" y="40" id="lastName" change="updateURL()" />

</mx:Application>
    

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Use SharedObject to transfer dataUse SharedObject to transfer data
2.Create a SharedObject
3.Optimize a Runtime Shared LibraryOptimize a Runtime Shared Library