├── MIT-LICENSE.txt
├── README.md
├── cs3.js
├── examples
├── 3dcarousels.html
├── README.txt
├── img
│ └── Flap.png
├── index.html
├── mousepaint.html
├── particles.html
└── particles_ie9.html
├── index.html
├── src
└── cs3
│ ├── core.js
│ ├── display
│ ├── Bitmap.js
│ ├── BitmapData.js
│ ├── BitmapDataChannel.js
│ ├── CapsStyle.js
│ ├── DisplayObject.js
│ ├── DisplayObjectContainer.js
│ ├── Graphics.js
│ ├── InteractiveObject.js
│ ├── JointStyle.js
│ ├── Loader.js
│ ├── LoaderInfo.js
│ ├── Shape.js
│ ├── Sprite.js
│ ├── Stage.js
│ ├── StageAlign.js
│ ├── StageRenderMode.js
│ └── StageScaleMode.js
│ ├── events
│ ├── Event.js
│ ├── EventDispatcher.js
│ ├── EventListener.js
│ ├── HTTPStatusEvent.js
│ ├── IOErrorEvent.js
│ ├── KeyboardEvent.js
│ ├── MouseEvent.js
│ ├── ProgressEvent.js
│ ├── TimerEvent.js
│ └── TweenEvent.js
│ ├── filters
│ ├── BitmapFilter.js
│ ├── BlurFilter.js
│ ├── ColorMatrixFilter.js
│ ├── ContextFilter.js
│ └── DropShadowFilter.js
│ ├── geom
│ ├── ColorTransform.js
│ ├── Matrix.js
│ ├── MatrixTransformer.js
│ ├── Point.js
│ ├── Rectangle.js
│ └── Transform.js
│ ├── media
│ ├── Sound.js
│ └── Video.js
│ ├── net
│ ├── URLLoader.js
│ ├── URLLoaderDataFormat.js
│ ├── URLRequest.js
│ ├── URLRequestMethod.js
│ └── URLVariables.js
│ ├── text
│ ├── TextField.js
│ ├── TextFormat.js
│ └── TextFormatAlign.js
│ ├── transitions
│ └── Tween.js
│ └── utils
│ ├── ByteArray.js
│ ├── CoordinateShuffler.js
│ ├── Endian.js
│ ├── Timer.js
│ └── getTimer.js
└── tests
├── README.txt
├── bitmapdata_applyfilter.html
├── bitmapdata_colortransform.html
├── bitmapdata_copychannel.html
├── bitmapdata_copypixels.html
├── bitmapdata_fillrect.html
├── bitmapdata_floodfill.html
├── bitmapdata_merge.html
├── bitmapdata_noise.html
├── bitmapdata_palletmap.html
├── bitmapdata_pixeldissolve.html
├── bitmapdata_scroll.html
├── bitmapdata_threshold.html
├── css
└── test.css
├── displayobject_getbounds.html
├── displayobject_hittestobject.html
├── displayobject_hittestpoint.html
├── displayobject_mask.html
├── graphics_beginbitmapfill.html
├── graphics_beginlineargradientfill.html
├── graphics_beginradialgradientfill.html
├── graphics_curveto.html
├── graphics_drawarc.html
├── graphics_drawcircle.html
├── graphics_drawellipse.html
├── graphics_drawrect.html
├── graphics_drawroundrect.html
├── graphics_linestyle.html
├── graphics_lineto.html
├── img
├── Flap.png
├── floodfilltest.gif
├── pattern.png
├── photo01.jpg
└── photo02.jpg
├── index.html
├── js
└── test.js
├── keyboardevent_keydown.html
├── keyboardevent_keyup.html
├── loader_load.html
├── mouseevent_click.html
├── mouseevent_doubleclick.html
├── mouseevent_mousedown.html
├── mouseevent_mouseout.html
├── mouseevent_mouseover.html
├── mouseevent_mouseup.html
├── mouseevent_mousewheel.html
├── mouseevent_rollout.html
├── mouseevent_rollover.html
├── rendering_displaylist.html
├── rendering_layers.html
├── sprite_startdrag.html
├── tween_looping.html
├── tween_start.html
└── tween_yoyo.html
/MIT-LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010 ARAKI Hayato
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | CanvasScript3
2 | ======
3 | Warning: This project is still in Development.
4 |
5 | CanvasScript3 is a Javascript sprite library for HTML5 Canvas similar to FLASH/ActionScript3.
6 |
7 | ### Tested browsers ###
8 | Opera 10.51
9 | Chrome 5.0.375.55
10 | Firefox 3.6.3
11 | Safari 4.0.5
12 | Safari 5.0
13 |
14 | ### Documentation ###
15 |
16 | not comming soon..
17 |
18 | ### Examples ###
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/3dcarousels.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 3D Carousels
6 |
7 |
106 |
126 |
127 |
128 |
129 | FPS:
130 |
131 |
--------------------------------------------------------------------------------
/examples/README.txt:
--------------------------------------------------------------------------------
1 | For some of the examples which use images you must access the page through a web server to make it work.
2 |
--------------------------------------------------------------------------------
/examples/img/Flap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arahaya/CanvasScript3/909dda54e1388eb0809aad420edad5d1e3ed39b1/examples/img/Flap.png
--------------------------------------------------------------------------------
/examples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
10 | CanvasScript3 Examples
11 |
12 |
13 | CanvasScript3 Examples
14 | Animation
15 |
22 | Drawing
23 |
26 |
27 |
--------------------------------------------------------------------------------
/examples/mousepaint.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Drawing
6 |
7 |
120 |
140 |
141 |
142 |
143 | FPS:
144 |
145 |
--------------------------------------------------------------------------------
/examples/particles.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Particles
6 |
7 |
190 |
206 |
207 |
208 |
209 | FPS:
210 |
211 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 | CanvasScript3
10 |
11 |
12 | CanvasScript3
13 |
18 |
19 |
--------------------------------------------------------------------------------
/src/cs3/display/Bitmap.js:
--------------------------------------------------------------------------------
1 | var Bitmap = new Class(DisplayObject, function()
2 | {
3 | this.__init__ = function(bitmapData)
4 | {
5 | DisplayObject.call(this);
6 |
7 | this.__bitmapData = null;
8 |
9 | if (bitmapData)
10 | {
11 | this.__set__bitmapData(bitmapData);
12 | }
13 | };
14 |
15 | //override
16 | this.__getContentBounds = function()
17 | {
18 | if (this.__bitmapData)
19 | {
20 | return this.__bitmapData.__rect.clone();
21 | }
22 | return new Rectangle();
23 | };
24 |
25 | //override
26 | this.__getAsBitmap = function()
27 | {
28 | if (this.__bitmapData)
29 | {
30 | return this;
31 | }
32 | return null;
33 | };
34 |
35 | //override
36 | this.__getModified = function()
37 | {
38 | if (this.__modified)
39 | {
40 | return true;
41 | }
42 | if (this.__transform.__modified)
43 | {
44 | return true;
45 | }
46 | if (this.__bitmapData && this.__bitmapData.__modified)
47 | {
48 | return true;
49 | }
50 | return false;
51 | };
52 |
53 | //override
54 | this.__setModified = function(v)
55 | {
56 | this.__modified = v;
57 | this.__transform.__modified = v;
58 | if (this.__bitmapData)
59 | {
60 | this.__bitmapData.__modified = v;
61 | }
62 | };
63 |
64 | //override
65 | this.__render = function(context, colorTransform)
66 | {
67 | if (this.__bitmapData)
68 | {
69 | this.__bitmapData.__render(context, colorTransform);
70 | }
71 | };
72 |
73 | //override
74 | this.__hitTestPoint = function(context, matrix, point)
75 | {
76 | if (this.__bitmapData)
77 | {
78 | var bounds = this.__getContentBounds();
79 |
80 | //convert point to local coords
81 | var invertedMatrix = matrix.clone();
82 | invertedMatrix.invert();
83 | var localPoint = invertedMatrix.transformPoint(point);
84 |
85 | if (bounds.containsPoint(localPoint))
86 | {
87 | //fix the points back to ints
88 | localPoint.x = localPoint.x | 0;
89 | localPoint.y = localPoint.y | 0;
90 | try
91 | {
92 | return (this.__bitmapData.getImageData(localPoint.x, localPoint.y, 1, 1).data[3] !== 0);
93 | }
94 | catch (e)
95 | {
96 | /**
97 | * if the bitmap source is on a different domain
98 | * we can't call getImageData so return true
99 | * as if it was a hitTest with shapeflag=false
100 | */
101 | return true;
102 | }
103 | }
104 | }
105 | return false;
106 | };
107 |
108 | /* getters and setters */
109 | this.__get__bitmapData = function()
110 | {
111 | return this.__bitmapData;
112 | };
113 |
114 | this.__set__bitmapData = function(v)
115 | {
116 | this.__bitmapData = v;
117 | this.__modified = true;
118 | };
119 |
120 | this.__get__pixelSnapping = function()
121 | {
122 | //not supported
123 | return false;
124 | };
125 |
126 | this.__set__pixelSnapping = function(v)
127 | {
128 | //not supported
129 | };
130 |
131 | this.__get__smoothing = function()
132 | {
133 | //not supported
134 | return false;
135 | };
136 |
137 | this.__set__smoothing = function(v)
138 | {
139 | //not supported
140 | };
141 |
142 | this.toString = function()
143 | {
144 | return '[object Bitmap]';
145 | };
146 | });
147 |
--------------------------------------------------------------------------------
/src/cs3/display/BitmapDataChannel.js:
--------------------------------------------------------------------------------
1 | var BitmapDataChannel = {
2 | RED: 1,
3 | GREEN: 2,
4 | BLUE: 4,
5 | ALPHA: 8
6 | };
7 |
--------------------------------------------------------------------------------
/src/cs3/display/CapsStyle.js:
--------------------------------------------------------------------------------
1 | CapsStyle = {
2 | NONE: 'butt',
3 | ROUND: 'round',
4 | SQUARE: 'square'
5 | };
6 |
--------------------------------------------------------------------------------
/src/cs3/display/InteractiveObject.js:
--------------------------------------------------------------------------------
1 | var InteractiveObject = new Class(DisplayObject, function()
2 | {
3 | this.__init__ = function()
4 | {
5 | DisplayObject.call(this);
6 | //this.doubleClickEnabled = true;
7 | this.mouseEnabled = true;
8 | //this.tabEnabled = true;
9 | //this.tabIndex = 0;
10 | //this.focusRect = null;
11 | };
12 |
13 | this.toString = function()
14 | {
15 | return '[object InteractiveObject]';
16 | };
17 | });
18 |
--------------------------------------------------------------------------------
/src/cs3/display/JointStyle.js:
--------------------------------------------------------------------------------
1 | JointStyle = {
2 | BEVEL: 'bevel',
3 | ROUND: 'round',
4 | MITER: 'miter'
5 | };
6 |
--------------------------------------------------------------------------------
/src/cs3/display/Loader.js:
--------------------------------------------------------------------------------
1 | var Loader = new Class(DisplayObjectContainer, function()
2 | {
3 | var noImplement = function()
4 | {
5 | throw new Error("The Loader class does not implement this method.");
6 | };
7 |
8 | /* @constructor */
9 | this.__init__ = function()
10 | {
11 | DisplayObjectContainer.call(this);
12 | this.__content = null;
13 | this.__contentLoaderInfo = new LoaderInfo(this);
14 | this.__img = null;
15 | };
16 |
17 | /* @override DisplayObject */
18 | this.__getAsBitmap = function()
19 | {
20 | if (this.__content)
21 | {
22 | return this.__content.__getAsBitmap();
23 | }
24 | return null;
25 | };
26 |
27 | /* @override DisplayObject */
28 | this.__getModified = function()
29 | {
30 | if (this.__modified)
31 | {
32 | return true;
33 | }
34 | if (this.__transform.__modified)
35 | {
36 | return true;
37 | }
38 | return false;
39 | };
40 |
41 | /* @override DisplayObject */
42 | this.__setModified = function(v)
43 | {
44 | this.__modified = v;
45 | this.__transform.__modified = v;
46 | };
47 |
48 | /* @override DisplayObject */
49 | this.__render = function(context, colorTransform)
50 | {
51 | if (!this.__content)
52 | {
53 | return;
54 | }
55 |
56 | this.__renderChildren(context, colorTransform);
57 | };
58 |
59 | this.load = function(request)
60 | {
61 | if (typeof request == 'string')
62 | {
63 | request = new URLRequest(request);
64 | }
65 |
66 | if (this.__content)
67 | {
68 | this.unload();
69 | }
70 |
71 | var img = new Image();
72 | var self = this;
73 | img.onload = function(e)
74 | {
75 | //convert HTMLImageElement to BitmapData(HTMLCanvasElement)
76 | var bitmapData = new BitmapData(this.width, this.height, false, 0x00000000);
77 | bitmapData.__context.drawImage(this, 0, 0);
78 | self.__content = new Bitmap(bitmapData);
79 |
80 | //add content as a child
81 | self.__addChildAt(self.__content, 0);
82 |
83 | var contentLoaderInfo = self.__contentLoaderInfo;
84 | contentLoaderInfo.__content = self.__content;
85 | contentLoaderInfo.__width = bitmapData.__width;
86 | contentLoaderInfo.__height = bitmapData.__height;
87 | contentLoaderInfo.dispatchEvent(new Event(Event.INIT, false, false));
88 | contentLoaderInfo.dispatchEvent(new Event(Event.COMPLETE, false, false));
89 | self.close();
90 | };
91 | img.onerror = function(e)
92 | {
93 | self.__contentLoaderInfo.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false));
94 | self.close();
95 | };
96 | img.onabort = function(e)
97 | {
98 | self.close();
99 | };
100 | img.src = request.__url;
101 | this.__img = img;
102 | };
103 |
104 | this.unload = function()
105 | {
106 | if (this.__content)
107 | {
108 | this.__removeChildAt(0);
109 | this.__content = null;
110 | var contentLoaderInfo = this.__contentLoaderInfo;
111 | contentLoaderInfo.__content = null;
112 | contentLoaderInfo.__width = 0;
113 | contentLoaderInfo.__height = 0;
114 | contentLoaderInfo.dispatchEvent(new Event(Event.UNLOAD, false, false));
115 | }
116 | };
117 |
118 | this.close = function()
119 | {
120 | this.__img.src = null;
121 | this.__img.onload = null;
122 | this.__img.onerror = null;
123 | this.__img.onabort = null;
124 | this.__img = null;
125 | };
126 |
127 | this.addChild = noImplement;
128 | this.addChildAt = noImplement;
129 | this.removeChild = noImplement;
130 | this.removeChildAt = noImplement;
131 | this.setChildIndex = noImplement;
132 |
133 | /* getters and setters */
134 | this.__get__content = function()
135 | {
136 | return this.__content;
137 | };
138 |
139 | this.__get__contentLoaderInfo = function()
140 | {
141 | return this.__contentLoaderInfo;
142 | };
143 |
144 | this.toString = function()
145 | {
146 | return '[object Loader]';
147 | };
148 | });
149 |
--------------------------------------------------------------------------------
/src/cs3/display/LoaderInfo.js:
--------------------------------------------------------------------------------
1 | var LoaderInfo = new Class(EventDispatcher, function()
2 | {
3 | this.__init__ = function()
4 | {
5 | EventDispatcher.call(this);
6 | this.__content = null;
7 | this.__width = 0;
8 | this.__height = 0;
9 | };
10 |
11 | /* getters and setters */
12 | this.__get__content = function()
13 | {
14 | return this.__content;
15 | };
16 | this.__get__width = function()
17 | {
18 | return this.__width;
19 | };
20 | this.__get__height = function()
21 | {
22 | return this.__height;
23 | };
24 |
25 | this.toString = function()
26 | {
27 | return '[object LoaderInfo]';
28 | };
29 | });
30 |
--------------------------------------------------------------------------------
/src/cs3/display/Shape.js:
--------------------------------------------------------------------------------
1 | var Shape = new Class(DisplayObject, function()
2 | {
3 | this.__init__ = function()
4 | {
5 | DisplayObject.call(this);
6 | this.__graphics = null;
7 | };
8 |
9 | //override
10 | this.__getContentBounds = function()
11 | {
12 | if (this.__graphics)
13 | {
14 | return this.__graphics.__rect.clone();
15 | }
16 | return new Rectangle();
17 | };
18 |
19 | //override
20 | this.__getModified = function()
21 | {
22 | if (this.__modified)
23 | {
24 | return true;
25 | }
26 | if (this.__transform.__modified)
27 | {
28 | return true;
29 | }
30 | if (this.__graphics && this.__graphics.__modified)
31 | {
32 | return true;
33 | }
34 | return false;
35 | };
36 |
37 | //override
38 | this.__setModified = function(v)
39 | {
40 | this.__modified = v;
41 | this.__transform.__modified = v;
42 | if (this.__graphics)
43 | {
44 | this.__graphics.__modified = v;
45 | }
46 | };
47 |
48 | //override
49 | this.__render = function(context, colorTransform)
50 | {
51 | if (this.__graphics)
52 | {
53 | this.__graphics.__render(context, colorTransform);
54 | }
55 | };
56 |
57 | //override
58 | this.__hitTestPoint = function(context, matrix, point)
59 | {
60 | if (this.__graphics)
61 | {
62 | var bounds = this.__getContentBounds();
63 |
64 | //convert point to local coords
65 | var invertedMatrix = matrix.clone();
66 | invertedMatrix.invert();
67 | var localPoint = invertedMatrix.transformPoint(point);
68 |
69 | if (bounds.containsPoint(localPoint))
70 | {
71 | this.__graphics.__render(context, null);
72 | return (context.getImageData(point.x, point.y, 1, 1).data[3] !== 0);
73 | }
74 | }
75 | return false;
76 | };
77 |
78 | /* getters and setters */
79 | this.__get__graphics = function()
80 | {
81 | if (this.__graphics === null)
82 | {
83 | this.__graphics = new Graphics();
84 | }
85 | return this.__graphics;
86 | };
87 |
88 | this.toString = function()
89 | {
90 | return '[object Shape]';
91 | };
92 | });
93 |
--------------------------------------------------------------------------------
/src/cs3/display/Sprite.js:
--------------------------------------------------------------------------------
1 | var Sprite = new Class(DisplayObjectContainer, function()
2 | {
3 | this.__init__ = function()
4 | {
5 | DisplayObjectContainer.call(this);
6 | this.__graphics = null;
7 | //this.__dropTarget = null;
8 | this.buttonMode = false;
9 | //this.hitArea = null;
10 | //this.soundTransform = null;
11 | this.useHandCursor = true;
12 | };
13 |
14 | /* @override DisplayObject */
15 | this.__getContentBounds = Shape.prototype.__getContentBounds;
16 |
17 | /* @override DisplayObject */
18 | this.__getModified = Shape.prototype.__getModified;
19 |
20 | /* @override DisplayObject */
21 | this.__setModified = Shape.prototype.__setModified;
22 |
23 | /* @override DisplayObject */
24 | this.__render = function(context, colorTransform)
25 | {
26 | if (this.__graphics)
27 | {
28 | this.__graphics.__render(context, colorTransform);
29 | }
30 |
31 | this.__renderChildren(context, colorTransform);
32 | };
33 |
34 | /* @override DisplayObject.__hitTestPoint */
35 | this.__hitTestPoint = Shape.prototype.__hitTestPoint;
36 |
37 | this.startDrag = function(lockCenter, bounds)
38 | {
39 | this.__stage.startDrag(this, lockCenter, bounds);
40 | };
41 |
42 | this.stopDrag = function()
43 | {
44 | this.__stage.stopDrag();
45 | };
46 |
47 | /* getters and setters */
48 | this.__get__graphics = Shape.prototype.__get__graphics;
49 |
50 | this.toString = function()
51 | {
52 | return '[object Sprite]';
53 | };
54 | });
55 |
--------------------------------------------------------------------------------
/src/cs3/display/StageAlign.js:
--------------------------------------------------------------------------------
1 | var StageAlign = {
2 | BOTTOM: 'B',
3 | BOTTOM_LEFT: 'BL',
4 | BOTTOM_RIGHT: 'BR',
5 | LEFT: 'L',
6 | RIGHT: 'R',
7 | TOP: 'T',
8 | TOP_LEFT: 'TL',
9 | TOP_RIGHT: 'TR'
10 | };
11 |
--------------------------------------------------------------------------------
/src/cs3/display/StageRenderMode.js:
--------------------------------------------------------------------------------
1 | var StageRenderMode = {
2 | ALL: 'all',
3 | DIRTY: 'dirty',
4 | AUTO: 'auto'
5 | };
6 |
--------------------------------------------------------------------------------
/src/cs3/display/StageScaleMode.js:
--------------------------------------------------------------------------------
1 | var StageScaleMode = {
2 | EXACT_FIT: 'exactFit',
3 | NO_BORDER: 'noBorder',
4 | NO_SCALE: 'noScale',
5 | SHOW_ALL: 'showAll'
6 | };
7 |
--------------------------------------------------------------------------------
/src/cs3/events/Event.js:
--------------------------------------------------------------------------------
1 | var Event = new Class(Object, function()
2 | {
3 | this.__init__ = function(type, bubbles, cancelable)
4 | {
5 | this.type = type;
6 | this.bubbles = (bubbles) ? true : false;
7 | this.cancelable = (cancelable) ? true : false;
8 | this.__preventDefault = false;
9 | this.__stopImmediatePropagation = false;
10 | this.__stopPropagation = false;
11 | };
12 |
13 | this.clone = function()
14 | {
15 | return new Event(this.type, this.bubbles, this.cancelable);
16 | };
17 |
18 | this.isDefaultPrevented = function()
19 | {
20 | return this.__preventDefault;
21 | };
22 |
23 | this.preventDefault = function()
24 | {
25 | this.__preventDefault = true;
26 | };
27 |
28 | this.stopImmediatePropagation = function()
29 | {
30 | this.__stopImmediatePropagation = true;
31 | };
32 |
33 | this.stopPropagation = function()
34 | {
35 | this.__stopPropagation = true;
36 | };
37 |
38 | this.toString = function()
39 | {
40 | return '[Event type=' + this.type + ' bubbles=' + this.bubbles + ' cancelable=' + this.cancelable + ']';
41 | };
42 | });
43 | Event.ACTIVATE = 'activate';
44 | Event.ADDED = 'added';
45 | Event.ADDED_TO_STAGE = 'addedToStage';
46 | Event.CANCEL = 'cancel';
47 | Event.CHANGE = 'change';
48 | Event.CLOSE = 'close';
49 | Event.COMPLETE = 'complete';
50 | Event.CONNECT = 'connect';
51 | Event.DEACTIVATE = 'deactivate';
52 | Event.ENTER_FRAME = 'enterFrame';
53 | Event.FULLSCREEN = 'fullScreen';
54 | Event.ID3 = 'id3';
55 | Event.INIT = 'init';
56 | Event.MOUSE_LEAVE = 'mouseLeave';
57 | Event.OPEN = 'open';
58 | Event.REMOVED = 'removed';
59 | Event.REMOVED_FROM_STAGE = 'removedFromStage';
60 | Event.RENDER = 'render';
61 | Event.RESIZE = 'resize';
62 | Event.SCROLL = 'scroll';
63 | Event.SELECT = 'select';
64 | Event.SOUND_COMPLETE = 'soundComplete';
65 | Event.TAB_CHILDREN_CHANGE = 'tabChildrenChange';
66 | Event.TAB_ENABLED_CHANGE = 'tabEnabledChange';
67 | Event.TAB_INDEX_CHANGE = 'tabIndexChange';
68 | Event.UNLOAD = 'unload';
69 |
--------------------------------------------------------------------------------
/src/cs3/events/EventDispatcher.js:
--------------------------------------------------------------------------------
1 | var EventDispatcher = new Class(Object, function()
2 | {
3 | var sortByPriority = function(a, b)
4 | {
5 | var p = 'priority';
6 | if (a[p] < b[p])
7 | {
8 | return 1;
9 | }
10 | else if (a[p] > b[p])
11 | {
12 | return -1;
13 | }
14 | else
15 | {
16 | return 0;
17 | }
18 | };
19 |
20 | this.__init__ = function()
21 | {
22 | this.__events = {};
23 | };
24 |
25 | /**
26 | * obj.addEventListener(type, listener, useCapture, priority);
27 | * obj.addEventListener(type, [scope, listener], useCapture, priority);
28 | * obj.addEventListener(type, new EventListener(scope, listener, useCapture, priority));
29 | */
30 | this.addEventListener = function(type, listener, useCapture, priority)
31 | {
32 | //TODO useCapture
33 | var events = this.__events;
34 |
35 | if (listener instanceof Function)
36 | {
37 | listener = new EventListener(this, listener, useCapture, priority);
38 | }
39 | else if (listener instanceof Array)
40 | {
41 | listener = new EventListener(listener[0], listener[1], useCapture, priority);
42 | }
43 |
44 | if (events[type] === undefined)
45 | {
46 | events[type] = [];
47 | }
48 |
49 | var listeners = events[type];
50 | listeners.push(listener);
51 | listeners.sort(sortByPriority);
52 | };
53 |
54 | this.dispatchEvent = function(event)
55 | {
56 | //TODO useCapture, priority
57 | //TODO when do you return false?
58 | //event = event.clone()
59 |
60 | //target only gets set once
61 | if (!event.target)
62 | {
63 | event.target = this;
64 | }
65 | event.currentTarget = this;
66 |
67 | var listeners = this.__events[event.type];
68 | if (listeners !== undefined)
69 | {
70 | for (var i = 0, l = listeners.length; i < l; ++i)
71 | {
72 | //events[i].call(this, event);
73 | //events[i](event);
74 | listeners[i].call(event);
75 | }
76 | }
77 | if (event.bubbles && this.__parent)
78 | {
79 | //var clone = event.clone();
80 | //pass the same target to the next event
81 | //clone.target = event.target;
82 | //return this.__parent.dispatchEvent(clone);
83 | return this.__parent.dispatchEvent(event);
84 | }
85 | else
86 | {
87 | return true;
88 | }
89 | };
90 |
91 | this.hasEventListener = function(type)
92 | {
93 | return (this.__events[type] !== undefined);
94 | };
95 |
96 | /**
97 | * obj.removeEventListener(type, listener, useCapture);
98 | * obj.removeEventListener(type, [scope, listener], useCapture);
99 | * obj.removeEventListener(type, new EventListener(scope, listener, useCapture));
100 | */
101 | this.removeEventListener = function(type, listener, useCapture)
102 | {
103 | //TODO useCapture
104 | var listeners = this.__events[type];
105 | if (listeners === undefined)
106 | {
107 | return;
108 | }
109 |
110 | if (listener instanceof Function)
111 | {
112 | listener = new EventListener(this, listener, useCapture);
113 | }
114 | else if (listener instanceof Array)
115 | {
116 | listener = new EventListener(listener[0], listener[1], useCapture);
117 | }
118 |
119 | for (var i = 0, l = listeners.length; i < l; ++i)
120 | {
121 | if (listener.equals(listeners[i]))
122 | {
123 | listeners.splice(i, 1);
124 | }
125 | }
126 | };
127 |
128 | this.willTrigger = function(type)
129 | {
130 | //TODO is this correct?
131 | var target = this;
132 | while (target)
133 | {
134 | if (target.hasEventListener(type))
135 | {
136 | return true;
137 | }
138 | target = target.__parent;
139 | }
140 | return false;
141 | };
142 |
143 | this.toString = function()
144 | {
145 | return '[object EventDispatcher]';
146 | };
147 | });
148 |
--------------------------------------------------------------------------------
/src/cs3/events/EventListener.js:
--------------------------------------------------------------------------------
1 | var EventListener = new Class(Object, function()
2 | {
3 | this.__init__ = function(scope, callback, useCapture, priority)
4 | {
5 | this.scope = scope;
6 | this.callback = callback;
7 | this.useCapture = useCapture ? true : false;
8 | this.priority = priority | 0;
9 | };
10 |
11 | this.call = function()
12 | {
13 | this.callback.apply(this.scope, arguments);
14 | };
15 |
16 | this.equals = function(toCompare)
17 | {
18 | if (toCompare.scope !== this.scope)
19 | {
20 | return false;
21 | }
22 | if (toCompare.callback !== this.callback)
23 | {
24 | return false;
25 | }
26 | if (toCompare.useCapture !== this.useCapture)
27 | {
28 | return false;
29 | }
30 | return true;
31 | };
32 |
33 | this.toString = function()
34 | {
35 | return '[object EventListener]';
36 | };
37 | });
38 |
--------------------------------------------------------------------------------
/src/cs3/events/HTTPStatusEvent.js:
--------------------------------------------------------------------------------
1 | var HTTPStatusEvent = new Class(Event, function()
2 | {
3 | this.__init__ = function(type, bubbles, cancelable, status)
4 | {
5 | Event.call(this, type, bubbles, cancelable);
6 | this.status = status | 0;
7 | };
8 |
9 | this.clone = function()
10 | {
11 | return new HTTPStatusEvent(this.type, this.bubbles, this.cancelable, this.status);
12 | };
13 |
14 | this.toString = function()
15 | {
16 | return '[HTTPStatusEvent type=' + this.type +
17 | ' bubbles=' + this.bubbles +
18 | ' cancelable=' + this.cancelable +
19 | ' status=' + this.status + ']';
20 | };
21 | });
22 | HTTPStatusEvent.HTTP_STATUS = 'httpStatus';
23 |
--------------------------------------------------------------------------------
/src/cs3/events/IOErrorEvent.js:
--------------------------------------------------------------------------------
1 | var IOErrorEvent = new Class(Event, function()
2 | {
3 | this.__init__ = function(type, bubbles, cancelable, text)
4 | {
5 | Event.call(this, type, bubbles, cancelable);
6 | this.text = (text !== undefined) ? text : "IOError";
7 | };
8 |
9 | this.clone = function()
10 | {
11 | return new IOErrorEvent(this.type, this.bubbles, this.cancelable, this.text);
12 | };
13 |
14 | this.toString = function()
15 | {
16 | return '[IOErrorEvent type=' + this.type +
17 | ' bubbles=' + this.bubbles +
18 | ' cancelable=' + this.cancelable +
19 | ' text=' + this.text + ']';
20 | };
21 | });
22 | IOErrorEvent.IO_ERROR = 'ioError';
23 |
--------------------------------------------------------------------------------
/src/cs3/events/KeyboardEvent.js:
--------------------------------------------------------------------------------
1 | var KeyboardEvent = new Class(Event, function()
2 | {
3 | this.__init__ = function(type, bubbles, cancelable, charCode, keyCode, keyLocation, ctrlKey, altKey, shiftKey)
4 | {
5 | Event.call(this, type, bubbles, cancelable);
6 | this.altKey = (altKey) ? true : false;
7 | this.charCode = charCode | 0;
8 | this.ctrlKey = (ctrlKey) ? true : false;
9 | this.keyCode = keyCode | 0;
10 | this.keyLocation = keyLocation || 0;
11 | this.shiftKey = (shiftKey) ? true : false;
12 | };
13 |
14 | this.clone = function()
15 | {
16 | return new KeyboardEvent(this.type, this.bubbles, this.cancelable, this.charCode, this.keyCode, this.keyLocation, this.ctrlKey, this.altKey, this.shiftKey);
17 | };
18 |
19 | this.updateAfterEvent = function()
20 | {
21 | //todo
22 | };
23 |
24 | this.toString = function()
25 | {
26 | return '[KeyboardEvent type=' + this.type +
27 | ' bubbles=' + this.bubbles +
28 | ' cancelable=' + this.cancelable +
29 | ' charCode=' + this.charCode +
30 | ' keyCode=' + this.keyCode +
31 | ' keyLocation=' + this.keyLocation +
32 | ' ctrlKey=' + this.ctrlKey +
33 | ' altKey=' + this.altKey +
34 | ' shiftKey=' + this.shiftKey + ']';
35 | };
36 | });
37 | KeyboardEvent.KEY_DOWN = 'keyDown';
38 | KeyboardEvent.KEY_UP = 'keyUp';
39 |
--------------------------------------------------------------------------------
/src/cs3/events/MouseEvent.js:
--------------------------------------------------------------------------------
1 | var MouseEvent = new Class(Event, function()
2 | {
3 | this.__init__ = function(type, bubbles, cancelable, localX, localY, relatedObject, ctrlKey, altKey, shiftKey, buttonDown, delta)
4 | {
5 | Event.call(this, type, bubbles, cancelable);
6 | this.altKey = (altKey) ? true : false;
7 | this.ctrlKey = (ctrlKey) ? true : false;
8 | this.shiftKey = (shiftKey) ? true : false;
9 | this.buttonDown = (buttonDown) ? true : false;//when does this become true?
10 | this.delta = delta | 0;
11 | this.__localX = (localX !== undefined) ? localX : null;
12 | this.__localY = (localY !== undefined) ? localY : null;
13 | this.relatedObject = relatedObject || null;
14 | };
15 |
16 | this.clone = function()
17 | {
18 | return new MouseEvent(this.type, this.bubbles, this.cancelable, this.__localX, this.__localY, this.relatedObject, this.ctrlKey, this.altKey, this.shiftKey, this.buttonDown, this.delta);
19 | };
20 |
21 | this.updateAfterEvent = function()
22 | {
23 | //todo
24 | };
25 |
26 | this.__get__localX = function()
27 | {
28 | if (this.__localX !== null)
29 | {
30 | return this.__localX;
31 | }
32 | return this.currentTarget.__get__mouseX();
33 | };
34 |
35 | this.__get__localY = function()
36 | {
37 | if (this.__localY !== null)
38 | {
39 | return this.__localY;
40 | }
41 | return this.currentTarget.__get__mouseY();
42 | };
43 |
44 | this.__get__stageX = function()
45 | {
46 | if (this.__localX !== null)
47 | {
48 | return this.currentTarget.localToGlobal(new Point(this.__localX, 0)).x;
49 | }
50 | return this.target.__stage.__mouseX;
51 | };
52 |
53 | this.__get__stageY = function()
54 | {
55 | if (this.__localY !== null)
56 | {
57 | return this.currentTarget.localToGlobal(new Point(this.__localY, 0)).y;
58 | }
59 | return this.currentTarget.__stage.__mouseY;
60 | };
61 |
62 | this.toString = function()
63 | {
64 | return '[MouseEvent type=' + this.type +
65 | ' bubbles=' + this.bubbles +
66 | ' cancelable=' + this.cancelable + ']';
67 | };
68 | });
69 | MouseEvent.CLICK = 'click';
70 | MouseEvent.DOUBLE_CLICK = 'doubleClick';
71 | MouseEvent.MOUSE_DOWN = 'mouseDown';
72 | MouseEvent.MOUSE_MOVE = 'mouseMove';
73 | MouseEvent.MOUSE_OUT = 'mouseOut';
74 | MouseEvent.MOUSE_OVER = 'mouseOver';
75 | MouseEvent.MOUSE_UP = 'mouseUp';
76 | MouseEvent.MOUSE_WHEEL = 'mouseWheel';
77 | MouseEvent.ROLL_OUT = 'rollOut';
78 | MouseEvent.ROLL_OVER = 'rollOver';
79 |
--------------------------------------------------------------------------------
/src/cs3/events/ProgressEvent.js:
--------------------------------------------------------------------------------
1 | var ProgressEvent = new Class(Event, function()
2 | {
3 | this.__init__ = function(type, bubbles, cancelable, bytesLoaded, bytesTotal)
4 | {
5 | Event.call(this, type, bubbles, cancelable);
6 | this.bytesLoaded = bytesLoaded | 0;
7 | this.bytesTotal = bytesTotal | 0;
8 | };
9 |
10 | this.clone = function()
11 | {
12 | return new ProgressEvent(this.type, this.bubbles, this.cancelable, this.bytesLoaded, this.bytesTotal);
13 | };
14 |
15 | this.toString = function()
16 | {
17 | return '[ProgressEvent type=' + this.type +
18 | ' bubbles=' + this.bubbles +
19 | ' cancelable=' + this.cancelable +
20 | ' bytesLoaded=' + this.bytesLoaded +
21 | ' bytesTotal=' + this.bytesTotal + ']';
22 | };
23 | });
24 | ProgressEvent.PROGRESS = 'progress';
25 |
--------------------------------------------------------------------------------
/src/cs3/events/TimerEvent.js:
--------------------------------------------------------------------------------
1 | var TimerEvent = new Class(Event, function()
2 | {
3 | this.__init__ = function(type, bubbles, cancelable)
4 | {
5 | Event.call(this, type, bubbles, cancelable);
6 | };
7 |
8 | this.clone = function()
9 | {
10 | return new TimerEvent(this.type, this.bubbles, this.cancelable);
11 | };
12 |
13 | this.updateAfterEvent = function()
14 | {
15 | //todo
16 | };
17 |
18 | this.toString = function()
19 | {
20 | return '[TimerEvent type=' + this.type +
21 | ' bubbles=' + this.bubbles +
22 | ' cancelable=' + this.cancelable + ']';
23 | };
24 | });
25 | TimerEvent.TIMER = 'timer';
26 | TimerEvent.TIMER_COMPLETE = 'timerComplete';
27 |
--------------------------------------------------------------------------------
/src/cs3/events/TweenEvent.js:
--------------------------------------------------------------------------------
1 | var TweenEvent = new Class(Event, function()
2 | {
3 | this.__init__ = function(type, time, position, bubbles, cancelable)
4 | {
5 | Event.call(this, type, bubbles, cancelable);
6 | this.time = time;
7 | this.position = position;
8 | };
9 |
10 | this.clone = function()
11 | {
12 | return new TweenEvent(this.type, this.time, this.position, this.bubbles, this.cancelable);
13 | };
14 |
15 | this.toString = function()
16 | {
17 | return '[TweenEvent' +
18 | ' type=' + this.type +
19 | ' time=' + this.time +
20 | ' position=' + this.position +
21 | ' bubbles=' + this.bubbles +
22 | ' cancelable=' + this.cancelable + ']';
23 | };
24 | });
25 | TweenEvent.MOTION_CHANGE = 'motionChange';
26 | TweenEvent.MOTION_FINISH = 'motionFinish';
27 | TweenEvent.MOTION_LOOP = 'motionLoop';
28 | TweenEvent.MOTION_RESUME = 'motionResume';
29 | TweenEvent.MOTION_START = 'motionStart';
30 | TweenEvent.MOTION_STOP = 'motionStop';
31 |
--------------------------------------------------------------------------------
/src/cs3/filters/BitmapFilter.js:
--------------------------------------------------------------------------------
1 | var BitmapFilter = new Class(Object, function()
2 | {
3 | this.__filter = function(displayObject)
4 | {
5 | };
6 |
7 | this.__filterBitmapData = function(sourceBitmapData, sourceRect, distBitmapData, distPoint)
8 | {
9 | };
10 |
11 | this.__generateRect = function(sourceRect)
12 | {
13 | };
14 |
15 | this.clone = function()
16 | {
17 | return new BitmapFilter();
18 | };
19 |
20 | this.toString = function()
21 | {
22 | return '[object BitmapFilter]';
23 | };
24 | });
25 |
--------------------------------------------------------------------------------
/src/cs3/filters/BlurFilter.js:
--------------------------------------------------------------------------------
1 | var BlurFilter = new Class(BitmapFilter, function()
2 | {
3 | this.__init__ = function(blurX, blurY, quality)
4 | {
5 | this.blurX = blurX || 4;
6 | this.blurY = blurY || 4;
7 | this.quality = quality || 1;
8 | };
9 |
10 | //override
11 | this.__filter = function(displayObject)
12 | {
13 | /*
14 | var target = (displayObject.__cache) ? displayObject.__cache : displayObject;
15 | var exWidth = this.blurX * this.quality;
16 | var exHeight = this.blurY * this.quality;
17 | var newWidth = target.width + exWidth;
18 | var newHeight = target.height + exHeight;
19 | var bitmapData = new BitmapData(newWidth, newHeight, true, 0);
20 |
21 | var matrix = new Matrix(1, 0, 0, 1, exWidth/2, exHeight/2);
22 | bitmapData.draw(target, matrix);
23 | //this.__applyBitmap(bitmapData);
24 |
25 | bitmapData.__rect.offset(-exWidth/2, -exHeight/2);
26 | displayObject.__cache = bitmapData;
27 | */
28 | };
29 |
30 | //override
31 | this.__filterBitmapData = function(sourceBitmapData, sourceRect, distBitmapData, distPoint)
32 | {
33 | var width = sourceRect.width;
34 | var height = sourceRect.height;
35 | var srcImageData = sourceBitmapData.__context.getImageData(sourceRect.x, sourceRect.y, width, height);
36 | var dstImageData = sourceBitmapData.__context.createImageData(width, height);
37 |
38 | for (var i = 0; i < this.quality; ++i)
39 | {
40 | this.__blur( srcImageData.data, dstImageData.data, width, height, this.blurX / 2 );
41 | this.__blur( dstImageData.data, srcImageData.data, height, width, this.blurY / 2 );
42 | }
43 |
44 | distBitmapData.__context.putImageData(srcImageData, distPoint.x, distPoint.y);
45 | };
46 |
47 | //override
48 | this.__generateRect = function(sourceRect)
49 | {
50 | var inflateX = this.blurX * this.quality / 2;
51 | var inflateY = this.blurY * this.quality / 2;
52 | var newRect = sourceRect.clone();
53 | newRect.inflate(inflateX, inflateY);
54 | return newRect;
55 | };
56 |
57 | /*
58 | * http://www.jhlabs.com/ip/BoxBlurFilter.java
59 | * Copyright 2005 Huxtable.com. All rights reserved.
60 | */
61 | this.__blur = function(src, dst, width, height, radius)
62 | {
63 | var length = src.length;
64 | var widthMinus1 = width - 1;
65 | var tableSize = 2 * radius + 1;
66 | var srcIndex = 0;
67 | var dstIndex;
68 | var divide = [];
69 | //var clamp = this.__clamp;
70 | var i, l, p, p2;
71 |
72 | for (i = 0, l = 256 * tableSize; i < l; ++i)
73 | {
74 | divide[i] = (i / tableSize) | 0;
75 | }
76 |
77 | for (var y = 0; y < height; ++y)
78 | {
79 | dstIndex = y;
80 | var ta = 0, tr = 0, tg = 0, tb = 0;
81 |
82 | for (i = -radius; i <= radius; ++i)
83 | {
84 | //p = (srcIndex + clamp(i, 0, widthMinus1)) * 4;
85 | p = (srcIndex + ((i < 0) ? 0 : (i > widthMinus1) ? widthMinus1 : i)) * 4;
86 | tr += src[p];
87 | tg += src[++p];
88 | tb += src[++p];
89 | ta += src[++p];
90 | }
91 |
92 | for (var x = 0; x < width; ++x)
93 | {
94 | p = dstIndex * 4;
95 | dst[p] = divide[tr];
96 | dst[++p] = divide[tg];
97 | dst[++p] = divide[tb];
98 | dst[++p] = divide[ta];
99 |
100 | var i1 = x + radius + 1;
101 | if (i1 > widthMinus1)
102 | {
103 | i1 = widthMinus1;
104 | }
105 | var i2 = x - radius;
106 | if (i2 < 0)
107 | {
108 | i2 = 0;
109 | }
110 |
111 | p = (srcIndex + i1) * 4;
112 | p2 = (srcIndex + i2) * 4;
113 |
114 | tr += src[p] - src[p2];
115 | tg += src[++p] - src[++p2];
116 | tb += src[++p] - src[++p2];
117 | ta += src[++p] - src[++p2];
118 |
119 | dstIndex += height;
120 | }
121 | srcIndex += width;
122 | }
123 | };
124 |
125 | //override
126 | this.clone = function()
127 | {
128 | return new BlurFilter(this.blurX, this.blurY, this.quality);
129 | };
130 |
131 | this.toString = function()
132 | {
133 | return '[object BlurFilter]';
134 | };
135 | });
136 |
--------------------------------------------------------------------------------
/src/cs3/filters/ColorMatrixFilter.js:
--------------------------------------------------------------------------------
1 | var ColorMatrixFilter = new Class(BitmapFilter, function()
2 | {
3 | this.__init__ = function(matrix)
4 | {
5 | this.matrix = matrix;
6 | };
7 | //override
8 | this.__filter = function(displayObject)
9 | {
10 | };
11 | //override
12 | this.__filterBitmapData = function(sourceBitmapData, sourceRect, distBitmapData, distPoint)
13 | {
14 | var width = sourceRect.width;
15 | var height = sourceRect.height;
16 | var srcImageData = sourceBitmapData.__context.getImageData(sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height);
17 | var dstImageData = sourceBitmapData.__context.createImageData(sourceRect.width, sourceRect.height);
18 | var sourcePixels = sourceImageData.data;
19 | var destPixels = destImageData.data;
20 | var length = sourcePixels.length;
21 |
22 | var m = this.matrix;
23 |
24 | for (var i = 0; i < length; i += 4)
25 | {
26 | var srcR = sourcePixels[i];
27 | var srcG = sourcePixels[i+1];
28 | var srcB = sourcePixels[i+2];
29 | var srcA = sourcePixels[i+3];
30 | destPixels[i++] = (m[0] * srcR) + (m[1] * srcG) + (m[2] * srcB) + (m[3] * srcA) + m[4];
31 | destPixels[i++] = (m[5] * srcR) + (m[6] * srcG) + (m[7] * srcB) + (m[8] * srcA) + m[9];
32 | destPixels[i++] = (m[10] * srcR) + (m[11] * srcG) + (m[12] * srcB) + (m[13] * srcA) + m[14];
33 | destPixels[i++] = (m[15] * srcR) + (m[16] * srcG) + (m[17] * srcB) + (m[18] * srcA) + m[19];
34 | }
35 |
36 | distBitmapData.__context.putImageData(dstImageData, distPoint.x, distPoint.y);
37 | };
38 | //override
39 | this.__generateRect = function(sourceRect)
40 | {
41 | return sourceRect.clone();
42 | };
43 | //override
44 | this.clone = function()
45 | {
46 | return new ColorMatrixFilter(this.matrix);
47 | };
48 | });
49 | ColorMatrixFilter.prototype.toString = function()
50 | {
51 | return '[object ColorMatrixFilter]';
52 | };
53 |
--------------------------------------------------------------------------------
/src/cs3/filters/ContextFilter.js:
--------------------------------------------------------------------------------
1 | var ContextFilter = new Class(Object, function()
2 | {
3 | this.__filter = function(context, target)
4 | {
5 | };
6 |
7 | this.__generateRect = function(sourceRect)
8 | {
9 | };
10 |
11 | this.clone = function()
12 | {
13 | return new ContextFilter();
14 | };
15 |
16 | this.toString = function()
17 | {
18 | return '[object ContextFilter]';
19 | };
20 | });
21 |
--------------------------------------------------------------------------------
/src/cs3/filters/DropShadowFilter.js:
--------------------------------------------------------------------------------
1 | var DropShadowFilter = new Class(ContextFilter, function()
2 | {
3 | this.__init__ = function(distance, angle, color, alpha, blur)
4 | {
5 | this.alpha = alpha || 1;
6 | this.blur = blur || 4;
7 | this.color = color | 0;
8 | this.distance = distance || 4;
9 | this.angle = angle || 45;
10 | };
11 |
12 | //override
13 | this.__filter = function(context, target)
14 | {
15 | var radian = this.angle * 0.017453292519943295;
16 | context.shadowBlur = this.blur;
17 | context.shadowColor = __toRGBA(((this.alpha * 255) << 24) + this.color);
18 | context.shadowOffsetX = this.distance * Math.cos(radian);
19 | context.shadowOffsetY = this.distance * Math.sin(radian);
20 | };
21 |
22 | //override
23 | this.__generateRect = function(sourceRect)
24 | {
25 | //TODO figure out how blur effects the size
26 | var newRect = sourceRect.clone();
27 | var point = Point.polar(this.distance, this.angle * 0.017453292519943295);
28 | if (point.x > 0)
29 | {
30 | newRect.width += point.x;
31 | }
32 | else if (point.x < 0)
33 | {
34 | newRect.x += point.x;
35 | newRect.width -= point.x;
36 | }
37 |
38 | if (point.y > 0)
39 | {
40 | newRect.height += point.y;
41 | }
42 | else if (point.y < 0)
43 | {
44 | newRect.y += point.y;
45 | newRect.height -= point.y;
46 | }
47 |
48 | return newRect;
49 | };
50 |
51 | //override
52 | this.clone = function()
53 | {
54 | return new DropShadowFilter(this.distance, this.angle, this.color, this.alpha, this.blur);
55 | };
56 |
57 | this.toString = function()
58 | {
59 | return '[object DropShadowFilter]';
60 | };
61 | });
62 |
--------------------------------------------------------------------------------
/src/cs3/geom/ColorTransform.js:
--------------------------------------------------------------------------------
1 | var ColorTransform = new Class(Object, function()
2 | {
3 | this.__init__ = function(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset)
4 | {
5 | this.redMultiplier = (redMultiplier !== undefined) ? redMultiplier : 1;
6 | this.greenMultiplier = (greenMultiplier !== undefined) ? greenMultiplier : 1;
7 | this.blueMultiplier = (blueMultiplier !== undefined) ? blueMultiplier : 1;
8 | this.alphaMultiplier = (alphaMultiplier !== undefined) ? alphaMultiplier : 1;
9 | this.redOffset = (redOffset) ? redOffset : 0;
10 | this.greenOffset = (greenOffset) ? greenOffset : 0;
11 | this.blueOffset = (blueOffset) ? blueOffset : 0;
12 | this.alphaOffset = (alphaOffset) ? alphaOffset : 0;
13 | };
14 |
15 | this.clone = function()
16 | {
17 | return new ColorTransform(this.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier, this.redOffset, this.greenOffset, this.blueOffset, this.alphaOffset);
18 | };
19 |
20 | this.concat = function(second)
21 | {
22 | this.redOffset += second.redOffset * this.redMultiplier;
23 | this.greenOffset += second.greenOffset * this.greenMultiplier;
24 | this.blueOffset += second.blueOffset * this.blueMultiplier;
25 | this.alphaOffset += second.alphaOffset * this.alphaMultiplier;
26 | this.redMultiplier *= second.redMultiplier;
27 | this.greenMultiplier *= second.greenMultiplier;
28 | this.blueMultiplier *= second.blueMultiplier;
29 | this.alphaMultiplier *= second.alphaMultiplier;
30 | };
31 |
32 | this.transformColor = function(color)
33 | {
34 | var a = (color >> 24 & 0xFF) * this.alphaMultiplier + this.alphaOffset;
35 | var r = (color >> 16 & 0xFF) * this.redMultiplier + this.redOffset;
36 | var g = (color >> 8 & 0xFF) * this.greenMultiplier + this.greenOffset;
37 | var b = (color & 0xFF) * this.blueMultiplier + this.blueOffset;
38 | if (a > 255)
39 | {
40 | a = 255;
41 | }
42 | if (r > 255)
43 | {
44 | r = 255;
45 | }
46 | if (g > 255)
47 | {
48 | g = 255;
49 | }
50 | if (b > 255)
51 | {
52 | b = 255;
53 | }
54 | return ((a << 24) | (r << 16) | (g << 8) | b) >>> 0;
55 | };
56 |
57 | this.__get__color = function()
58 | {
59 | return ((this.alphaOffset << 24) | (this.redOffset << 16) | (this.greenOffset << 8) | this.blueOffset) >>> 0;
60 | };
61 |
62 | this.__set__color = function(v)
63 | {
64 | this.alphaMultiplier = 0;
65 | this.redMultiplier = 0;
66 | this.greenMultiplier = 0;
67 | this.blueMultiplier = 0;
68 | this.alphaOffset = v >> 24 & 0xFF;
69 | this.redOffset = v >> 16 & 0xFF;
70 | this.greenOffset = v >> 8 & 0xFF;
71 | this.blueOffset = v & 0xFF;
72 | };
73 |
74 | this.toString = function()
75 | {
76 | return '(redMultiplier=' + this.redMultiplier +
77 | ', greenMultiplier=' + this.greenMultiplier +
78 | ', blueMultiplier=' + this.blueMultiplier +
79 | ', alphaMultiplier=' + this.alphaMultiplier +
80 | ', redOffset=' + this.redOffset +
81 | ', greenOffset=' + this.greenOffset +
82 | ', blueOffset=' + this.blueOffset +
83 | ', alphaOffset=' + this.alphaOffset + ')';
84 | };
85 | });
86 |
--------------------------------------------------------------------------------
/src/cs3/geom/MatrixTransformer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * http://www.canadahealthinfoway.com/flash/infoway/AllProjects/lib/fl/motion/MatrixTransformer.as
3 | * Copyright c 2007. Adobe Systems Incorporated. All Rights Reserved.
4 | */
5 | var MatrixTransformer = new Class(Object, function()
6 | {
7 | this.toString = function()
8 | {
9 | return '[object MatrixTransformer]';
10 | };
11 | });
12 | MatrixTransformer.getScaleX = function(m)
13 | {
14 | return Math.sqrt(m.a * m.a + m.b * m.b);
15 | };
16 | MatrixTransformer.setScaleX = function(m, scaleX)
17 | {
18 | var a = m.a;
19 | var b = m.b;
20 | var old = Math.sqrt(a * a + b * b);
21 | if (old) {
22 | var ratio = scaleX / old;
23 | m.a *= ratio;
24 | m.b *= ratio;
25 | }
26 | else {
27 | var skewY = Math.atan2(b, a);
28 | m.a = Math.cos(skewY) * scaleX;
29 | m.b = Math.sin(skewY) * scaleX;
30 | }
31 | };
32 | MatrixTransformer.getScaleY = function(m)
33 | {
34 | return Math.sqrt(m.c * m.c + m.d * m.d);
35 | };
36 | MatrixTransformer.setScaleY = function(m, scaleY)
37 | {
38 | var c = m.c;
39 | var d = m.d;
40 | var old = Math.sqrt(c * c + d * d);
41 | if (old) {
42 | var ratio = scaleY / old;
43 | m.c *= ratio;
44 | m.d *= ratio;
45 | }
46 | else {
47 | var skewX = Math.atan2(-c, d);
48 | m.c = -Math.sin(skewX) * scaleY;
49 | m.d = Math.cos(skewX) * scaleY;
50 | }
51 | };
52 | MatrixTransformer.getSkewXRadians = function(m)
53 | {
54 | return Math.atan2(-m.c, m.d);
55 | };
56 | MatrixTransformer.setSkewXRadians = function(m, skewX)
57 | {
58 | var scaleY = Math.sqrt(m.c * m.c + m.d * m.d);
59 | m.c = -scaleY * Math.sin(skewX);
60 | m.d = scaleY * Math.cos(skewX);
61 | };
62 | MatrixTransformer.getSkewYRadians = function(m)
63 | {
64 | return Math.atan2(m.b, m.a);
65 | };
66 | MatrixTransformer.setSkewYRadians = function(m, skewY)
67 | {
68 | var scaleX = Math.sqrt(m.a * m.a + m.b * m.b);
69 | m.a = scaleX * Math.cos(skewY);
70 | m.b = scaleX * Math.sin(skewY);
71 | };
72 | MatrixTransformer.getSkewX = function(m)
73 | {
74 | return Math.atan2(-m.c, m.d) * 57.29577951308232;
75 | };
76 | MatrixTransformer.setSkewX = function(m, skewX)
77 | {
78 | MatrixTransformer.setSkewXRadians(m, skewX * 0.017453292519943295);
79 | };
80 | MatrixTransformer.getSkewY = function(m)
81 | {
82 | return Math.atan2(m.b, m.a) * 57.29577951308232;
83 | };
84 | MatrixTransformer.setSkewY = function(m, skewY)
85 | {
86 | MatrixTransformer.setSkewYRadians(m, skewY * 0.017453292519943295);
87 | };
88 | MatrixTransformer.getRotationRadians = function(m)
89 | {
90 | return Math.atan2(m.b, m.a);
91 | };
92 | MatrixTransformer.setRotationRadians = function(m, rotation)
93 | {
94 | var a = m.a;
95 | var b = m.b;
96 | var c = m.c;
97 | var d = m.d;
98 | var oldRotation = Math.atan2(b, a);
99 | var oldSkewX = Math.atan2(-c, d);
100 | var skewX = oldSkewX + rotation - oldRotation;
101 | var skewY = rotation;
102 | var scaleY = Math.sqrt(c * c + d * d);
103 | var scaleX = Math.sqrt(a * a + b * b);
104 | m.c = -scaleY * Math.sin(skewX);
105 | m.d = scaleY * Math.cos(skewX);
106 | m.a = scaleX * Math.cos(skewY);
107 | m.b = scaleX * Math.sin(skewY);
108 | };
109 | MatrixTransformer.getRotation = function(m)
110 | {
111 | return Math.atan2(m.b, m.a) * 57.29577951308232;
112 | };
113 | MatrixTransformer.setRotation = function(m, rotation)
114 | {
115 | MatrixTransformer.setRotationRadians(m, rotation * 0.017453292519943295);
116 | };
117 | MatrixTransformer.rotateAroundInternalPoint = function(m, x, y, angleDegrees)
118 | {
119 | var point = new Point(x, y);
120 | point = m.transformPoint(point);
121 | m.tx -= point.x;
122 | m.ty -= point.y;
123 | m.rotate(angleDegrees * 0.017453292519943295);
124 | m.tx += point.x;
125 | m.ty += point.y;
126 | };
127 | MatrixTransformer.rotateAroundExternalPoint = function(m, x, y, angleDegrees)
128 | {
129 | m.tx -= x;
130 | m.ty -= y;
131 | m.rotate(angleDegrees * 0.017453292519943295);
132 | m.tx += x;
133 | m.ty += y;
134 | };
135 | MatrixTransformer.matchInternalPointWithExternal = function(m, internalPoint, externalPoint)
136 | {
137 | var point = m.transformPoint(internalPoint);
138 | m.tx += externalPoint.x - point.x;
139 | m.ty += externalPoint.y - point.y;
140 | };
141 |
--------------------------------------------------------------------------------
/src/cs3/geom/Point.js:
--------------------------------------------------------------------------------
1 | var Point = new Class(Object, function()
2 | {
3 | this.__init__ = function(x, y)
4 | {
5 | this.x = (x) ? x : 0;
6 | this.y = (y) ? y : 0;
7 | };
8 | this.add = function(v)
9 | {
10 | return new Point(this.x + v.x, this.y + v.y);
11 | };
12 | this.clone = function()
13 | {
14 | return new Point(this.x, this.y);
15 | };
16 | this.equals = function(toCompare)
17 | {
18 | return (toCompare.x === this.x && toCompare.y === this.y) ? true : false;
19 | };
20 | this.normalize = function(thickness)
21 | {
22 | var x = this.x;
23 | var y = this.y;
24 | var l = this.length;
25 | if (l > 0) {
26 | var f = length / l;
27 | x *= f;
28 | y *= f;
29 | }
30 | return new Point(x, y);
31 | };
32 | this.offset = function(dx, dy)
33 | {
34 | return new Point(this.x + dx, this.y + dy);
35 | };
36 | this.subtract = function(v)
37 | {
38 | return new Point(this.x - v.x, this.y - v.y);
39 | };
40 |
41 | /* getters and setters */
42 | this.__get__length = function()
43 | {
44 | return Math.sqrt(this._x * this._x + this._y * this._y);
45 | };
46 |
47 | this.toString = function()
48 | {
49 | return '(x=' + this.x + ', y=' + this.y + ')';
50 | };
51 | });
52 | Point.distance = function(pt1, pt2)
53 | {
54 | var dx = pt2.x - pt1.x;
55 | var dy = pt2.y - pt1.y;
56 | return Math.sqrt(dx * dx + dy * dy);
57 | };
58 | Point.interpolate = function(pt1, pt2, f)
59 | {
60 | return new Point(f * pt1.x + (1 - f) * pt2.x, f * pt1.y + (1 - f) * pt2.y);
61 | };
62 | Point.polar = function(len, angle)
63 | {
64 | return new Point(len * Math.cos(angle), len * Math.sin(angle));
65 | };
66 |
--------------------------------------------------------------------------------
/src/cs3/geom/Rectangle.js:
--------------------------------------------------------------------------------
1 | var Rectangle = new Class(Object, function()
2 | {
3 | this.__init__ = function(x, y, width, height)
4 | {
5 | this.x = (x) ? x : 0;
6 | this.y = (y) ? y : 0;
7 | this.width = (width) ? width : 0;
8 | this.height = (height) ? height : 0;
9 | };
10 | this.clone = function()
11 | {
12 | return new Rectangle(this.x, this.y, this.width, this.height);
13 | };
14 | this.contains = function(x, y)
15 | {
16 | return (
17 | this.x <= x &&
18 | this.y <= y &&
19 | this.x + this.width > x &&
20 | this.y + this.height > y) ? true : false;
21 | };
22 | this.containsPoint = function(point)
23 | {
24 | return this.contains(point.x, point.y);
25 | };
26 | this.containsRect = function(rect)
27 | {
28 | return (
29 | this.x <= rect.x &&
30 | this.y <= rect.y &&
31 | this.x + this.width >= rect.x + rect.width &&
32 | this.y + this.height >= rect.y + rect.height) ? true : false;
33 | };
34 | this.equals = function(toCompare)
35 | {
36 | return (
37 | toCompare.x === this.x &&
38 | toCompare.y === this.y &&
39 | toCompare.width === this.width &&
40 | toCompare.height === this.height) ? true : false;
41 | };
42 | this.inflate = function(dx, dy)
43 | {
44 | this.x -= dx;
45 | this.width += 2 * dx;
46 | this.y -= dy;
47 | this.height += 2 * dy;
48 | };
49 | this.inflatePoint = function(point)
50 | {
51 | return this.inflate(point.x, point.y);
52 | };
53 | this.intersection = function(toIntersect)
54 | {
55 | var x1 = this.x;
56 | var y1 = this.y;
57 | var w1 = this.width;
58 | var h1 = this.height;
59 | var x2 = toIntersect.x;
60 | var y2 = toIntersect.y;
61 | var w2 = toIntersect.width;
62 | var h2 = toIntersect.height;
63 |
64 | if (w1 <= 0 || h1 <= 0 || w2 <= 0 || h2 <= 0) {
65 | return new Rectangle(0, 0, 0, 0);
66 | }
67 |
68 | var l = (x1 > x2) ? x1 : x2;
69 | var r = (x1 + w1 < x2 + w2) ? x1 + w1 : x2 + w2;
70 |
71 | if (l >= r) {
72 | return new Rectangle(0, 0, 0, 0);
73 | }
74 |
75 | var t = (y1 > y2) ? y1 : y2;
76 | var b = (y1 + h1 < y2 + h2) ? y1 + h1 : y2 + h2;
77 |
78 | if (t >= b) {
79 | return new Rectangle(0, 0, 0, 0);
80 | }
81 |
82 | return new Rectangle(l, t, r - l, b - t);
83 | };
84 | this.intersects = function(toIntersect)
85 | {
86 | var x1 = this.x;
87 | var y1 = this.y;
88 | var w1 = this.width;
89 | var h1 = this.height;
90 | var x2 = toIntersect.x;
91 | var y2 = toIntersect.y;
92 | var w2 = toIntersect.width;
93 | var h2 = toIntersect.height;
94 |
95 | if (w1 <= 0 || h1 <= 0 || w2 <= 0 || h2 <= 0) {
96 | return false;
97 | }
98 |
99 | return (x1 <= x2 + w2 &&
100 | x2 <= x1 + w1 &&
101 | y1 <= y2 + h2 &&
102 | y2 <= y1 + h1) ? true : false;
103 | };
104 | this.isEmpty = function()
105 | {
106 | return (this.width <= 0 || this.height <= 0) ? true : false;
107 | };
108 | this.offset = function(dx, dy)
109 | {
110 | this.x += dx;
111 | this.y += dy;
112 | };
113 | this.offsetPoint = function(point)
114 | {
115 | this.x += point.x;
116 | this.y += point.y;
117 | };
118 | this.repair = function()
119 | {
120 | if (this.width < 0) {
121 | this.width = -this.width;
122 | this.x -= this.width;
123 | }
124 | if (this.height < 0) {
125 | this.height = -this.height;
126 | this.y -= this.height;
127 | }
128 | };
129 | this.setEmpty = function()
130 | {
131 | this.x = this.y = this.width = this.height = 0;
132 | };
133 | this.union = function(toUnion)
134 | {
135 | var x1 = this.x;
136 | var y1 = this.y;
137 | var w1 = this.width;
138 | var h1 = this.height;
139 | var x2 = toUnion.x;
140 | var y2 = toUnion.y;
141 | var w2 = toUnion.width;
142 | var h2 = toUnion.height;
143 |
144 | if (w1 <= 0 || h1 <= 0) {
145 | return toUnion.clone();
146 | }
147 |
148 | if (w2 <= 0 || h2 <= 0) {
149 | return this.clone();
150 | }
151 |
152 | var l = (x1 < x2) ? x1 : x2;
153 | var r = (x1 + w1 > x2 + w2) ? x1 + w1 : x2 + w2;
154 | var t = (y1 < y2) ? y1 : y2;
155 | var b = (y1 + h1 > y2 + h2) ? y1 + h1 : y2 + h2;
156 |
157 | return new Rectangle(l, t, r - l, b - t);
158 | };
159 |
160 | /* getters and setters */
161 | this.__get__top = function()
162 | {
163 | return this.y;
164 | };
165 | this.__get__right = function()
166 | {
167 | return this.x + this.width;
168 | };
169 | this.__get__bottom = function()
170 | {
171 | return this.y + this.height;
172 | };
173 | this.__get__left = function()
174 | {
175 | return this.x;
176 | };
177 | this.__get__topLeft = function()
178 | {
179 | return new Point(this.x, this.y);
180 | };
181 | this.__set__topLeft = function(v)
182 | {
183 | this.x = v.x;
184 | this.y = v.y;
185 | };
186 | this.__get__bottomRight = function()
187 | {
188 | return new Point(this.x + this.width, this.y + this.height);
189 | };
190 | this.__set__bottomRight = function(v)
191 | {
192 | this.width = v.x - this.x;
193 | this.height = v.y - this.y;
194 | };
195 | this.__get__size = function()
196 | {
197 | return new Point(this.width, this.height);
198 | };
199 | this.__set__size = function(v)
200 | {
201 | this.width = v.x;
202 | this.height = v.y;
203 | };
204 |
205 | this.toString = function()
206 | {
207 | return '(x=' + this.x + ', y=' + this.y + ', w=' + this.width + ', h=' + this.height + ')';
208 | };
209 | });
210 |
--------------------------------------------------------------------------------
/src/cs3/geom/Transform.js:
--------------------------------------------------------------------------------
1 | var Transform = new Class(Object, function()
2 | {
3 | var getRotation = MatrixTransformer.getRotation;
4 | var setRotation = MatrixTransformer.setRotation;
5 | var getScaleX = MatrixTransformer.getScaleX;
6 | var setScaleX = MatrixTransformer.setScaleX;
7 | var getScaleY = MatrixTransformer.getScaleY;
8 | var setScaleY = MatrixTransformer.setScaleY;
9 |
10 | this.__init__ = function()
11 | {
12 | this.__target = null;
13 | this.__colorTransform = new ColorTransform();
14 | this.__matrix = new Matrix();
15 | this.__modified = false;
16 | };
17 | this.__getX = function()
18 | {
19 | return this.__matrix.tx;
20 | };
21 | this.__setX = function(v)
22 | {
23 | this.__matrix.tx = v;
24 | this.__modified = true;
25 | };
26 | this.__getY = function()
27 | {
28 | return this.__matrix.ty;
29 | };
30 | this.__setY = function(v)
31 | {
32 | this.__matrix.ty = v;
33 | this.__modified = true;
34 | };
35 | this.__getRotation = function(v)
36 | {
37 | return getRotation(this.__matrix);
38 | };
39 | this.__setRotation = function(v)
40 | {
41 | setRotation(this.__matrix, v);
42 | this.__modified = true;
43 | };
44 | this.__getScaleX = function()
45 | {
46 | return getScaleX(this.__matrix);
47 | };
48 | this.__setScaleX = function(v)
49 | {
50 | setScaleX(this.__matrix, v);
51 | this.__modified = true;
52 | };
53 | this.__getScaleY = function()
54 | {
55 | return getScaleY(this.__matrix);
56 | };
57 | this.__setScaleY = function(v)
58 | {
59 | setScaleY(this.__matrix, v);
60 | this.__modified = true;
61 | };
62 |
63 | /* getters and setters */
64 | this.__get__concatenatedColorTransform = function()
65 | {
66 | var target = this.__target;
67 | if (target && target.__parent) {
68 | var concatenated = this.__colorTransform.clone();
69 | concatenated.concat(target.__parent.__transform.__get__concatenatedColorTransform());
70 | return concatenated;
71 | }
72 | else {
73 | return this.__colorTransform.clone();
74 | }
75 | };
76 | this.__get__colorTransform = function()
77 | {
78 | return this.__colorTransform.clone();
79 | };
80 | this.__set__colorTransform = function(v)
81 | {
82 | this.__colorTransform = v.clone();
83 | this.__modified = true;
84 | };
85 | this.__get__concatenatedMatrix = function()
86 | {
87 | var target = this.__target;
88 | if (target && target.__parent) {
89 | var concatenated = this.__matrix.clone();
90 | concatenated.concat(target.__parent.__transform.__get__concatenatedMatrix());
91 | return concatenated;
92 | }
93 | else {
94 | return this.__matrix.clone();
95 | }
96 | };
97 | this.__get__matrix = function()
98 | {
99 | return this.__matrix.clone();
100 | };
101 | this.__set__matrix = function(v)
102 | {
103 | this.__matrix = v.clone();
104 | this.__modified = true;
105 | };
106 | this.__get__pixelBounds = function()
107 | {
108 | var target = this.__target;
109 | if (target) {
110 | return target.__getBounds();
111 | }
112 | return new Rectangle();
113 | };
114 |
115 | this.toString = function()
116 | {
117 | return '[object Transform]';
118 | };
119 | });
120 |
--------------------------------------------------------------------------------
/src/cs3/media/Sound.js:
--------------------------------------------------------------------------------
1 | var Sound = new Class(EventDispatcher, function()
2 | {
3 | this.__init__ = function(/* source1, source2.. */)
4 | {
5 | EventDispatcher.call(this);
6 | this.__media = null;
7 | this.__url = null;
8 | this.__canPlay = false;
9 | this.__isPlaying = false;
10 | this.__startTime = 0;
11 | this.__loops = 0;
12 | this.__loopCount = 0;
13 | this.__volume = 1;
14 | if (arguments.length !== 0) {
15 | this.load.apply(this, arguments);
16 | }
17 | };
18 |
19 | this.__onCanPlay = function()
20 | {
21 | trace("onCanPlay");
22 | this.__canPlay = true;
23 | if (this.__isPlaying) {
24 | this.__media.currentTime = this.__startTime;
25 |
26 | this.__media.play();
27 | this.__media.volume = this.__volume;
28 | }
29 | };
30 |
31 | this.__onEnded = function()
32 | {
33 | if (this.__loops > this.__loopCount++) {
34 | this.__media.currentTime = this.__startTime;
35 | this.__media.play();
36 | }
37 | };
38 |
39 | this.close = function()
40 | {
41 | this.__url = null;
42 | this.__canPlay = false;
43 | this.__isPlaying = false;
44 | this.__startTime = 0;
45 | this.__loops = 0;
46 | this.__loopCount = 0;
47 | document.body.removeChild(this.__media);
48 | cs3.utils.removeAllEventListeners(this.__media);
49 | this.__media = null;
50 | };
51 |
52 | this.load = function(/* source1, source2.. */)
53 | {
54 | if (arguments.length === 0) {
55 | throw new ArgumentError("load requires at least one url");
56 | }
57 |
58 | var self = this;
59 | var media = document.createElement('AUDIO');
60 | media.autoplay = false;
61 | media.loop = false;
62 | media.volume = this.__volume;
63 |
64 | for (var i = 0, l = arguments.length; i < l; ++i)
65 | {
66 | var request = arguments[i];
67 | if (typeof request == 'string') {
68 | request = new URLRequest(request);
69 | }
70 | var source = document.createElement('SOURCE');
71 | source.src = request.__url;
72 | media.appendChild(source);
73 | }
74 |
75 | cs3.utils.addEventListener(media, 'canplay', function(e)
76 | {
77 | self.__onCanPlay();
78 | cs3.utils.removeEventListener(media, 'canplay', arguments.callee);
79 | });
80 | cs3.utils.addEventListener(media, 'load', function(e)
81 | {
82 | trace("onLoad");
83 | });
84 | cs3.utils.addEventListener(media, 'ended', function(e)
85 | {
86 | self.__onEnded();
87 | });
88 |
89 | media.style.display = "none";
90 | document.body.appendChild(media);
91 |
92 | this.__media = media;
93 | this.__url = media.currentSrc;
94 | };
95 |
96 | this.play = function(startTime, loops)
97 | {
98 | if (this.__media === null) {
99 | throw new ArgumentError("Invalid Sound.");
100 | }
101 |
102 | var self = this;
103 | var media = this.__media;
104 | this.__isPlaying = true;
105 | this.__startTime = Number(startTime) || 0;
106 | this.__loops = loops | 0;
107 | this.__loopCount = 0;
108 |
109 | if (this.__canPlay) {
110 | media.currentTime = this.__startTime;
111 | media.volume = this.__volume;
112 | media.play();
113 | }
114 | };
115 |
116 | this.pause = function()
117 | {
118 | if (this.__media === null) {
119 | throw new ArgumentError("Invalid Sound.");
120 | }
121 | this.__media.pause();
122 | this.__isPlaying = false;
123 | };
124 |
125 | /* getters and setters */
126 | this.__get__length = function()
127 | {
128 | if (this.__media) {
129 | return this.__media.duration;
130 | }
131 | return 0;
132 | };
133 |
134 | this.__get__position = function()
135 | {
136 | if (this.__media) {
137 | return this.__media.currentTime;
138 | }
139 | return 0;
140 | };
141 |
142 | this.__get__url = function()
143 | {
144 | return this.__url;
145 | };
146 |
147 | this.__get__volume = function()
148 | {
149 | return this.__volume;
150 | };
151 |
152 | this.__set__volume = function(v)
153 | {
154 | this.__volume = v;
155 | if (this.__media) {
156 | this.__media.volume = v;
157 | }
158 | };
159 |
160 | this.toString = function()
161 | {
162 | return '[object Sound]';
163 | };
164 | });
165 |
--------------------------------------------------------------------------------
/src/cs3/media/Video.js:
--------------------------------------------------------------------------------
1 | var Video = new Class(DisplayObject, function()
2 | {
3 | this.__init__ = function()
4 | {
5 | DisplayObject.call(this);
6 | this.__media = null;
7 | this.__url = null;
8 | this.__canPlay = false;
9 | this.__isPlaying = false;
10 | this.__startTime = 0;
11 | this.__loops = 0;
12 | this.__loopCount = 0;
13 | this.__volume = 1;
14 | if (arguments.length !== 0) {
15 | this.load.apply(this, arguments);
16 | }
17 | };
18 |
19 | //override
20 | this.__getContentBounds = function()
21 | {
22 | //TODO
23 | if (this.__media) {
24 | return new Rectangle(0, 0, this.__media.videoWidth, this.__media.videoHeight);
25 | }
26 | return new Rectangle();
27 | };
28 |
29 | //override
30 | this.__getModified = function()
31 | {
32 | //return this.__modified;
33 | if (this.__media && this.__media.paused === false) {
34 | return true;
35 | }
36 | return this.__transform.__modified || this.__modified;
37 | };
38 |
39 | //override
40 | this.__setModified = function(v)
41 | {
42 | this.__transform.__modified = this.__modified = v;
43 | };
44 |
45 | //override
46 | this.__render = function(context, colorTransform)
47 | {
48 | if (this.__media) {
49 | context.drawImage(this.__media, 0, 0);
50 | }
51 | };
52 |
53 | //override
54 | this.__hitTestPoint = function(context, matrix, point)
55 | {
56 | if (this.__media) {
57 | var bounds = this.__getContentBounds();
58 |
59 | //convert point to local coords
60 | var invertedMatrix = matrix.clone();
61 | invertedMatrix.invert();
62 | var localPoint = invertedMatrix.transformPoint(point);
63 |
64 | if (bounds.containsPoint(localPoint)) {
65 | return true;
66 | }
67 | }
68 | return false;
69 | };
70 |
71 | this.__onCanPlay = function()
72 | {
73 | this.__canPlay = true;
74 | if (this.__isPlaying) {
75 | this.__media.currentTime = this.__startTime;
76 | this.__media.play();
77 | }
78 | };
79 |
80 | this.__onEnded = function()
81 | {
82 | if (this.__loops === -1 || this.__loops > this.__loopCount) {
83 | this.__loopCount++;
84 | this.__media.currentTime = this.__startTime;
85 | this.__media.play();
86 | }
87 | };
88 |
89 | this.close = function()
90 | {
91 | this.__url = null;
92 | this.__canPlay = false;
93 | this.__isPlaying = false;
94 | this.__startTime = 0;
95 | this.__loops = 0;
96 | this.__loopCount = 0;
97 | document.body.removeChild(this.__media);
98 | cs3.utils.removeAllEventListeners(this.__media);
99 | this.__media = null;
100 | };
101 |
102 | this.load = function(/* source1, source2.. */)
103 | {
104 | if (arguments.length === 0) {
105 | throw new ArgumentError("load requires at least one url");
106 | }
107 |
108 | var self = this;
109 | var media = document.createElement('VIDEO');
110 | media.autoplay = false;
111 | media.loop = false;
112 | media.volume = this.__volume;
113 |
114 | for (var i = 0, l = arguments.length; i < l; ++i)
115 | {
116 | var request = arguments[i];
117 | if (typeof request == 'string') {
118 | request = new URLRequest(request);
119 | }
120 | var source = document.createElement('SOURCE');
121 | source.src = request.__url;
122 | media.appendChild(source);
123 | }
124 |
125 | cs3.utils.addEventListener(media, 'canplay', function(e)
126 | {
127 | self.__onCanPlay();
128 | cs3.utils.removeEventListener(media, 'canplay', arguments.callee);
129 | });
130 | cs3.utils.addEventListener(media, 'ended', function(e)
131 | {
132 | self.__onEnded();
133 | });
134 |
135 | media.style.display = "none";
136 | document.body.appendChild(media);
137 |
138 | this.__media = media;
139 | this.__url = media.currentSrc;
140 | };
141 |
142 | this.play = function(startTime, loops)
143 | {
144 | if (this.__media === null) {
145 | throw new ArgumentError("Invalid Video.");
146 | }
147 |
148 | var self = this;
149 | var media = this.__media;
150 | this.__isPlaying = true;
151 | this.__startTime = Number(startTime) || 0;
152 | this.__loops = loops | 0;
153 | this.__loopCount = 0;
154 |
155 | if (this.__canPlay) {
156 | media.currentTime = this.__startTime;
157 | media.play();
158 | }
159 | };
160 |
161 | this.pause = function()
162 | {
163 | if (this.__media === null) {
164 | throw new ArgumentError("Invalid Video.");
165 | }
166 | this.__media.pause();
167 | this.__isPlaying = false;
168 | };
169 |
170 | /* getters and setters */
171 | this.__get__length = function()
172 | {
173 | if (this.__media) {
174 | return this.__media.duration;
175 | }
176 | return 0;
177 | };
178 |
179 | this.__get__position = function()
180 | {
181 | if (this.__media) {
182 | return this.__media.currentTime;
183 | }
184 | return 0;
185 | };
186 |
187 | this.__get__url = function()
188 | {
189 | return this.__url;
190 | };
191 |
192 | this.__get__volume = function()
193 | {
194 | return this.__volume;
195 | };
196 |
197 | this.__set__volume = function(v)
198 | {
199 | this.__volume = v;
200 | if (this.__media) {
201 | this.__media.volume = v;
202 | }
203 | };
204 |
205 | this.toString = function()
206 | {
207 | return '[object Video]';
208 | };
209 | });
210 |
--------------------------------------------------------------------------------
/src/cs3/net/URLLoader.js:
--------------------------------------------------------------------------------
1 | var URLLoader = new Class(EventDispatcher, function()
2 | {
3 | this.__init__ = function()
4 | {
5 | EventDispatcher.call(this);
6 | this.__request = null;
7 | this.bytesLoaded = 0;
8 | this.bytesTotal = 0;
9 | this.data = null;
10 | this.dataFormat = URLLoaderDataFormat.TEXT;
11 | };
12 | this.close = function()
13 | {
14 | this.__request.abort();
15 | };
16 | this.load = function(request)
17 | {
18 | var self = this;
19 | var hasStatus = false;
20 | this.__request = new cs3.utils.createXMLHttpRequest();
21 |
22 | if (typeof request == 'string') {
23 | request = new URLRequest(request);
24 | }
25 |
26 | if (this.dataFormat == URLLoaderDataFormat.BINARY) {
27 | throw new Error("URLLoaderDataFormat.BINARY is not supported");
28 | }
29 |
30 | this.__request.open(request.__method, request.__url, true);
31 | this.__request.onreadystatechange = function() {
32 | if (!hasStatus) {
33 | try {
34 | self.dispatchEvent(new HTTPStatusEvent(HTTPStatusEvent.HTTP_STATUS, false, false, this.status));
35 | hasStatus = true;
36 | } catch (e) {}
37 | }
38 | if (this.readyState == 1) {
39 | self.dispatchEvent(new Event(Event.OPEN, false, false));
40 | }
41 | //else if (this.readyState == 2) {
42 | //}
43 | else if (this.readyState == 3) {
44 | var loaded = this.responseText.length;
45 | var total = this.getResponseHeader('Content-Length') || loaded + 1;
46 | self.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS, false, false, loaded, total));
47 | }
48 | else if (this.readyState == 4) {
49 | if (this.status == 200) {
50 | if (self.dataFormat === URLLoaderDataFormat.VARIABLES) {
51 | self.data = new URLVariables(this.responseText);
52 | }
53 | else if (self.dataFormat == URLLoaderDataFormat.XML) {
54 | self.data = this.responseXML;
55 | if (self.data === null) {
56 | throw new TypeError("Could not parse the XML file.");
57 | }
58 | }
59 | else if (self.dataFormat == URLLoaderDataFormat.JSON) {
60 | self.data = eval('(' + this.responseText + ')');
61 | }
62 | else {
63 | self.data = this.responseText;
64 | }
65 | self.dispatchEvent(new Event(Event.COMPLETE, false, false));
66 | }
67 | else {
68 | self.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, this.statusText));
69 | }
70 |
71 | this.onreadystatechange = null;
72 | }
73 | };
74 | this.__request.send(null);
75 | };
76 |
77 | this.toString = function()
78 | {
79 | return '[object URLLoader]';
80 | };
81 | });
82 |
--------------------------------------------------------------------------------
/src/cs3/net/URLLoaderDataFormat.js:
--------------------------------------------------------------------------------
1 | var URLLoaderDataFormat = {
2 | BINARY: 'binary',
3 | TEXT: 'text',
4 | XML: 'xml',
5 | JSON: 'json',
6 | VARIABLES: 'variables'
7 | };
8 |
--------------------------------------------------------------------------------
/src/cs3/net/URLRequest.js:
--------------------------------------------------------------------------------
1 | var URLRequest = new Class(Object, function()
2 | {
3 | this.__init__ = function(url)
4 | {
5 | this.__contentType = null;
6 | this.__data = null;
7 | this.__method = URLRequestMethod.GET;
8 | this.__requestHeaders = [];
9 | this.__url = (url !== undefined) ? url : null;
10 | };
11 |
12 | /* getters and setters */
13 | this.__get__contentType = function()
14 | {
15 | return this.__contentType;
16 | };
17 | this.__set__contentType = function(v)
18 | {
19 | this.__contentType = v;
20 | };
21 | this.__get__data = function()
22 | {
23 | return this.__data;
24 | };
25 | this.__set__data = function(v)
26 | {
27 | this.__data = v;
28 | };
29 | this.__get__method = function()
30 | {
31 | return this.__method;
32 | };
33 | this.__set__method = function(v)
34 | {
35 | this.__method = v;
36 | };
37 | this.__get__requestHeaders = function()
38 | {
39 | return this.__requestHeaders.slice(0);
40 | };
41 | this.__set__requestHeaders = function(v)
42 | {
43 | this.__requestHeaders = v.slice(0);
44 | };
45 | this.__get__url = function()
46 | {
47 | return this.__url;
48 | };
49 | this.__set__url = function(v)
50 | {
51 | this.__url = v;
52 | };
53 |
54 | this.toString = function()
55 | {
56 | return '[object URLRequest]';
57 | };
58 | });
59 |
--------------------------------------------------------------------------------
/src/cs3/net/URLRequestMethod.js:
--------------------------------------------------------------------------------
1 | var URLRequestMethod = {
2 | GET: 'GET',
3 | POST: 'POST'
4 | };
5 |
--------------------------------------------------------------------------------
/src/cs3/net/URLVariables.js:
--------------------------------------------------------------------------------
1 | var URLVariables = new Class(Object, function()
2 | {
3 | this.__init__ = function(src)
4 | {
5 | this.decode(src);
6 | };
7 | this.decode = function(src)
8 | {
9 | if (!src) { return; }
10 | var pairs = src.split('&');
11 | for (var i = 0, l = pairs.length; i < l; ++i)
12 | {
13 | var s = pairs[i];
14 | if (s.indexOf('=') === -1) {
15 | throw new Error('The String passed to URLVariables.decode () must be a URL-encoded query strings.');
16 | }
17 |
18 | var p = s.split('=', 2);
19 |
20 | if (this.hasOwnProperty(p[0])) {
21 | throw new ReferenceError('Cannot assign to a method ' + p[0] + ' on URLVariables');
22 | }
23 |
24 | this[p[0]] = decodeURIComponent(p[1]);
25 | }
26 | };
27 |
28 | this.toString = function()
29 | {
30 | var pairs = [];
31 | for (var p in this)
32 | {
33 | if (p != 'constructor' && p != 'decode' && p != 'toString') {
34 | pairs.push(p + '=' + encodeURIComponent(this[p]));
35 | }
36 | }
37 | return pairs.join('&');
38 | };
39 | });
40 |
--------------------------------------------------------------------------------
/src/cs3/text/TextFormat.js:
--------------------------------------------------------------------------------
1 | var TextFormat = new Class(Object, function()
2 | {
3 | this.__init__ = function(font, size, color, bold, italic, underline, url, target, align, leftMargin, rightMargin, indent, leading)
4 | {
5 | this.align = (align) ? align : TextFormatAlign.LEFT;
6 | this.blockIndent = 0;
7 | this.bold = (bold) ? true : false;
8 | this.bullet = false;
9 | this.color = color | 0;
10 | this.font = (font) ? font : "Times New Roman";//TODO MacOS should be 'Times'
11 | this.indent = (indent) ? indent : 0;
12 | this.italic = (italic) ? true : false;
13 | this.kerning = false;
14 | this.leading = (leading) ? leading : 0;
15 | this.leftMargin = (leftMargin) ? leftMargin : 0;
16 | this.rightMargin = (rightMargin) ? rightMargin : 0;
17 | this.size = (size) ? size : 12;
18 | this.tabStops = [];
19 | this.target = (target) ? target : "";
20 | this.underline = (underline) ? true : false;
21 | this.url = (url) ? url : "";
22 | };
23 |
24 | this.toString = function()
25 | {
26 | return '[object TextFormat]';
27 | };
28 | });
29 |
--------------------------------------------------------------------------------
/src/cs3/text/TextFormatAlign.js:
--------------------------------------------------------------------------------
1 | var TextFormatAlign = {
2 | CENTER: 'center',
3 | JUSTIFY: 'justify',
4 | LEFT: 'left',
5 | RIGHT: 'right'
6 | };
7 |
--------------------------------------------------------------------------------
/src/cs3/utils/Endian.js:
--------------------------------------------------------------------------------
1 | var Endian = {
2 | BIG_ENDIAN: 'bigEndian',
3 | LITTLE_ENDIAN: 'littleEndian'
4 | };
5 |
--------------------------------------------------------------------------------
/src/cs3/utils/Timer.js:
--------------------------------------------------------------------------------
1 | var Timer = new Class(EventDispatcher, function()
2 | {
3 | this.__init__ = function(delay, repeatCount)
4 | {
5 | EventDispatcher.call(this);
6 | this.__currentCount = 0;
7 | this.__delay = 0;
8 | this.__repeatCount = repeatCount | 0;
9 | this.__running = false;
10 | this.__timer = null;
11 |
12 | this.__set__delay(delay);
13 | };
14 | this.reset = function()
15 | {
16 | this.stop();
17 | this.__currentCount = 0;
18 | };
19 | this.start = function()
20 | {
21 | this.__running = true;
22 | this.__timer = setInterval(cs3.utils.closure(this, function()
23 | {
24 | this.__currentCount++;
25 |
26 | this.dispatchEvent(new TimerEvent(TimerEvent.TIMER, false, false));
27 |
28 | if (this.__repeatCount && this.__repeatCount <= this.__currentCount) {
29 | this.dispatchEvent(new TimerEvent(TimerEvent.TIMER_COMPLETE, false, false));
30 | this.stop();
31 | }
32 | }), this.__delay);
33 | };
34 | this.stop = function()
35 | {
36 | clearInterval(this.__timer);
37 | this.__running = false;
38 | };
39 |
40 | this.__get__currentCount = function()
41 | {
42 | return this.__currentCount;
43 | };
44 | this.__get__delay = function()
45 | {
46 | return this.__delay;
47 | };
48 | this.__set__delay = function(v)
49 | {
50 | v = +v;
51 | if (v < 0 || v == Infinity) {
52 | throw new RangeError('Error #2066: The Timer delay specified is out of range.');
53 | }
54 | this.__delay = v;
55 | };
56 | this.__get__repeatCount = function()
57 | {
58 | return this.__repeatCount;
59 | };
60 | this.__set__repeatCount = function(v)
61 | {
62 | this.__repeatCount = v | 0;
63 | };
64 | this.__get__running = function()
65 | {
66 | return this.__running;
67 | };
68 |
69 | this.toString = function()
70 | {
71 | return '[object Timer]';
72 | };
73 | });
74 |
--------------------------------------------------------------------------------
/src/cs3/utils/getTimer.js:
--------------------------------------------------------------------------------
1 | var getTimer = function()
2 | {
3 | return (cs3.core.initialized) ? (new Date()).getTime() - cs3.core.startTime : 0;
4 | };
5 |
--------------------------------------------------------------------------------
/tests/README.txt:
--------------------------------------------------------------------------------
1 | For some of the tests which use images you must access the page through a web server to make it work.
2 |
3 | To view the trace results open your browsers console window.
4 |
--------------------------------------------------------------------------------
/tests/bitmapdata_applyfilter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - ApplyFilter
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
31 |
32 |
Canvas
33 |
34 |
Output
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/tests/bitmapdata_colortransform.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - ColorTransform
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
30 |
31 |
Canvas
32 |
33 |
Output
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/tests/bitmapdata_copychannel.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - CopyChannel
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
30 |
31 |
Canvas
32 |
33 |
Output
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/tests/bitmapdata_copypixels.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - CopyPixels
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
31 |
32 |
Canvas
33 |
34 |
Output
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/tests/bitmapdata_fillrect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - FillRect
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
29 |
30 |
Canvas
31 |
32 |
Output
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/tests/bitmapdata_floodfill.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - FloodFill
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
30 |
31 |
Canvas
32 |
33 |
Output
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/tests/bitmapdata_merge.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - Merge
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
31 |
32 |
Canvas
33 |
34 |
Output
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/tests/bitmapdata_noise.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - Noise
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
28 |
29 |
Canvas
30 |
31 |
Output
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/tests/bitmapdata_palletmap.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - PalletMap
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
41 |
42 |
Canvas
43 |
44 |
Output
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/tests/bitmapdata_pixeldissolve.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - PixelDissolve
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
41 |
42 |
Canvas
43 |
44 |
Output
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/tests/bitmapdata_scroll.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - Scroll
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
30 |
31 |
Canvas
32 |
33 |
Output
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/tests/bitmapdata_threshold.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BitmapData - Treshold
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
30 |
31 |
Canvas
32 |
33 |
Output
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/tests/css/test.css:
--------------------------------------------------------------------------------
1 | @charset "utf-8";
2 | html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var,optgroup{font-style:inherit;font-weight:inherit;}del,ins{text-decoration:none;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:baseline;}sub{vertical-align:baseline;}legend{color:#000;}input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;}input,button,textarea,select{*font-size:100%;}body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}select,input,button,textarea,button{font:99% arial,helvetica,clean,sans-serif;}table{font-size:inherit;font:100%;}pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%;}
3 |
4 | html, body {
5 | margin:0;
6 | padding:0;
7 | border:0;
8 | width:100%;
9 | height:100%;
10 | }
11 |
12 | body, textarea {
13 | font-size:13px;
14 | font-family:Arial, Helvetica, sans-serif;
15 | }
16 |
17 | textarea {
18 | font-size:13px;
19 | font-family:"Bitstream Vera Sans Mono", "Courier", monospace;
20 | padding:10px;
21 | }
22 |
23 | p {
24 | margin:8px 16px;
25 | font-size:14px;
26 | }
27 |
28 | #layout {
29 | position:relative;
30 | margin:12px;
31 | height:900px;
32 | }
33 |
34 | #layout p {
35 | margin:0;
36 | }
37 |
38 | #code-label {
39 | position:absolute;
40 | top:0;
41 | left:0;
42 | font-weight:bold;
43 | }
44 | #code {
45 | position:absolute;
46 | top:20px;
47 | left:0;
48 | width:460px;
49 | height:480px;
50 | }
51 |
52 | #canvas-label {
53 | position:absolute;
54 | top:0;
55 | left:500px;
56 | font-weight:bold;
57 | }
58 | #canvas {
59 | position:absolute;
60 | top:20px;
61 | left:500px;
62 | border:1px solid #ccc;
63 | width:420px;
64 | height:500px;
65 | }
66 |
67 | #run {
68 | position:absolute;
69 | top:528px;
70 | left:0;
71 | padding:3px;
72 | }
73 |
74 | #output-label {
75 | position:absolute;
76 | top:540px;
77 | left:860px;
78 | font-weight:bold;
79 | }
80 | #output {
81 | position:absolute;
82 | top:560px;
83 | left:0;
84 | width:900px;
85 | height:280px;
86 | }
87 |
--------------------------------------------------------------------------------
/tests/displayobject_getbounds.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | DisplayObject - GetBounds
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
102 |
103 |
Canvas
104 |
105 |
Output
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/tests/displayobject_hittestobject.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | DisplayObject - HitTestObject
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
48 |
49 |
Canvas
50 |
51 |
Output
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/tests/displayobject_hittestpoint.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | DisplayObject - HitTestPoint
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
50 |
51 |
Canvas
52 |
53 |
Output
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/tests/displayobject_mask.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | DisplayObject - Mask
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
66 |
67 |
Canvas
68 |
69 |
Output
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/tests/graphics_beginbitmapfill.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - BeginBitmapFill
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
30 |
31 |
Canvas
32 |
33 |
Output
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/tests/graphics_beginlineargradientfill.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - BeginLinearGradientFill
7 |
8 |
9 |
10 |
11 |
12 | Replacement for Graphics.beginGradientFill(type=GradientType.LINEAR)
13 |
14 |
Code
15 |
97 |
98 |
Canvas
99 |
100 |
Output
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/tests/graphics_beginradialgradientfill.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - BeginRadialGradientFill
7 |
8 |
9 |
10 |
11 |
12 | Replacement for Graphics.beginGradientFill(type=GradientType.RADIAL)
13 |
14 |
Code
15 |
45 |
46 |
Canvas
47 |
48 |
Output
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/tests/graphics_curveto.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - CurveTo
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
63 |
64 |
Canvas
65 |
66 |
Output
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/tests/graphics_drawarc.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - DrawArc
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
72 |
73 |
Canvas
74 |
75 |
Output
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/tests/graphics_drawcircle.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - DrawCircle
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
72 |
73 |
Canvas
74 |
75 |
Output
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/tests/graphics_drawellipse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - DrawEllipse
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
46 |
47 |
Canvas
48 |
49 |
Output
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/tests/graphics_drawrect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - DrawRect
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
72 |
73 |
Canvas
74 |
75 |
Output
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/tests/graphics_drawroundrect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - DrawRoundRect
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
72 |
73 |
Canvas
74 |
75 |
Output
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/tests/graphics_linestyle.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - LineStyle
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
118 |
119 |
Canvas
120 |
121 |
Output
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/tests/graphics_lineto.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Graphics - LineTo
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
94 |
95 |
Canvas
96 |
97 |
Output
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/tests/img/Flap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arahaya/CanvasScript3/909dda54e1388eb0809aad420edad5d1e3ed39b1/tests/img/Flap.png
--------------------------------------------------------------------------------
/tests/img/floodfilltest.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arahaya/CanvasScript3/909dda54e1388eb0809aad420edad5d1e3ed39b1/tests/img/floodfilltest.gif
--------------------------------------------------------------------------------
/tests/img/pattern.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arahaya/CanvasScript3/909dda54e1388eb0809aad420edad5d1e3ed39b1/tests/img/pattern.png
--------------------------------------------------------------------------------
/tests/img/photo01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arahaya/CanvasScript3/909dda54e1388eb0809aad420edad5d1e3ed39b1/tests/img/photo01.jpg
--------------------------------------------------------------------------------
/tests/img/photo02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arahaya/CanvasScript3/909dda54e1388eb0809aad420edad5d1e3ed39b1/tests/img/photo02.jpg
--------------------------------------------------------------------------------
/tests/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 | CanvasScript3 Tests
12 |
13 |
14 | CanvasScript3 Tests
15 | Graphics
16 |
29 | Rendering
30 |
33 | MouseEvent
34 |
45 | KeyboardEvent
46 |
50 | DisplayObject
51 |
57 | Sprite
58 |
61 | Loader
62 |
65 | BitmapData
66 |
80 | Tween
81 |
86 |
87 |
--------------------------------------------------------------------------------
/tests/js/test.js:
--------------------------------------------------------------------------------
1 | cs3.utils.addOnload(function()
2 | {
3 | //override the trace function
4 | trace = function()
5 | {
6 | var msg = Array.prototype.join.apply(arguments);
7 |
8 | var output = document.getElementById('output');
9 | if (output) {
10 | output.value += msg + "\n";
11 | }
12 |
13 | try {
14 | console.log(msg);
15 | }
16 | catch (e) {}
17 | }
18 | });
19 |
20 | function runCode()
21 | {
22 | var output = document.getElementById('output');
23 | if (output) {
24 | output.value = "";
25 | }
26 |
27 | var codePanel = document.getElementById('code');
28 | if (codePanel) {
29 | var code = codePanel.value;
30 | try {
31 | (function(){
32 | eval(code);
33 | }).apply(window);
34 | }
35 | catch (e) {
36 | trace(e);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tests/keyboardevent_keydown.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | KeyboardEvent - KeyDown
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
29 |
30 |
Canvas
31 |
32 |
Output
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/tests/keyboardevent_keyup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | KeyboardEvent - KeyUp
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
29 |
30 |
Canvas
31 |
32 |
Output
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/tests/loader_load.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Loader - Load
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
29 |
30 |
Canvas
31 |
32 |
Output
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/tests/mouseevent_click.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - Click
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
65 |
66 |
Canvas
67 |
68 |
Output
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/tests/mouseevent_doubleclick.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - DoubleClick
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
65 |
66 |
Canvas
67 |
68 |
Output
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/tests/mouseevent_mousedown.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - MouseDown
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
65 |
66 |
Canvas
67 |
68 |
Output
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/tests/mouseevent_mouseout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - MouseOut
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
65 |
66 |
Canvas
67 |
68 |
Output
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/tests/mouseevent_mouseover.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - MouseOver
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
65 |
66 |
Canvas
67 |
68 |
Output
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/tests/mouseevent_mouseup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - MouseUp
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
65 |
66 |
Canvas
67 |
68 |
Output
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/tests/mouseevent_mousewheel.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - MouseWheel
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
34 |
35 |
Canvas
36 |
37 |
Output
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/tests/mouseevent_rollout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - RollOut
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
65 |
66 |
Canvas
67 |
68 |
Output
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/tests/mouseevent_rollover.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MouseEvent - RollOver
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
65 |
66 |
Canvas
67 |
68 |
Output
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/tests/rendering_displaylist.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Rendering - DisplayList
7 |
8 |
9 |
10 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/tests/rendering_layers.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Rendering - Layers
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
85 |
86 |
Canvas
87 |
88 |
Output
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/tests/sprite_startdrag.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Sprite - StartDrag
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
77 |
78 |
Canvas
79 |
80 |
Output
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/tests/tween_looping.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Tween - Looping
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
48 |
49 |
Canvas
50 |
51 |
Output
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/tests/tween_start.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Tween - Start
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
44 |
45 |
Canvas
46 |
47 |
Output
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/tests/tween_yoyo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Tween - Yoyo
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Code
14 |
49 |
50 |
Canvas
51 |
52 |
Output
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------