dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Shared Objects FPS...

  1. #1
    ASR | FlashComm Ceasar Aware0's Avatar
    Join Date
    Aug 2002
    Location
    Aurora, Colorado, USA
    Posts
    110
    Taken from Macromedia's Flash AS Dictionary:
    If you have FlashComm MX click here
    Code:
    SharedObject.setFps
    
    Availability
     Flash Player 6.
     
     Flash Communication Server MX.
     
    
    
    Usage
    
    
    myRemoteSharedObject.setFps(updatesPerSecond)
    Parameters
    
    
    updatesPerSecond A number that specifies how often a client's changes to a remote shared object are sent to the server. The default value is the frame rate of the movie. 
    
     To send changes immediately and then stop sending changes, pass 0 for updatesPerSecond.
     
     To reset updatesPerSecond to its default value, pass a value less than 0. 
     
    
    Returns
    
    
    A Boolean value of true if the update was accepted, false otherwise. 
    
    Description
    
    
    Method; specifies the number of times per second that a client's changes to a shared object are sent to the server. 
    
    Use this method when you want to control the amount of traffic between the client and the server. For example, if the connection between the client and server is relatively slow, you may want to set updatesPerSecond to a relatively low value. Conversely, if the client is connected to a multiuser game in which timing is important, you may want to set updatesPerSecond to a relatively high value. 
    
    If you want to manually control when updates are sent, issue this command with updatesPerSecond set to 0 when you want to send changes to the server. For example, if you want to let the user push a button that sends updates to the server, attach myRemoteSharedObject.setFps(0) to the button. 
    
    Regardless of the value you pass for updatesPerSecond, changes are not sent to the server until SharedObject.onSync has returned a value for the previous update. That is, if the response time from the server is slow, updates may be sent to the server less frequently than the value specified in updatesPerSecond.
    Now to my understanding, there is a pre-set update rate on the SO that you can change with this method. So what's this initial value?

    On the the actual application of this...

    I am creating a multiplayer, real-time game. I am using a setInterval to constantly send the current player's data to the server SO, this then invokes the onSync on each of the other users connected, who's SWFs then update the player's information. All the clients are sending/recieving their information all the time.

    Because they are always sending the information, I need the transfer rate maxed out. I am wondering if i can use something like this:
    Code:
    User.prototype.sendData = function() {
    	//This is the information that is to be sent. At the moment, just simple location/rotation
    	so.data.x = this._x;
    	so.data.y = this._y;
    	so.data.rot = this._rotation;
    	//Here is where I am wondering what will happen
    	//Will this make it so that the data from this client will be sent
    	//to the server SO whenever this function is called? or what?
    	//Now if I am using a setInterval(at 5 ms) to call this function,
    	//will that then make the client update the info in the so every
    	//5 miliseconds? or no?
    	so.setFps(0);
    };

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Posts
    190
    Just set it to 40 ya noob :\

  3. #3
    ASR | FlashComm Ceasar Aware0's Avatar
    Join Date
    Aug 2002
    Location
    Aurora, Colorado, USA
    Posts
    110
    *cough*geek!*cough*

    yea thanks. I'll stick to your previous advice and just use call functions instead of remote SO's

    BTW...your sha1 Ad thing...the admin area is not working
    just leaving a message in case i dont talk to you later.

  4. #4
    psx = new Moderator();
    Join Date
    Jan 2001
    Posts
    923
    Hey -
    Just to clarify - the so sync's at whatever the framerate of the movie is at. If your movie is at 12fps, than so is your so.

    Here's where it gets tricky... if your movie is at 12fps, and you try to set the fps to 30 it doesn't work. It will only go as fast as your movie's framerate.

    By setting it to 0, you are just forcing an update. So the code you posted should do the trick.

    Psx

  5. #5
    Senior Member catapop's Avatar
    Join Date
    Nov 2005
    Posts
    114
    hi! I have a similar problem or somthing like that!
    till now I used flash comm server 1.5 and my script was fine but now i'm using media server 2 and it's a little problem

    i have a shared object and i change his information on the server side
    on client side i use onSynk to show the information every time I update it on server side

    so this works just fine on flash commserver 1.5 but it doesn't work on media server 2.

    can anyone know why???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center