only check as many Flash versions as we have functions for
[swfdec.git] / libswfdec / swfdec_initialize.as
blob009bbccf4a9143e1b0da756374214adb7970a084
1 /* Swfdec
2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 /*** GENERAL ***/
22 ASSetNative = ASnative (4, 0);
23 ASSetNativeAccessor = ASnative (4, 1);
25 /*** ASBROADCASTER ***/
27 function AsBroadcaster () { };
29 AsBroadcaster.broadcastMessage = ASnative(101, 12);
31 AsBroadcaster.addListener = function (x) {
32 this.removeListener (x);
33 this._listeners.push (x);
34 return true;
37 AsBroadcaster.removeListener = function (x) {
38 var l = this._listeners;
39 var i;
41 for (var i = 0; i < l.length; i++) {
42 if (l[i] == x) {
43 l.splice (i, 1);
44 return true;
47 return false;
50 AsBroadcaster.initialize = function (o) {
51 o.broadcastMessage = ASnative(101, 12);
52 o.addListener = AsBroadcaster.addListener;
53 o.removeListener = AsBroadcaster.removeListener;
54 o._listeners = new Array ();
55 ASSetPropFlags(o, "broadcastMessage,addListener,removeListener,_listeners", 131);
57 ASSetPropFlags(AsBroadcaster, null, 131);
59 Key = { ALT: 18, BACKSPACE: 8, CAPSLOCK: 20, CONTROL: 17, DELETEKEY: 46,
60 DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37,
61 PGDN: 34, PGUP: 33, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38 };
62 ASSetNative(Key, 800, "getAscii,getCode,isDown");
63 AsBroadcaster.initialize(Key);
64 ASSetPropFlags(Key, null, 7);
66 /*** MOUSE ***/
68 Mouse = new Object ();
69 Mouse.show = ASnative (5, 0);
70 Mouse.hide = ASnative (5, 1);
71 AsBroadcaster.initialize (Mouse);
73 /*** STAGE ***/
75 Stage = new Object ();
76 AsBroadcaster.initialize (Stage);
77 ASSetNativeAccessor (Stage, 666, "scaleMode,align,width,height", 1);
79 /*** LOADVARS ***/
81 function LoadVars () { };
83 LoadVars.prototype.contentType = "application/x-www-form-urlencoded";
85 LoadVars.prototype.load = ASnative (301, 0);
86 //LoadVars.prototype.send = ASnative (301, 1);
87 //LoadVars.prototype.sendAndLoad = ASnative (301, 2);
88 LoadVars.prototype.decode = ASnative (301, 3);
90 LoadVars.prototype.onLoad = function () {
93 LoadVars.prototype.onData = function (src) {
94 this.loaded = true;
95 if (src != null) {
96 this.decode (src);
97 this.onLoad (true);
98 } else {
99 this.onLoad (false);
103 LoadVars.prototype.toString = function () {
104 var str = null;
105 for (var x in this) {
106 if (str == null) {
107 str = escape(x) + "=" + escape(this[x]);
108 } else {
109 str += "&" + escape(x) + "=" + escape(this[x]);
112 return str;
115 LoadVars.prototype.getBytesLoaded = function () {
116 return this._bytesLoaded;
119 LoadVars.prototype.getBytesTotal = function () {
120 return this._bytesTotal;
123 ASSetPropFlags(LoadVars.prototype, null, 129);