Usage of remote shared object Sharedobject in flashcom

Source: Internet
Author: User
Tags array empty client
object| objects

Learn FCS also has almost one months, feel the most distinctive thing or sharedobject.
Sharedobject have a lot of things, local operations do not say (I believe many people have not contacted FCS also used); Just talk about remote shared objects.
The basic application process is:

MY_NC = new Netconnection ();
My_nc.connect ("Rtmp:/app", variable 1, variable 2,...);
Myso=getremote ("Myso", My_nc.uri,false)
Myso.connect (MY_NC);
Myso.onsync=function (info) {
}
Myso.data[property]=newvalue
//

The following resolution:

MY_NC = new Netconnection ();
My_nc.connect ("Rtmp:/app", variable 1, variable 2,...);
Myso=getremote ("Myso", My_nc.uri,false)
MYSO: Shared object name;
My_nc.uri: Shared objects share users connected to My_nc.uri;
False: You can also use TRUE or null;
1. Null or False:p ersistence not on the server
2. True:persistence on the server (not on the local);
3. A full or partial local path to the shared object
Persistence on the server and local
I don't quite know what that means, but I conclude: false: When all users are stopped
When Myso empty; true: not Empty,
Myso.connect (MY_NC);
Connect Myso to Server
Myso.onsync=function (info) {
}
MYSO Events
Change its value (it triggers the Onsync event once it changes its value):
Myso.data[property]=newvalue

Here you can use the basic, of course, if you want to create a corresponding MYSO on the server can also be used
APPLICATION.MYSO = Sharedobject.get ("Myso", false);
But note that in the server Operation Myso property is to use SetProperty to change, or an object as its properties, then the operation of the object without using SetProperty.
//
The following is the key to the Myso event: Onsync
Sharedobject has two events: Onstatus and Onsync
Two are basically the same, but there is a bit (don't know if this makes people not onstatus): Onstatus does not trigger this event for both new and old values.
and Onsync but whether or not the same will trigger;
Let's look at one example:

My_so.onsync = function (info) {
for (name in info) {
Trace ("[Sync] Reading Array Object #" +name+ "code (" +info[name].code+ "," +info[name].name+ ")");
Switch (info[name].code) {
Case "Change":
var property = Info[name].name;
var newvalue = This.data[property];
_root[property+ "_in"].text = newvalue;
Break
Case "Success":
Break
Case "Reject":
Break
Case "Clear":
Break
Case "Delete":
Break
Trace ("Data is updated");
}
}
};

Operation:

Myso.data[mytxt]=50

Just on top of it:

My_so.onsync = function (info) {
Info: Event Onsync triggered return information, is a one-dimensional array, two attributes (Code,name)
for (name in info) {
Name: variable attribute name, this is a traversal to see what attributes have changed in this event (often only one attribute has changed)
Trace ("Info[name].code:" +info[name].code+ "Info[name].name:" +info[name].name);
Output Info[name].code: The event type relative to this client: the following switch;
Output Info[name].name: Property name
Switch (info[name].code) {
Case "Change":
When the event type is "changed", the basic broadcast event is here, and every other client executes the statement here.
var _property = Info[name].name;
var _newvalue = This.data[_property];
_root[_property].text = _newvalue;
Break
Case "Success":
When the event type is "successful": note that when the change on this client triggers itself to be "successful", the other client is "change";
Break
Case "Reject":
When the event type is "modified unsuccessfully":
Break
Case "Clear":
This use is relatively few, is not very clear, according to the meaning of English self is also not very understanding:
This value was received by a Flash player, that connected to a sharedobject for the "the".
Clear is also sent if the server and client data are so far out of sync that client dumps
Its version of the Sharedobject and resynchronizes itself completely.
Break
Case "Delete":
When MYSO to delete
Break
Trace ("Data is updated");
}
}
}
//

When it comes to My_so having to mention the My_so.send () function (which I like to use), it's also a kind of Onsync broadcast event. This is very useful.
Usage:

Myso.send ("Toggleball", variable 1, variable 2 ...);
Myso property functions that correspond to the client or server side:
Myso.toggleball=function (variable 1, variable 2 ...) {
This function executes on all other clients, just like the Onsync effect
}
<!--/message-->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.