8 Replies Latest reply on Feb 21, 2007 11:00 AM by fisher_john

    How could I write this code?

    fisher_john
      I am trying to create a shared object that will host a chat room environment. I will have many of these rooms and I know what I want to do, just not how to write it in actionscript or if it is even possible. the underlined portion is what i just don't know how to code ( (room + roomNumber + _so) ) as it should throught usage equate to something like room1_so, room2_so, room3_so, and so on. any help would be greatly appreciated. thanks in advance.

      function doJoin(roomNumber) {
      (room + roomNumber + _so) = SharedObject.getRemote( (room + roomNumber + _so) ,_root.clientroom_nc.uri,true);
      if( (room + roomNumber + _so) ).data.seat1 = occupied) {
      do this;
      }
        • 1. Re: How could I write this code?
          kglad Adobe Community Professional & MVP
          if the sharedobject is defined on the tl timeline, you can use:

          • 2. Re: How could I write this code?
            fisher_john Level 1
            hmm. Not quiet sure about this. How would I define it on the "tl timeline"? I am new to the language and haven't dealt with this yet. If you could point me in the direction of a document that would cover this that would explain it a bit? or just how to set it up and use it. also is this something that could be "defined in the timeline" automatically for each room as they could number in the hundreds. Thanks.
            • 3. Re: How could I write this code?
              kglad Adobe Community Professional & MVP
              on the timeline where your code resides, you can use:

              tl=this;

              that will take care of correctly defining tl. use the trace() function to see what you're doing.
              • 4. Re: How could I write this code?
                fisher_john Level 1
                I have tried it 2 different ways just to check to see if I was doing it wrong....neither is working first I tried tl=this; at the top of the actionscript frame, secondly I tried putting it in the function like so...either way it is returning the value as undefined....grrr...im probably just doing something wrong.

                • 5. Re: How could I write this code?
                  kglad Adobe Community Professional & MVP
                  put tl=this on the timeline that contains your doJoin() function.
                  • 6. Re: How could I write this code?
                    fisher_john Level 1
                    Either I just don't know how to place it on the timeline or its simply not working for me. I only have one timeline....Like I said I'm new to this so not sure really...

                    I have my 1 scene with 3 different layers. one layer is where I have ALL of my actionscript code in one frame...this is where my doJoin() function is and at the top of that code before any functions, etc. is where I'm putting the tl=this;. The other layers are just graphical that I change the display with.

                    If it's something else besides that that I'm supposed to be doing then I'd like to know otherwise again...it's just not working...thanks again for the help & patience.
                    • 7. Re: How could I write this code?
                      kglad Adobe Community Professional & MVP
                      i just noticed you're trying use a connect() method applied to a sharedobject. there is no such method for the sharedobject.

                      you may be confusing the localconnection class and the sharedobject class.

                      you can store data in the sharedobject that can be retrieved by the same user at any time. you can use the localconnection to communicate two flash applications that are open simultaneously by the same user. what are you trying to do?

                      • 8. Re: How could I write this code?
                        fisher_john Level 1
                        its actually connecting to flash media server remote shared object as opposed to the local shared object. The code in question was actually taken nearly word for word from the macromedia sample file so I know that that portion is correct.

                        If I replace the shared object name from
                        tl["room"+roomNumber+"_so"].connect(_root.clientroom_nc);
                        and change it to
                        room1_so.connect(_root.clientroom_nc);

                        everything works fine and the connection is succesful, however since I hope to have many many rooms that is just not a feasible way to write it. I have racked my brain trying to think of an alternative way of writing it but have come up with nothing. I am well versed in Basic, PHP, and some C, but this damn actionscript stuff is throwing me for a loop since it is incredibly different in a lot of ways.