Skip to main content
Participating Frequently
August 2, 2009
Answered

Could not create SharedObject in Flash Media Interactive Server 3.0

  • August 2, 2009
  • 2 replies
  • 3336 views

Hello All,

I am new to FMS and have been working on Flash Media Development Server.

My Setup:

I have a FMS and HTTP server on same machine  . I developed an Online Chat  Room  Application with Flex Builder 3 on the machine . In this, I used FMS's SharedObject technology to implement an online user list function. When Debugging, I found there's no SharedObject had been created  and there's no err and exception had been thrown.

Please help me.

Thanks

    This topic has been closed for replies.
    Correct answer Anubis_mxy

    Thanks for your bold guess. I checked the  permission of  my application folder  and found it's  enough to write access. Another, I found no  warnings about my problem in the application log. I suspect the prolem is main.far file in my application folder. But I still would like to thank you.


    That's OK

    2 replies

    Participating Frequently
    August 3, 2009

    The SharedObject object should be created by SSL .

    You can try the code :

    //code start

    var YourSharedOBJ;

    application.onAppStart = function()

    {

         YourSharedOBJ = SharedObject.get(YourSHOBJ_Name,false);

    }

    application.onConnect = function(client)

    {

         application.acceptConnection(client);

    }

    //code end

    Save the code into a main.asc file then put it to your application_name folder.

    You can get more information about SharedObject from the flashmediaserver_3.5_SSLR.pdf

    MHuatingAuthor
    Participating Frequently
    August 3, 2009

    I used your code to create main.asc file  and saved it to the folder named "SharedObjectApp"  as follows:

    //Code Start

    var so;
    application.onAppStart = function()
    {
    application.allowDebug = true;
    so = SharedObject.get("RemotingSO",true);
    trace("onAppStart() has been called!");

    }
    application.onConnect = function(client)
    {
    application.acceptConnection(client);
    trace("onConnect() has been called!");
    }

    //Code End

    And I restarted the Server and debugged my application again .  But the result was that there's still no SharedObject had been created in both FMS Admin Console and the folder named "SharedObjectApp" . Now, I even suspect that  the above code was never executed because I found no trace result had been writed to 'Live Log'  in Admin and  the log files.

    What and how I do next? Please tell me at the first time.  Thanks a lot!

    August 3, 2009

    Does FMS have write access to the /applications directory? It needs to create folders for the persistent SO. If there's a permission error, there should be a warning about it in the application log.

    August 2, 2009

    Can you post your code? It's hard to isolate the problem without seeing it.

    MHuatingAuthor
    Participating Frequently
    August 3, 2009

    My code is as follows:

    import mx.controls.Alert;

    import mx.collections.ArrayCollection;

    import flex.VO.Message;

    private var nc:NetConnection;

    private var so:SharedObject;

    private function onClick():void

    {

    //Alert.show("onClick()is called successfully!");

    nc = new NetConnection();

    nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatusHandler);

    nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,onErrorHandler);

    nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityErrorHandler);

    nc.connect("rtmp://211.68.247.*/SharedObjectApp");

    nc.client = this;

    }

    public function onSecurityErrorHandler(e:SecurityErrorEvent):void

    {

    trace(e.text);

    }

    public function onBWDone():void

    {

    }

    private function onNetStatusHandler(evt:NetStatusEvent):void

    {

    this.panChat.title="("evt.info.code+")";

    if(evt.info.code=="NetConnection.Connect.Success")

    {

    so = SharedObject.getRemote("RemotingSO",nc.uri,true);

    so.addEventListener(SyncEvent.SYNC,onSyncHandler);

    so.connect(nc);

    trace("so is created successfully!");

    }

    trace("onNetStatusHandler()is called successfully!");

    }

    function onErrorHandler(e:AsyncErrorEvent):void

    {

    trace(e.error.message);

    }

    private function onSyncHandler(evt2:SyncEvent):void

    {

    trace("onSyncHandler() is being called!");

    if(so.data.msgCollection!=null)

    {

    var tempCollection:ArrayCollection = new ArrayCollection();

    convertArrayCollection(tempCollection,so.data.msgCollection as ArrayCollection);

    this.msgText.text="";

    for(var index:int=0;index<tempCollection.length;index++)

    {

    var message:Object = tempCollection.getItemAt(index);

    var displayMessage:String = message.NickName"says:"message.Context;

    this.msgText.text += displayMessage + "\n";

    trace("Chat information list is updated successfully!");

    }

    }

    }

    private function onSend():void

    {

    var tempCollection:ArrayCollection = new ArrayCollection();

    if(so.data.msgCollection != null)

    {

    convertArrayCollection(tempCollection,so.data.msgCollection as ArrayCollection);

    }

    var msg:Message = new Message();

    msg.NickName = this.txtUser.text;

    msg.Context = this.txtMessage.text;

    tempCollection.addItem(msg);

    so.setProperty("msgCollection",tempCollection);

    //so.flush();

    trace("onSend() is called successfully!");

    this.txtMessage.text="";

    }

    private function convertArrayCollection(arrNew:ArrayCollection,arrOld:ArrayCollection):void

    {

    arrNew.removeAll();

    for(var i:int=0;i<arrOld.length ;i++)

    {

    arrNew.addItemAt(arrOld.getItemAt(i),i);

    }

    }