source: Dev/branches/rest-dojo-ui/client/dojox/embed/flashVars.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.8 KB
Line 
1define(['dojo'],function(dojo){
2
3dojo.getObject("dojox.embed", true);
4dojo.deprecated("dojox.embed.flashVars", "Will be removed in 2.0", "2.0");
5
6dojox.embed.flashVars = {
7        //      summary
8        //              Handles flashvar serialization
9        //              Converting complex objects into a simple, clear string that can be appended
10        //              to the swf as a query: myMovie.swf?flashvars=foo.
11        //              Note this needs to work with the SWF, which must know what variables to expect.
12        //              Therefore this is something of an "internal" class - unless you know how to
13        //              modify or create SWFs.
14        //
15        //      description:
16        //              JSON could be done, but Deft does not yet have a JSON parser, and quotes are
17        //              very problematic since Flash cannot use eval(); JSON parsing was successful
18        //              when it was fully escaped, but that made it very large anyway. flashvar
19        //              serialization at most is 200% larger than JSON.
20        //
21        //      See:
22        //              Deft/common/flashVars.as
23        //
24        serialize: function(/* String */n, /*Object*/o){
25                // summary:
26                //              Key method. Serializes an object.
27                //      n:String
28                //              The name for the object, such as: "button"
29                //      o:Object
30                //              The object to serialize
31                //
32                var esc = function(val){
33                        //      have to encode certain characters that indicate an object
34                        if(typeof val=="string"){
35                                val = val.replace(/;/g,"_sc_");
36                                val = val.replace(/\./g,"_pr_");
37                                val = val.replace(/\:/g,"_cl_");
38                                //val = escape(val);
39                        }
40                        return val;
41                };
42                var df = dojox.embed.flashVars.serialize;
43                var txt = "";
44                if(dojo.isArray(o)){
45                        for(var i=0;i<o.length;i++){
46                                txt += df(n+"."+i, esc(o[i]))+";";
47                        }
48                        return txt.replace(/;{2,}/g,";");
49                }else if(dojo.isObject(o)){
50                        for(var nm in o){
51                                txt += df(n+"."+nm, esc(o[nm]))+";";
52                        }
53                        return txt.replace(/;{2,}/g,";");
54                }
55                // Dev note: important that there is no double semi-colons
56                return n+":"+o; // String
57        }
58};
59return dojox.embed.flashVars;
60});
Note: See TracBrowser for help on using the repository browser.