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.
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
22 ASSetNative
= ASnative
(4, 0);
23 ASSetNativeAccessor
= ASnative
(4, 1);
26 /* Only Flash extensions here, rest to swfdec_as_initialize.as */
28 Object.registerClass
= ASnative
(101, 8);
29 ASSetPropFlags
(Object, null, 7);
31 /*** ASBROADCASTER ***/
33 function AsBroadcaster
() { };
35 AsBroadcaster
.broadcastMessage
= ASnative
(101, 12);
37 AsBroadcaster
.addListener
= function (x
) {
38 this.removeListener
(x
);
39 this._listeners
.push
(x
);
43 AsBroadcaster
.removeListener
= function (x
) {
44 var l
= this._listeners
;
47 for (var i
= 0; i
< l
.length
; i
++) {
56 AsBroadcaster
.initialize
= function (o
) {
57 o
.broadcastMessage
= ASnative
(101, 12);
58 o
.addListener
= AsBroadcaster
.addListener
;
59 o
.removeListener
= AsBroadcaster
.removeListener
;
61 ASSetPropFlags
(o
, "broadcastMessage,addListener,removeListener,_listeners", 131);
63 ASSetPropFlags
(AsBroadcaster
, null, 131);
65 Key
= { ALT
: 18, BACKSPACE
: 8, CAPSLOCK
: 20, CONTROL
: 17, DELETEKEY
: 46,
66 DOWN
: 40, END
: 35, ENTER
: 13, ESCAPE
: 27, HOME
: 36, INSERT
: 45, LEFT
: 37,
67 PGDN
: 34, PGUP
: 33, RIGHT
: 39, SHIFT
: 16, SPACE
: 32, TAB
: 9, UP
: 38 };
68 ASSetNative
(Key
, 800, "getAscii,getCode,isDown");
69 AsBroadcaster
.initialize
(Key
);
70 ASSetPropFlags
(Key
, null, 7);
75 Mouse.show
= ASnative
(5, 0);
76 Mouse.hide
= ASnative
(5, 1);
77 AsBroadcaster
.initialize
(Mouse);
78 ASSetPropFlags
(Mouse, null, 7);
83 AsBroadcaster
.initialize
(Stage);
84 ASSetNativeAccessor
(Stage, 666, "scaleMode,align,width,height", 1);
88 function LoadVars
() { };
90 LoadVars
.prototype
.contentType
= "application/x-www-form-urlencoded";
92 LoadVars
.prototype
.load
= ASnative
(301, 0);
93 //LoadVars.prototype.send = ASnative (301, 1);
94 //LoadVars.prototype.sendAndLoad = ASnative (301, 2);
95 LoadVars
.prototype
.decode
= ASnative
(301, 3);
97 LoadVars
.prototype
.onLoad
= function () {
100 LoadVars
.prototype
.onData
= function (src
) {
110 LoadVars
.prototype
.toString
= function () {
112 for (var x
in this) {
114 str
= escape
(x
) + "=" + escape
(this[x
]);
116 str
+= "&" + escape
(x
) + "=" + escape
(this[x
]);
122 LoadVars
.prototype
.getBytesLoaded
= function () {
123 return this._bytesLoaded
;
126 LoadVars
.prototype
.getBytesTotal
= function () {
127 return this._bytesTotal
;
130 ASSetPropFlags
(LoadVars
.prototype
, null, 131);
134 Sound = ASconstructor
(500, 16);
135 ASSetNative
(Sound.prototype
, 500, "stop,attachSound,start", 6);
139 XMLNode = ASconstructor
(253, 0);
141 XMLNode.prototype
.cloneNode
= ASnative
(253, 1);
142 XMLNode.prototype
.removeNode
= ASnative
(253, 2);
143 XMLNode.prototype
.insertBefore
= ASnative
(253, 3);
144 XMLNode.prototype
.appendChild
= ASnative
(253, 4);
145 XMLNode.prototype
.hasChildNodes
= ASnative
(253, 5);
146 XMLNode.prototype
.toString
= ASnative
(253, 6);
147 XMLNode.prototype
.getNamespaceForPrefix
= ASnative
(253, 7);
148 XMLNode.prototype
.getPrefixForNamespace
= ASnative
(253, 8);
152 XML = ASconstructor
(253, 9);
154 XML.prototype
= new XMLNode (1, "");
155 ASSetPropFlags
(XML, "prototype", 3);
157 XML.prototype
.load
= ASnative
(301, 0);
158 //XML.prototype.send = ASnative (301, 1);
159 //XML.prototype.sendAndLoad = ASnative (301, 2);
160 XML.prototype
.createElement
= ASnative
(253, 10);
161 XML.prototype
.createTextNode
= ASnative
(253, 11);
162 XML.prototype
.parseXML
= ASnative
(253, 12);
164 XML.prototype
.onLoad
= function () {
167 // Note: handling of loaded is different here than in LoadVars
168 XML.prototype
.onData
= function (src
) {
179 XML.prototype
.getBytesLoaded
= function () {
180 return this._bytesLoaded
;
183 XML.prototype
.getBytesTotal
= function () {
184 return this._bytesTotal
;
190 System.capabilities
= {};
191 System.capabilities
.Query
= ASnative
(11, 0);
192 System.capabilities
.Query
();
193 delete System.capabilities
.Query
;
197 Color = function (target
) {
198 this.target
= target
;
199 ASSetPropFlags
(this, null, 7);
201 ASSetNative
(Color.prototype
, 700, "setRGB,setTransform,getRGB,getTransform");
202 ASSetPropFlags
(Color.prototype
, null, 7);
206 MovieClip.prototype
.meth
= function (method
) {
207 var lower
= method
.toLowerCase
();
208 if (lower
== "post") {
210 } else if (lower
== "get") {
217 MovieClip.prototype
.getURL
= function (url
, target
, method
) {
218 if (typeof (target
) == "undefined")
219 target
= ""; // undefined to empty string, even in version >= 7
221 var type
= this.meth
(method
);
223 getURL
(url
, target
);
224 } else if (type
== 1) {
225 getURL
(url
, target
, "GET");
227 getURL
(url
, target
, "POST");
231 // work around ming bug, causing loadVariables to be lower cased
232 MovieClip.prototype
["loadVariables"] = function (url
, method
) {
233 var type
= this.meth
(method
);
236 loadVariables
(url
, this._target
);
237 } else if (type
== 1) {
238 loadVariables
(url
, this._target
, "GET");
240 loadVariables
(url
, this._target
, "POST");
245 // work around ming bug, causing loadMovie to be lower cased
246 MovieClip.prototype
["loadMovie"] = function (url
, method
) {
247 var type
= this.meth
(method
);
250 loadMovie
(url
, this._target
);
251 } else if (type
== 1) {
252 loadMovie
(url
, this._target
, "GET");
254 loadMovie
(url
, this._target
, "POST");
259 MovieClip.prototype
.attachMovie
= ASnative
(900, 0);
260 MovieClip.prototype
.swapDepths
= ASnative
(900, 1);
261 MovieClip.prototype
.hitTest
= ASnative
(900, 4);
262 MovieClip.prototype
.getBounds
= ASnative
(900, 5);
263 MovieClip.prototype
.getBytesTotal
= ASnative
(900, 6);
264 MovieClip.prototype
.getBytesLoaded
= ASnative
(900, 7);
265 MovieClip.prototype
.getDepth
= ASnative
(900, 10);
266 MovieClip.prototype
.play
= ASnative
(900, 12);
267 MovieClip.prototype
.stop
= ASnative
(900, 13);
268 MovieClip.prototype
.nextFrame
= ASnative
(900, 14);
269 MovieClip.prototype
.prevFrame
= ASnative
(900, 15);
270 MovieClip.prototype
.gotoAndPlay
= ASnative
(900, 16);
271 MovieClip.prototype
.gotoAndStop
= ASnative
(900, 17);
272 // work around ming bug, causing these two to be lower cased
273 MovieClip.prototype
["duplicateMovieClip"] = ASnative
(900, 18);
274 MovieClip.prototype
["removeMovieClip"] = ASnative
(900, 19);
275 MovieClip.prototype
.startDrag
= ASnative
(900, 20);
276 MovieClip.prototype
.stopDrag
= ASnative
(900, 21);
278 ASSetPropFlags
(MovieClip.prototype
, "getDepth", 128);
280 ASSetNative
(MovieClip.prototype
, 901, "6createEmptyMovieClip,6beginFill,6beginGradientFill,6moveTo,6lineTo,6curveTo,6lineStyle,6endFill,6clear");
281 ASSetPropFlags
(MovieClip.prototype
, null, 3);
289 TextFormat = ASconstructor
(110, 0);
291 /* TextField.Stylesheet */
293 TextField.StyleSheet = ASconstructor
(113, 0);
295 TextField.StyleSheet.prototype
._copy
= function (o
) {
296 if (typeof (o
) != "object")
300 for (var prop
in o
) {
301 o_new
[prop
] = o
[prop
];
306 TextField.StyleSheet.prototype
.clear
= function () {
311 TextField.StyleSheet.prototype
.getStyle
= function (name
) {
312 return (this._copy
(this._css
[name
]));
315 TextField.StyleSheet.prototype
.setStyle
= function (name
, style
) {
319 this._css
[name
] = this._copy
(style
);
320 this.doTransform
(name
);
323 TextField.StyleSheet.prototype
.getStyleNames
= function () {
324 var tmp
= this._css
; /* ming bug? */
326 for (var prop
in tmp
) {
332 TextField.StyleSheet.prototype
.doTransform
= function (name
) {
336 this._styles
[name
] = this.transform
(this._css
[name
]);
339 TextField.StyleSheet.prototype
.transform
= function (style
) {
343 var format
= new TextFormat ();
346 format
.align
= style
.textAlign
;
348 if (style
.fontWeight
== "bold") {
350 } else if (style
.fontWeight
== "normal") {
355 var tmp
= this.parseColor
(style
.color
);
360 format
.display
= style
.display
;
362 if (style
.fontFamily
)
363 format
.font
= this.parseCSSFontFamily
(style
.fontFamily
);
365 if (style
.textIndent
)
366 format
.indent
= parseInt
(style
.textIndent
);
368 if (style
.fontStyle
== "italic") {
369 format
.italic
= true;
370 } else if (style
.fontStyle
== "normal") {
371 format
.italic
= false;
374 if (style
.kerning
== "true") {
375 format
.kerning
= true;
376 } else if (style
.kerning
== "false") {
377 format
.kerning
= false;
379 format
.kerning
= parseInt
(style
.kerning
);
383 format
.leading
= parseInt
(style
.leading
);
385 if (style
.marginLeft
)
386 format
.leftMargin
= parseInt
(style
.marginLeft
);
388 if (style
.letterSpacing
)
389 format
.letterSpacing
= parseInt
(style
.letterSpacing
);
391 if (style
.marginRight
)
392 format
.rightMargin
= parseInt
(style
.marginRight
);
394 if (style
.fontSize
) {
395 var tmp
= parseInt
(style
.fontSize
);
400 if (style
.textDecoration
== "underline") {
401 format
.underline
= true;
402 } else if (style
.textDecoration
== "none") {
403 format
.underline
= false;
409 TextField.StyleSheet.prototype
.parseCSS
= function (css
) {
410 var result
= this.parseCSSInternal
(css
);
411 if (typeof (result
) == "null")
417 for (var prop
in result
) {
418 this._css
[prop
] = this._copy
(result
[prop
]);
419 this.doTransform
(prop
);
425 TextField.StyleSheet.prototype
.parse
= TextField.StyleSheet.prototype
.parseCSS
;
427 TextField.StyleSheet.prototype
.load
= ASnative
(301, 0);
429 TextField.StyleSheet.prototype
.onLoad
= function () {
432 TextField.StyleSheet.prototype
.onData
= function (src
) {
434 var result
= this.parse
(src
);
435 this.loaded
= result
;
436 this.onLoad
(result
);
442 TextField.StyleSheet.prototype
.parseCSSInternal
= ASnative
(113, 101);
443 TextField.StyleSheet.prototype
.parseCSSFontFamily
= ASnative
(113, 102);
444 TextField.StyleSheet.prototype
.parseColor
= ASnative
(113, 103);
445 ASSetPropFlags
(TextField.StyleSheet.prototype
, null, 1027);
446 ASSetPropFlags
(TextField, "StyleSheet", 1027);
448 /* Global Functions */
450 setInterval
= ASnative
(250, 0);
451 clearInterval
= ASnative
(250, 1);
452 setTimeout
= ASnative
(250, 2);
453 clearTimeout
= clearInterval
;
455 /*** OH THE HUMANITY ***/
459 /*** GLOBAL PROPFLAGS */
461 ASSetPropFlags
(this, null, 1, 6);