Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Remote Shared Object not persisting.

Avatar of qfwp
qfwp asked on
Adobe FlashApache Flex
4 Comments1 Solution693 ViewsLast Modified:
Hi

I am currently attempting to make a class that reads a remote shared object and can also set properties.

I seem to be able to create a shared object, set a property and then read back that property, but only within the same session. The data does not seem to persist.

If I load up the browser after closing it the property i set is now undefined.

I have also noticed that i dont get any events from the NetStatus handler for the SharedObject, or any SyncEvent.
private var ncSharedObject:NetConnection
        private var globSO:SharedObject;
        private var globStrUserName:String;
        private var globFMSAPP:String;
            
        public function videoSO(strUserName:String, fmsApp:String){
        
            globStrUserName = strUserName;
            
            globFMSAPP = fmsApp;
        
            ncSharedObject = new NetConnection();
            ncSharedObject.addEventListener(NetStatusEvent.NET_STATUS, funcNetStatusHandler);
            ncSharedObject.addEventListener(SecurityErrorEvent.SECURITY_ERROR, funcSecurityErrorHandler);
            ncSharedObject.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErrorHandler);
            
            ncSharedObject.connect(fmsApp);
            
                
        }

        private function funcNetStatusHandler(evt:NetStatusEvent):void {
        
            funcDebug("status:" + evt.info.code);
        
            if (evt.info.code == "NetConnection.Connect.Success") {
            
                globBoolConnectionSuccessful = true;
            
                funcReadSharedObject();
            
            }
        
        }
        
        private function funcReadSharedObject():void {
        
            funcDebug("Getting Shared Object " + ncSharedObject.uri);
                    
            globSO = SharedObject.getRemote(globStrUserName, ncSharedObject.uri, true, false);
            
            funcDebug("??" + globSO.data);
            
            globSO.client = this;
            
            globSO.addEventListener(SyncEvent.SYNC, syncHandler);
            globSO.connect(ncSharedObject);
            
            
            globSO.addEventListener(NetStatusEvent.NET_STATUS, funcSOStatusHandler);
            
        
        }

        private function funcSOStatusHandler(evt:NetStatusEvent):void {
        
            funcDebug("SOstatus:" + evt.info.code);
        
        }
        
        private function syncHandler(evt:SyncEvent):void {
        
            funcDebug("syncHandler: " + globSO.data.userdata);
        
        }

        public function funcSetSharedObjectData(strUserName:String, numCDID:Number, numPosition:Number):void {
    
            funcDebug("size: " + globSO.size);
    
            funcDebug("SET SO - " + globSO.data.userdata);
    
            var objUser:objUserData;
            
            if (globSO.data.userdata == undefined){
                
                objUser = new objUserData();
                
                objUser.UserName = strUserName;
            
                globSO.setProperty("userdata", objUser);
                
                
            
            } else {
            
                objUser = globSO.data.userdata;
                
                objUser.UserName = new Date().toTimeString();
                
                globSO.setProperty("userdata", objUser);
                
            
            }
}
        public function funcGetLastPosition(strUserName:String, numCDID:Number):String {
        
            funcDebug("READ SO - " + globSO.data.userdata);
        
            var objUser:objUserData = globSO.data.userdata;
            
            return objUser.UserName;
}
ASKER CERTIFIED SOLUTION
Avatar of qfwp
qfwp

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers