9 |
10 |
11 |
12 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/tutorials/SoundJS and PreloadJS/preloadjs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SoundJS demo: Using PreloadJS
5 |
6 |
7 |
8 |
9 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/tests/tasks/listips.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 gskinner.com, inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person
5 | * obtaining a copy of this software and associated documentation
6 | * files (the "Software"), to deal in the Software without
7 | * restriction, including without limitation the rights to use,
8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following
11 | * conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be
14 | * included in all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | module.exports = function (grunt) {
27 | var os = require('os');
28 |
29 | grunt.registerMultiTask('listips', 'Prints a list of active ips.', function() {
30 | var opts = this.options({"port": 80});
31 |
32 | var port = opts.port;
33 | var label = opts.label?'('+opts.label+') ':'';
34 |
35 | if (port == 80) {
36 | port = '';
37 | } else {
38 | port = ':'+port;
39 | }
40 |
41 | var interfaces = os.networkInterfaces();
42 | var addresses = [];
43 | for (var n in interfaces) {
44 | for (var n2 in interfaces[n]) {
45 | var address = interfaces[n][n2];
46 | if (address.family == 'IPv4' && !address.internal) {
47 | addresses.push('http://'+address.address+port);
48 | }
49 | }
50 | }
51 |
52 | addresses.push('http://localhost'+port);
53 | grunt.log.subhead('\n'+label+'Listening on:\n\t', addresses.join('\n\t '));
54 | });
55 | }
56 |
--------------------------------------------------------------------------------
/src/createjs/utils/indexOf.js:
--------------------------------------------------------------------------------
1 | /*
2 | * indexOf
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | * Copyright (c) 2010 gskinner.com, inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without
10 | * restriction, including without limitation the rights to use,
11 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the
13 | * Software is furnished to do so, subject to the following
14 | * conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be
17 | * included in all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 | * OTHER DEALINGS IN THE SOFTWARE.
27 | */
28 |
29 | /**
30 | * @module CreateJS
31 | */
32 |
33 | // namespace:
34 | this.createjs = this.createjs||{};
35 |
36 | /**
37 | * @class Utility Methods
38 | */
39 |
40 | /**
41 | * Finds the first occurrence of a specified value searchElement in the passed in array, and returns the index of
42 | * that value. Returns -1 if value is not found.
43 | *
44 | * var i = createjs.indexOf(myArray, myElementToFind);
45 | *
46 | * @method indexOf
47 | * @param {Array} array Array to search for searchElement
48 | * @param searchElement Element to find in array.
49 | * @return {Number} The first index of searchElement in array.
50 | */
51 | createjs.indexOf = function (array, searchElement){
52 | "use strict";
53 |
54 | for (var i = 0,l=array.length; i < l; i++) {
55 | if (searchElement === array[i]) {
56 | return i;
57 | }
58 | }
59 | return -1;
60 | };
61 |
--------------------------------------------------------------------------------
/src/preloadjs/data/Methods.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Methods
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | *
6 | * Copyright (c) 2012 gskinner.com, inc.
7 | *
8 | * Permission is hereby granted, free of charge, to any person
9 | * obtaining a copy of this software and associated documentation
10 | * files (the "Software"), to deal in the Software without
11 | * restriction, including without limitation the rights to use,
12 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the
14 | * Software is furnished to do so, subject to the following
15 | * conditions:
16 | *
17 | * The above copyright notice and this permission notice shall be
18 | * included in all copies or substantial portions of the Software.
19 | *
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | * OTHER DEALINGS IN THE SOFTWARE.
28 | */
29 |
30 | /**
31 | * @module PreloadJS
32 | */
33 |
34 | // namespace:
35 | this.createjs = this.createjs || {};
36 |
37 | (function() {
38 |
39 | "use strict";
40 |
41 | /**
42 | * Defines the method types for XHR requests. Currently, PreloadJS only supports "POST" and "GET", however
43 | * any HTML method can be used with PreloadJS utilities.
44 | *
45 | * @class Methods
46 | * @static
47 | */
48 | var s = {};
49 |
50 | /**
51 | * Defines a POST request, use for a method value when loading data.
52 | * @property POST
53 | * @type {string}
54 | * @default post
55 | * @static
56 | */
57 | s.POST = "POST";
58 |
59 | /**
60 | * Defines a GET request, use for a method value when loading data.
61 | * @property GET
62 | * @type {string}
63 | * @default get
64 | * @static
65 | */
66 | s.GET = "GET";
67 |
68 | createjs.Methods = s;
69 | }());
70 |
--------------------------------------------------------------------------------
/tutorials/_shared/SyntaxHighlighter/shBrushXml.js:
--------------------------------------------------------------------------------
1 | /**
2 | * SyntaxHighlighter
3 | * http://alexgorbatchev.com/SyntaxHighlighter
4 | *
5 | * SyntaxHighlighter is donationware. If you are using it, please donate.
6 | * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
7 | *
8 | * @version
9 | * 3.0.83 (July 02 2010)
10 | *
11 | * @copyright
12 | * Copyright (C) 2004-2010 Alex Gorbatchev.
13 | *
14 | * @license
15 | * Dual licensed under the MIT and GPL licenses.
16 | */
17 | ;(function()
18 | {
19 | // CommonJS
20 | typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
21 |
22 | function Brush()
23 | {
24 | function process(match, regexInfo)
25 | {
26 | var constructor = SyntaxHighlighter.Match,
27 | code = match[0],
28 | tag = new XRegExp('(<|<)[\\s\\/\\?]*(?[:\\w-\\.]+)', 'xg').exec(code),
29 | result = []
30 | ;
31 |
32 | if (match.attributes != null)
33 | {
34 | var attributes,
35 | regex = new XRegExp('(? [\\w:\\-\\.]+)' +
36 | '\\s*=\\s*' +
37 | '(? ".*?"|\'.*?\'|\\w+)',
38 | 'xg');
39 |
40 | while ((attributes = regex.exec(code)) != null)
41 | {
42 | result.push(new constructor(attributes.name, match.index + attributes.index, 'color1'));
43 | result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string'));
44 | }
45 | }
46 |
47 | if (tag != null)
48 | result.push(
49 | new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword')
50 | );
51 |
52 | return result;
53 | }
54 |
55 | this.regexList = [
56 | { regex: new XRegExp('(\\<|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\>|>)', 'gm'), css: 'color2' }, //
57 | { regex: SyntaxHighlighter.regexLib.xmlComments, css: 'comments' }, //
58 | { regex: new XRegExp('(<|<)[\\s\\/\\?]*(\\w+)(?.*?)[\\s\\/\\?]*(>|>)', 'sg'), func: process }
59 | ];
60 | };
61 |
62 | Brush.prototype = new SyntaxHighlighter.Highlighter();
63 | Brush.aliases = ['xml', 'xhtml', 'xslt', 'html'];
64 |
65 | SyntaxHighlighter.brushes.Xml = Brush;
66 |
67 | // CommonJS
68 | typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
69 | })();
70 |
--------------------------------------------------------------------------------
/src/createjs/utils/extend.js:
--------------------------------------------------------------------------------
1 | /*
2 | * extend
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | * Copyright (c) 2010 gskinner.com, inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without
10 | * restriction, including without limitation the rights to use,
11 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the
13 | * Software is furnished to do so, subject to the following
14 | * conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be
17 | * included in all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 | * OTHER DEALINGS IN THE SOFTWARE.
27 | */
28 |
29 | /**
30 | * @module CreateJS
31 | */
32 |
33 | // namespace:
34 | this.createjs = this.createjs||{};
35 |
36 | /**
37 | * @class Utility Methods
38 | */
39 |
40 | /**
41 | * Sets up the prototype chain and constructor property for a new class.
42 | *
43 | * This should be called right after creating the class constructor.
44 | *
45 | * function MySubClass() {}
46 | * createjs.extend(MySubClass, MySuperClass);
47 | * MySubClass.prototype.doSomething = function() { }
48 | *
49 | * var foo = new MySubClass();
50 | * console.log(foo instanceof MySuperClass); // true
51 | * console.log(foo.prototype.constructor === MySubClass); // true
52 | *
53 | * @method extend
54 | * @param {Function} subclass The subclass.
55 | * @param {Function} superclass The superclass to extend.
56 | * @return {Function} Returns the subclass's new prototype.
57 | */
58 | createjs.extend = function(subclass, superclass) {
59 | "use strict";
60 |
61 | function o() { this.constructor = subclass; }
62 | o.prototype = superclass.prototype;
63 | return (subclass.prototype = new o());
64 | };
65 |
--------------------------------------------------------------------------------
/tutorials/_shared/tutorial.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 3em;
3 | padding: 0;
4 | background-color: #eaebee;
5 | font-family: Arial, Verdana, sans-serif;
6 | font-size: 14px;
7 | font-weight: normal;
8 | color: #333;
9 | line-height: 1.4em;
10 | }
11 |
12 | article {
13 | width: 55em;
14 | margin-left: auto;
15 | margin-right: auto;
16 | }
17 |
18 | a:link, a:visited {
19 | color: #39f;
20 | text-decoration: none;
21 | }
22 |
23 | a:hover {
24 | text-decoration: underline;
25 | }
26 |
27 | header p {
28 | color: #999b9f;
29 | margin: 0;
30 | padding: 0.8em;
31 | line-height: 1.6em;
32 | font-size: 0.9em;
33 | }
34 |
35 | header p strong {
36 | color: #808387;
37 | text-transform: uppercase;
38 | }
39 |
40 | h1::after {
41 | display: block;
42 | content: "";
43 | background: url('../_shared/createjs-logo-horizontal-gray-lightest.svg') no-repeat;
44 | height:2em;
45 | width: 6em;
46 | margin-top: -0.1em;
47 | float: right;
48 | }
49 |
50 | h1, h2 {
51 | color: #FFF;
52 | font-size: 1.6em;
53 | margin-bottom: 0;
54 | padding: 1.5em;
55 | padding-bottom: 1.2em;
56 | background: #374252;
57 | text-transform: uppercase;
58 | }
59 |
60 | h1 em {
61 | font-weight: 200;
62 | font-style: normal;
63 | }
64 |
65 | h2 {
66 | font-size: 1.3em;
67 | padding: 1em;
68 | padding-bottom: 0.8em;
69 | }
70 |
71 | h3 {
72 | background: #e0e1e5;
73 | color: #374252;
74 | font-size: 1.25em;
75 | padding: 0.5em;
76 | margin-top: 1.25em;
77 | margin-bottom: -0.5em;
78 | position: relative;
79 | }
80 |
81 | div.demo {
82 | border: solid 2px rgba(255, 255, 255, 0.4);
83 | }
84 |
85 | div.demo p {
86 | margin: 0;
87 | padding: 4px;
88 | font-size: 0.9em;
89 | }
90 |
91 | textarea {
92 | width: 100%;
93 | height: 60px;
94 | }
95 |
96 | div.demo p a {
97 | float: right;
98 | }
99 |
100 | iframe.demo {
101 | background-color: rgba(255, 255, 255, 0.25);
102 | border: none;
103 | margin-right: 8px;
104 | }
105 |
106 | code {
107 | color: black;
108 | background-color: rgba(255, 230, 0, 0.33);
109 | padding: 1px 3px;
110 | font-family: Courier New, Courier, serif;
111 | font-weight: bold;
112 | }
113 |
114 | A code, code A {
115 | color: rgb(0, 0, 172);
116 | }
117 |
118 | .highlight {
119 | background-color: rgba(250, 252, 255, 0.7);
120 | margin: 0;
121 | padding: 0.8em;
122 | }
--------------------------------------------------------------------------------
/tests/tasks/findopenport.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 gskinner.com, inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person
5 | * obtaining a copy of this software and associated documentation
6 | * files (the "Software"), to deal in the Software without
7 | * restriction, including without limitation the rights to use,
8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following
11 | * conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be
14 | * included in all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | module.exports = function (grunt) {
27 | var net = require('net');
28 | var _callback;
29 | var _ports;
30 | var _opts;
31 | var _done;
32 |
33 | grunt.registerMultiTask('findopenport', 'Prints a list of active ips.', function() {
34 | _opts = this.options();
35 |
36 | _done = this.async();
37 | _ports = _opts['ports'] || [80, 8888, 9000, 9999, 9001];
38 | checkNext();
39 | });
40 |
41 | function checkNext() {
42 | if (!_ports.length) {
43 | grunt.option(_portName, -1);
44 | _done();
45 | return;
46 | }
47 |
48 | check(_ports.shift(), function(success, port) {
49 | if (!success) {
50 | checkNext();
51 | } else {
52 | //grunt.option(_portName, port);
53 | var configNames = Array.isArray(_opts.configName)?_opts.configName:[_opts.configName];
54 |
55 | configNames.forEach(function(item) {
56 | grunt.config.set(item, port);
57 | });
58 | _done();
59 | }
60 | });
61 | }
62 |
63 | function check(port, callback) {
64 | var server = net.createServer();
65 | server.on('error', function(e) {
66 | callback(false, port);
67 | });
68 |
69 | server.listen(port, function() {
70 | callback(true, port);
71 | server.close();
72 | });
73 | }
74 | };
75 |
--------------------------------------------------------------------------------
/src/preloadjs/utils/Elements.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Elements
3 | *
4 | * Visit http://createjs.com/ for documentation, updates and examples.
5 | *
6 | *
7 | * Copyright (c) 2012 gskinner.com, inc.
8 | *
9 | * Permission is hereby granted, free of charge, to any person
10 | * obtaining a copy of this software and associated documentation
11 | * files (the "Software"), to deal in the Software without
12 | * restriction, including without limitation the rights to use,
13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * copies of the Software, and to permit persons to whom the
15 | * Software is furnished to do so, subject to the following
16 | * conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be
19 | * included in all copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 | * OTHER DEALINGS IN THE SOFTWARE.
29 | */
30 |
31 | /**
32 | * @module PreloadJS
33 | */
34 |
35 | (function () {
36 |
37 | /**
38 | * Convenience methods for creating various elements used by PrelaodJS.
39 | *
40 | * @class DomUtils
41 | */
42 | var s = {};
43 |
44 | s.a = function() {
45 | return s.el("a");
46 | }
47 |
48 | s.svg = function() {
49 | return s.el("svg");
50 | }
51 |
52 | s.object = function() {
53 | return s.el("object");
54 | }
55 |
56 | s.image = function() {
57 | return s.el("image");
58 | }
59 |
60 | s.img = function() {
61 | return s.el("img");
62 | }
63 |
64 | s.style = function() {
65 | return s.el("style");
66 | }
67 |
68 | s.link = function() {
69 | return s.el("link");
70 | }
71 |
72 | s.script = function() {
73 | return s.el("script");
74 | }
75 |
76 | s.audio = function() {
77 | return s.el("audio");
78 | }
79 |
80 | s.video = function() {
81 | return s.el("video");
82 | }
83 |
84 | s.text = function(value) {
85 | return document.createTextNode(value);
86 | }
87 |
88 | s.el = function(name) {
89 | return document.createElement(name);
90 | }
91 |
92 | createjs.Elements = s;
93 |
94 | }());
95 |
--------------------------------------------------------------------------------
/src/preloadjs/net/AbstractRequest.js:
--------------------------------------------------------------------------------
1 | /*
2 | * AbstractRequest
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | *
6 | * Copyright (c) 2012 gskinner.com, inc.
7 | *
8 | * Permission is hereby granted, free of charge, to any person
9 | * obtaining a copy of this software and associated documentation
10 | * files (the "Software"), to deal in the Software without
11 | * restriction, including without limitation the rights to use,
12 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the
14 | * Software is furnished to do so, subject to the following
15 | * conditions:
16 | *
17 | * The above copyright notice and this permission notice shall be
18 | * included in all copies or substantial portions of the Software.
19 | *
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | * OTHER DEALINGS IN THE SOFTWARE.
28 | */
29 |
30 | /**
31 | * @module PreloadJS
32 | */
33 |
34 | // namespace:
35 | this.createjs = this.createjs || {};
36 |
37 | (function () {
38 | "use strict";
39 |
40 | /**
41 | * A base class for actual data requests, such as {{#crossLink "XHRRequest"}}{{/crossLink}}, {{#crossLink "TagRequest"}}{{/crossLink}},
42 | * and {{#crossLink "MediaRequest"}}{{/crossLink}}. PreloadJS loaders will typically use a data loader under the
43 | * hood to get data.
44 | * @class AbstractRequest
45 | * @param {LoadItem} item
46 | * @constructor
47 | */
48 | var AbstractRequest = function (item) {
49 | this._item = item;
50 | };
51 |
52 | var p = createjs.extend(AbstractRequest, createjs.EventDispatcher);
53 |
54 | // public methods
55 | /**
56 | * Begin a load.
57 | * @method load
58 | */
59 | p.load = function() {};
60 |
61 | /**
62 | * Clean up a request.
63 | * @method destroy
64 | */
65 | p.destroy = function() {};
66 |
67 | /**
68 | * Cancel an in-progress request.
69 | * @method cancel
70 | */
71 | p.cancel = function() {};
72 |
73 | createjs.AbstractRequest = createjs.promote(AbstractRequest, "EventDispatcher");
74 |
75 | }());
--------------------------------------------------------------------------------
/src/createjs/events/ErrorEvent.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Event
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | * Copyright (c) 2010 gskinner.com, inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without
10 | * restriction, including without limitation the rights to use,
11 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the
13 | * Software is furnished to do so, subject to the following
14 | * conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be
17 | * included in all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 | * OTHER DEALINGS IN THE SOFTWARE.
27 | */
28 |
29 | /**
30 | * @module CreateJS
31 | */
32 |
33 | // namespace:
34 | this.createjs = this.createjs||{};
35 |
36 | (function() {
37 | "use strict";
38 |
39 | /**
40 | * A general error {{#crossLink "Event"}}{{/crossLink}}, that describes an error that occurred, as well as any details.
41 | * @class ErrorEvent
42 | * @param {String} [title] The error title
43 | * @param {String} [message] The error description
44 | * @param {Object} [data] Additional error data
45 | * @constructor
46 | */
47 | function ErrorEvent(title, message, data) {
48 | this.Event_constructor("error");
49 |
50 | /**
51 | * The short error title, which indicates the type of error that occurred.
52 | * @property title
53 | * @type String
54 | */
55 | this.title = title;
56 |
57 | /**
58 | * The verbose error message, containing details about the error.
59 | * @property message
60 | * @type String
61 | */
62 | this.message = message;
63 |
64 | /**
65 | * Additional data attached to an error.
66 | * @property data
67 | * @type {Object}
68 | */
69 | this.data = data;
70 | }
71 |
72 | var p = createjs.extend(ErrorEvent, createjs.Event);
73 |
74 | p.clone = function() {
75 | return new createjs.ErrorEvent(this.title, this.message, this.data);
76 | };
77 |
78 | createjs.ErrorEvent = createjs.promote(ErrorEvent, "Event");
79 |
80 | }());
--------------------------------------------------------------------------------
/src/createjs/utils/deprecate.js:
--------------------------------------------------------------------------------
1 | /*
2 | * extend
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | * Copyright (c) 2010 gskinner.com, inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without
10 | * restriction, including without limitation the rights to use,
11 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the
13 | * Software is furnished to do so, subject to the following
14 | * conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be
17 | * included in all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 | * OTHER DEALINGS IN THE SOFTWARE.
27 | */
28 |
29 | /**
30 | * @module CreateJS
31 | */
32 |
33 | // namespace:
34 | this.createjs = this.createjs||{};
35 |
36 | /**
37 | * @class Utility Methods
38 | */
39 |
40 | /**
41 | * Wraps deprecated methods so they still be used, but throw warnings to developers.
42 | *
43 | * obj.deprecatedMethod = createjs.deprecate("Old Method Name", obj._fallbackMethod);
44 | *
45 | * The recommended approach for deprecated properties is:
46 | *
47 | * try {
48 | * Obj ect.defineProperties(object, {
49 | * readyOnlyProp: { get: createjs.deprecate("readOnlyProp", function() { return this.alternateProp; }) },
50 | * readWriteProp: {
51 | * get: createjs.deprecate("readOnlyProp", function() { return this.alternateProp; }),
52 | * set: createjs.deprecate("readOnlyProp", function(val) { this.alternateProp = val; })
53 | * });
54 | * } catch (e) {}
55 | *
56 | * @method deprecate
57 | * @param {Function} [fallbackMethod=null] A method to call when the deprecated method is used. See the example for how
58 | * @param {String} [name=null] The name of the method or property to display in the console warning.
59 | * to deprecate properties.
60 | * @return {Function} If a fallbackMethod is supplied, returns a closure that will call the fallback method after
61 | * logging the warning in the console.
62 | */
63 | createjs.deprecate = function(fallbackMethod, name) {
64 | "use strict";
65 | return function() {
66 | var msg = "Deprecated property or method '"+name+"'. See docs for info.";
67 | console && (console.warn ? console.warn(msg) : console.log(msg));
68 | return fallbackMethod && fallbackMethod.apply(this, arguments);
69 | }
70 | };
--------------------------------------------------------------------------------
/src/createjs/utils/proxy.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Proxy
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | * Copyright (c) 2010 gskinner.com, inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without
10 | * restriction, including without limitation the rights to use,
11 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the
13 | * Software is furnished to do so, subject to the following
14 | * conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be
17 | * included in all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 | * OTHER DEALINGS IN THE SOFTWARE.
27 | */
28 |
29 | /**
30 | * @module CreateJS
31 | */
32 |
33 | // namespace:
34 | this.createjs = this.createjs||{};
35 |
36 | /**
37 | * Various utilities that the CreateJS Suite uses. Utilities are created as separate files, and will be available on the
38 | * createjs namespace directly.
39 | *
40 | *
Example
41 | *
42 | * myObject.addEventListener("change", createjs.proxy(myMethod, scope));
43 | *
44 | * @class Utility Methods
45 | * @main Utility Methods
46 | */
47 |
48 | (function() {
49 | "use strict";
50 |
51 | /**
52 | * A function proxy for methods. By default, JavaScript methods do not maintain scope, so passing a method as a
53 | * callback will result in the method getting called in the scope of the caller. Using a proxy ensures that the
54 | * method gets called in the correct scope.
55 | *
56 | * Additional arguments can be passed that will be applied to the function when it is called.
57 | *
58 | *
Example
59 | *
60 | * myObject.addEventListener("event", createjs.proxy(myHandler, this, arg1, arg2));
61 | *
62 | * function myHandler(arg1, arg2) {
63 | * // This gets called when myObject.myCallback is executed.
64 | * }
65 | *
66 | * @method proxy
67 | * @param {Function} method The function to call
68 | * @param {Object} scope The scope to call the method name on
69 | * @param {mixed} [arg] * Arguments that are appended to the callback for additional params.
70 | * @public
71 | * @static
72 | */
73 | createjs.proxy = function (method, scope) {
74 | var aArgs = Array.prototype.slice.call(arguments, 2);
75 | return function () {
76 | return method.apply(scope, Array.prototype.slice.call(arguments, 0).concat(aArgs));
77 | };
78 | }
79 |
80 | }());
81 |
--------------------------------------------------------------------------------
/examples/Game/Ship.js:
--------------------------------------------------------------------------------
1 | (function (window) {
2 |
3 | function Ship() {
4 | this.Container_constructor();
5 |
6 | this.shipFlame = new createjs.Shape();
7 | this.shipBody = new createjs.Shape();
8 |
9 | this.addChild(this.shipFlame);
10 | this.addChild(this.shipBody);
11 |
12 | this.makeShape();
13 | this.timeout = 0;
14 | this.thrust = 0;
15 | this.vX = 0;
16 | this.vY = 0;
17 | }
18 | var p = createjs.extend(Ship, createjs.Container);
19 |
20 | // public properties:
21 | Ship.TOGGLE = 60;
22 | Ship.MAX_THRUST = 2;
23 | Ship.MAX_VELOCITY = 5;
24 |
25 | // public properties:
26 | p.shipFlame;
27 | p.shipBody;
28 |
29 | p.timeout;
30 | p.thrust;
31 |
32 | p.vX;
33 | p.vY;
34 |
35 | p.bounds;
36 | p.hit;
37 |
38 |
39 | // public methods:
40 | p.makeShape = function () {
41 | //draw ship body
42 | var g = this.shipBody.graphics;
43 | g.clear();
44 | g.beginStroke("#FFFFFF");
45 |
46 | g.moveTo(0, 10); //nose
47 | g.lineTo(5, -6); //rfin
48 | g.lineTo(0, -2); //notch
49 | g.lineTo(-5, -6); //lfin
50 | g.closePath(); // nose
51 |
52 |
53 | //draw ship flame
54 | var o = this.shipFlame;
55 | o.scaleX = 0.5;
56 | o.scaleY = 0.5;
57 | o.y = -5;
58 |
59 | g = o.graphics;
60 | g.clear();
61 | g.beginStroke("#FFFFFF");
62 |
63 | g.moveTo(2, 0); //ship
64 | g.lineTo(4, -3); //rpoint
65 | g.lineTo(2, -2); //rnotch
66 | g.lineTo(0, -5); //tip
67 | g.lineTo(-2, -2); //lnotch
68 | g.lineTo(-4, -3); //lpoint
69 | g.lineTo(-2, -0); //ship
70 |
71 | //furthest visual element
72 | this.bounds = 10;
73 | this.hit = this.bounds;
74 | }
75 |
76 | p.tick = function (event) {
77 | //move by velocity
78 | this.x += this.vX;
79 | this.y += this.vY;
80 |
81 | //with thrust flicker a flame every Ship.TOGGLE frames, attenuate thrust
82 | if (this.thrust > 0) {
83 | this.timeout++;
84 | this.shipFlame.alpha = 1;
85 |
86 | if (this.timeout > Ship.TOGGLE) {
87 | this.timeout = 0;
88 | if (this.shipFlame.scaleX == 1) {
89 | this.shipFlame.scaleX = 0.5;
90 | this.shipFlame.scaleY = 0.5;
91 | } else {
92 | this.shipFlame.scaleX = 1;
93 | this.shipFlame.scaleY = 1;
94 | }
95 | }
96 | this.thrust -= 0.5;
97 | } else {
98 | this.shipFlame.alpha = 0;
99 | this.thrust = 0;
100 | }
101 | }
102 |
103 | p.accelerate = function () {
104 | //increase push amount for acceleration
105 | this.thrust += this.thrust + 0.6;
106 | if (this.thrust >= Ship.MAX_THRUST) {
107 | this.thrust = Ship.MAX_THRUST;
108 | }
109 |
110 | //accelerate
111 | this.vX += Math.sin(this.rotation * (Math.PI / -180)) * this.thrust;
112 | this.vY += Math.cos(this.rotation * (Math.PI / -180)) * this.thrust;
113 |
114 | //cap max speeds
115 | this.vX = Math.min(Ship.MAX_VELOCITY, Math.max(-Ship.MAX_VELOCITY, this.vX));
116 | this.vY = Math.min(Ship.MAX_VELOCITY, Math.max(-Ship.MAX_VELOCITY, this.vY));
117 | }
118 |
119 | window.Ship = createjs.promote(Ship, "Container");
120 |
121 | }(window));
122 |
--------------------------------------------------------------------------------
/src/preloadjs/events/ProgressEvent.js:
--------------------------------------------------------------------------------
1 | /*
2 | * ProgressEvent
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | *
6 | * Copyright (c) 2012 gskinner.com, inc.
7 | *
8 | * Permission is hereby granted, free of charge, to any person
9 | * obtaining a copy of this software and associated documentation
10 | * files (the "Software"), to deal in the Software without
11 | * restriction, including without limitation the rights to use,
12 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the
14 | * Software is furnished to do so, subject to the following
15 | * conditions:
16 | *
17 | * The above copyright notice and this permission notice shall be
18 | * included in all copies or substantial portions of the Software.
19 | *
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | * OTHER DEALINGS IN THE SOFTWARE.
28 | */
29 |
30 | /**
31 | * @module PreloadJS
32 | */
33 |
34 | // namespace:
35 | this.createjs = this.createjs || {};
36 |
37 | (function (scope) {
38 | "use strict";
39 |
40 | // constructor
41 | /**
42 | * A CreateJS {{#crossLink "Event"}}{{/crossLink}} that is dispatched when progress changes.
43 | * @class ProgressEvent
44 | * @param {Number} loaded The amount that has been loaded. This can be any number relative to the total.
45 | * @param {Number} [total=1] The total amount that will load. This will default to 1, so if the `loaded` value is
46 | * a percentage (between 0 and 1), it can be omitted.
47 | * @todo Consider having this event be a "fileprogress" event as well
48 | * @constructor
49 | */
50 | function ProgressEvent(loaded, total) {
51 | this.Event_constructor("progress");
52 |
53 | /**
54 | * The amount that has been loaded (out of a total amount)
55 | * @property loaded
56 | * @type {Number}
57 | */
58 | this.loaded = loaded;
59 |
60 | /**
61 | * The total "size" of the load.
62 | * @property total
63 | * @type {Number}
64 | * @default 1
65 | */
66 | this.total = (total == null) ? 1 : total;
67 |
68 | /**
69 | * The percentage (out of 1) that the load has been completed. This is calculated using `loaded/total`.
70 | * @property progress
71 | * @type {Number}
72 | * @default 0
73 | */
74 | this.progress = (total == 0) ? 0 : this.loaded / this.total;
75 | };
76 |
77 | var p = createjs.extend(ProgressEvent, createjs.Event);
78 |
79 | /**
80 | * Returns a clone of the ProgressEvent instance.
81 | * @method clone
82 | * @return {ProgressEvent} a clone of the Event instance.
83 | **/
84 | p.clone = function() {
85 | return new createjs.ProgressEvent(this.loaded, this.total);
86 | };
87 |
88 | createjs.ProgressEvent = createjs.promote(ProgressEvent, "Event");
89 |
90 | }(window));
--------------------------------------------------------------------------------
/src/soundjs/webaudio/WebAudioLoader.js:
--------------------------------------------------------------------------------
1 | /*
2 | * WebAudioLoader
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | *
6 | * Copyright (c) 2012 gskinner.com, inc.
7 | *
8 | * Permission is hereby granted, free of charge, to any person
9 | * obtaining a copy of this software and associated documentation
10 | * files (the "Software"), to deal in the Software without
11 | * restriction, including without limitation the rights to use,
12 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the
14 | * Software is furnished to do so, subject to the following
15 | * conditions:
16 | *
17 | * The above copyright notice and this permission notice shall be
18 | * included in all copies or substantial portions of the Software.
19 | *
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | * OTHER DEALINGS IN THE SOFTWARE.
28 | */
29 |
30 | /**
31 | * @module SoundJS
32 | */
33 |
34 | // namespace:
35 | this.createjs = this.createjs || {};
36 |
37 | (function () {
38 | "use strict";
39 |
40 | /**
41 | * Loader provides a mechanism to preload Web Audio content via PreloadJS or internally. Instances are returned to
42 | * the preloader, and the load method is called when the asset needs to be requested.
43 | *
44 | * @class WebAudioLoader
45 | * @param {String} loadItem The item to be loaded
46 | * @extends XHRRequest
47 | * @protected
48 | */
49 | function Loader(loadItem) {
50 | this.AbstractLoader_constructor(loadItem, true, createjs.Types.SOUND);
51 |
52 | };
53 | var p = createjs.extend(Loader, createjs.AbstractLoader);
54 |
55 | /**
56 | * web audio context required for decoding audio
57 | * @property context
58 | * @type {AudioContext}
59 | * @static
60 | */
61 | Loader.context = null;
62 |
63 |
64 | // public methods
65 | p.toString = function () {
66 | return "[WebAudioLoader]";
67 | };
68 |
69 |
70 | // private methods
71 | p._createRequest = function() {
72 | this._request = new createjs.XHRRequest(this._item, false);
73 | this._request.setResponseType("arraybuffer");
74 | };
75 |
76 | p._sendComplete = function (event) {
77 | // OJR we leave this wrapped in Loader because we need to reference src and the handler only receives a single argument, the decodedAudio
78 | Loader.context.decodeAudioData(this._rawResult,
79 | createjs.proxy(this._handleAudioDecoded, this),
80 | createjs.proxy(this._sendError, this));
81 | };
82 |
83 |
84 | /**
85 | * The audio has been decoded.
86 | * @method handleAudioDecoded
87 | * @param decoded
88 | * @protected
89 | */
90 | p._handleAudioDecoded = function (decodedAudio) {
91 | this._result = decodedAudio;
92 | this.AbstractLoader__sendComplete();
93 | };
94 |
95 | createjs.WebAudioLoader = createjs.promote(Loader, "AbstractLoader");
96 | }());
97 |
--------------------------------------------------------------------------------
/src/createjs/utils/BrowserDetect.js:
--------------------------------------------------------------------------------
1 | /*
2 | * BrowserDetect
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | * Copyright (c) 2010 gskinner.com, inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without
10 | * restriction, including without limitation the rights to use,
11 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the
13 | * Software is furnished to do so, subject to the following
14 | * conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be
17 | * included in all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 | * OTHER DEALINGS IN THE SOFTWARE.
27 | */
28 |
29 | /**
30 | * @module CreateJS
31 | */
32 |
33 | // namespace:
34 | this.createjs = this.createjs||{};
35 |
36 | /**
37 | * @class Utility Methods
38 | */
39 | (function() {
40 | "use strict";
41 |
42 | /**
43 | * An object that determines the current browser, version, operating system, and other environment
44 | * variables via user agent string.
45 | *
46 | * Used for audio because feature detection is unable to detect the many limitations of mobile devices.
47 | *
48 | *
Example
49 | *
50 | * if (createjs.BrowserDetect.isIOS) { // do stuff }
51 | *
52 | * @property BrowserDetect
53 | * @type {Object}
54 | * @param {Boolean} isFirefox True if our browser is Firefox.
55 | * @param {Boolean} isOpera True if our browser is opera.
56 | * @param {Boolean} isChrome True if our browser is Chrome. Note that Chrome for Android returns true, but is a
57 | * completely different browser with different abilities.
58 | * @param {Boolean} isIOS True if our browser is safari for iOS devices (iPad, iPhone, and iPod).
59 | * @param {Boolean} isAndroid True if our browser is Android.
60 | * @param {Boolean} isBlackberry True if our browser is Blackberry.
61 | * @constructor
62 | * @static
63 | */
64 | function BrowserDetect() {
65 | throw "BrowserDetect cannot be instantiated";
66 | };
67 |
68 | var agent = BrowserDetect.agent = window.navigator.userAgent;
69 | BrowserDetect.isWindowPhone = (agent.indexOf("IEMobile") > -1) || (agent.indexOf("Windows Phone") > -1);
70 | BrowserDetect.isFirefox = (agent.indexOf("Firefox") > -1);
71 | BrowserDetect.isOpera = (window.opera != null);
72 | BrowserDetect.isChrome = (agent.indexOf("Chrome") > -1); // NOTE that Chrome on Android returns true but is a completely different browser with different abilities
73 | BrowserDetect.isIOS = (agent.indexOf("iPod") > -1 || agent.indexOf("iPhone") > -1 || agent.indexOf("iPad") > -1) && !BrowserDetect.isWindowPhone;
74 | BrowserDetect.isAndroid = (agent.indexOf("Android") > -1) && !BrowserDetect.isWindowPhone;
75 | BrowserDetect.isBlackberry = (agent.indexOf("Blackberry") > -1);
76 |
77 | createjs.BrowserDetect = BrowserDetect;
78 |
79 | }());
80 |
--------------------------------------------------------------------------------
/tutorials/_shared/SyntaxHighlighter/shThemeDefault.css:
--------------------------------------------------------------------------------
1 | /**
2 | * SyntaxHighlighter
3 | * http://alexgorbatchev.com/SyntaxHighlighter
4 | *
5 | * SyntaxHighlighter is donationware. If you are using it, please donate.
6 | * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
7 | *
8 | * @version
9 | * 3.0.83 (July 02 2010)
10 | *
11 | * @copyright
12 | * Copyright (C) 2004-2010 Alex Gorbatchev.
13 | *
14 | * @license
15 | * Dual licensed under the MIT and GPL licenses.
16 | */
17 | .syntaxhighlighter {
18 | background-color: white !important;
19 | }
20 | .syntaxhighlighter .line.alt1 {
21 | background-color: white !important;
22 | }
23 | .syntaxhighlighter .line.alt2 {
24 | background-color: white !important;
25 | }
26 | .syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 {
27 | background-color: #e0e0e0 !important;
28 | }
29 | .syntaxhighlighter .line.highlighted.number {
30 | color: black !important;
31 | }
32 | .syntaxhighlighter table caption {
33 | color: black !important;
34 | }
35 | .syntaxhighlighter .gutter {
36 | color: #afafaf !important;
37 | }
38 | .syntaxhighlighter .gutter .line {
39 | border-right: 3px solid #6ce26c !important;
40 | }
41 | .syntaxhighlighter .gutter .line.highlighted {
42 | background-color: #6ce26c !important;
43 | color: white !important;
44 | }
45 | .syntaxhighlighter.printing .line .content {
46 | border: none !important;
47 | }
48 | .syntaxhighlighter.collapsed {
49 | overflow: visible !important;
50 | }
51 | .syntaxhighlighter.collapsed .toolbar {
52 | color: blue !important;
53 | background: white !important;
54 | border: 1px solid #6ce26c !important;
55 | }
56 | .syntaxhighlighter.collapsed .toolbar a {
57 | color: blue !important;
58 | }
59 | .syntaxhighlighter.collapsed .toolbar a:hover {
60 | color: red !important;
61 | }
62 | .syntaxhighlighter .toolbar {
63 | color: white !important;
64 | background: #6ce26c !important;
65 | border: none !important;
66 | }
67 | .syntaxhighlighter .toolbar a {
68 | color: white !important;
69 | }
70 | .syntaxhighlighter .toolbar a:hover {
71 | color: black !important;
72 | }
73 | .syntaxhighlighter .plain, .syntaxhighlighter .plain a {
74 | color: black !important;
75 | }
76 | .syntaxhighlighter .comments, .syntaxhighlighter .comments a {
77 | color: #008200 !important;
78 | }
79 | .syntaxhighlighter .string, .syntaxhighlighter .string a {
80 | color: blue !important;
81 | }
82 | .syntaxhighlighter .keyword {
83 | color: #006699 !important;
84 | }
85 | .syntaxhighlighter .preprocessor {
86 | color: gray !important;
87 | }
88 | .syntaxhighlighter .variable {
89 | color: #aa7700 !important;
90 | }
91 | .syntaxhighlighter .value {
92 | color: #009900 !important;
93 | }
94 | .syntaxhighlighter .functions {
95 | color: #ff1493 !important;
96 | }
97 | .syntaxhighlighter .constants {
98 | color: #0066cc !important;
99 | }
100 | .syntaxhighlighter .script {
101 | font-weight: bold !important;
102 | color: #006699 !important;
103 | background-color: none !important;
104 | }
105 | .syntaxhighlighter .color1, .syntaxhighlighter .color1 a {
106 | color: gray !important;
107 | }
108 | .syntaxhighlighter .color2, .syntaxhighlighter .color2 a {
109 | color: #ff1493 !important;
110 | }
111 | .syntaxhighlighter .color3, .syntaxhighlighter .color3 a {
112 | color: red !important;
113 | }
114 |
115 | .syntaxhighlighter .keyword {
116 | font-weight: bold !important;
117 | }
118 |
--------------------------------------------------------------------------------
/src/soundjs/data/AudioSprite.js:
--------------------------------------------------------------------------------
1 | // NOTE this is "Class" is purely to document audioSprite Setup and usage.
2 | /**
3 | * @module SoundJS
4 | */
5 |
6 | /**
7 | * Note: AudioSprite is not a class, but its usage is easily lost in the documentation, so it has been called
8 | * out here for quick reference.
9 | *
10 | * Audio sprites are much like CSS sprites or image sprite sheets: multiple audio assets grouped into a single file.
11 | * Audio sprites work around limitations in certain browsers, where only a single sound can be loaded and played at a
12 | * time. We recommend at least 300ms of silence between audio clips to deal with HTML audio tag inaccuracy, and to prevent
13 | * accidentally playing bits of the neighbouring clips.
14 | *
15 | * Benefits of Audio Sprites:
16 | *
17 | *
More robust support for older browsers and devices that only allow a single audio instance, such as iOS 5.
18 | *
They provide a work around for the Internet Explorer 9 audio tag limit, which restricts how many different
19 | * sounds that could be loaded at once.
20 | *
Faster loading by only requiring a single network request for several sounds, especially on mobile devices
21 | * where the network round trip for each file can add significant latency.
22 | *
23 | *
24 | * Drawbacks of Audio Sprites
25 | *
26 | *
No guarantee of smooth looping when using HTML or Flash audio. If you have a track that needs to loop
27 | * smoothly and you are supporting non-web audio browsers, do not use audio sprites for that sound if you can avoid
28 | * it.
29 | *
No guarantee that HTML audio will play back immediately, especially the first time. In some browsers
30 | * (Chrome!), HTML audio will only load enough to play through at the current download speed – so we rely on the
31 | * `canplaythrough` event to determine if the audio is loaded. Since audio sprites must jump ahead to play specific
32 | * sounds, the audio may not yet have downloaded fully.
33 | *
Audio sprites share the same core source, so if you have a sprite with 5 sounds and are limited to 2
34 | * concurrently playing instances, you can only play 2 of the sounds at the same time.
35 | *
36 | *
37 | *
Example
38 | *
39 | * createjs.Sound.initializeDefaultPlugins();
40 | * var assetsPath = "./assets/";
41 | * var sounds = [{
42 | * src:"MyAudioSprite.ogg", data: {
43 | * audioSprite: [
44 | * {id:"sound1", startTime:0, duration:500},
45 | * {id:"sound2", startTime:1000, duration:400},
46 | * {id:"sound3", startTime:1700, duration: 1000}
47 | * ]}
48 | * }
49 | * ];
50 | * createjs.Sound.alternateExtensions = ["mp3"];
51 | * createjs.Sound.on("fileload", loadSound);
52 | * createjs.Sound.registerSounds(sounds, assetsPath);
53 | * // after load is complete
54 | * createjs.Sound.play("sound2");
55 | *
56 | * You can also create audio sprites on the fly by setting the startTime and duration when creating an new AbstractSoundInstance.
57 | *
58 | * createjs.Sound.play("MyAudioSprite", {startTime: 1000, duration: 400});
59 | *
60 | * The excellent CreateJS community has created a tool to create audio sprites, available at
61 | * https://github.com/tonistiigi/audiosprite,
62 | * as well as a jsfiddle to convert the output
63 | * to SoundJS format.
64 | *
65 | * @class AudioSprite
66 | * @since 0.6.0
67 | */
68 |
--------------------------------------------------------------------------------
/src/createjs/utils/promote.js:
--------------------------------------------------------------------------------
1 | /*
2 | * promote
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | * Copyright (c) 2010 gskinner.com, inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without
10 | * restriction, including without limitation the rights to use,
11 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the
13 | * Software is furnished to do so, subject to the following
14 | * conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be
17 | * included in all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 | * OTHER DEALINGS IN THE SOFTWARE.
27 | */
28 |
29 | /**
30 | * @module CreateJS
31 | */
32 |
33 | // namespace:
34 | this.createjs = this.createjs||{};
35 |
36 | /**
37 | * @class Utility Methods
38 | */
39 |
40 | /**
41 | * Promotes any methods on the super class that were overridden, by creating an alias in the format `prefix_methodName`.
42 | * It is recommended to use the super class's name as the prefix.
43 | * An alias to the super class's constructor is always added in the format `prefix_constructor`.
44 | * This allows the subclass to call super class methods without using `function.call`, providing better performance.
45 | *
46 | * For example, if `MySubClass` extends `MySuperClass`, and both define a `draw` method, then calling `promote(MySubClass, "MySuperClass")`
47 | * would add a `MySuperClass_constructor` method to MySubClass and promote the `draw` method on `MySuperClass` to the
48 | * prototype of `MySubClass` as `MySuperClass_draw`.
49 | *
50 | * This should be called after the class's prototype is fully defined.
51 | *
52 | * function ClassA(name) {
53 | * this.name = name;
54 | * }
55 | * ClassA.prototype.greet = function() {
56 | * return "Hello "+this.name;
57 | * }
58 | *
59 | * function ClassB(name, punctuation) {
60 | * this.ClassA_constructor(name);
61 | * this.punctuation = punctuation;
62 | * }
63 | * createjs.extend(ClassB, ClassA);
64 | * ClassB.prototype.greet = function() {
65 | * return this.ClassA_greet()+this.punctuation;
66 | * }
67 | * createjs.promote(ClassB, "ClassA");
68 | *
69 | * var foo = new ClassB("World", "!?!");
70 | * console.log(foo.greet()); // Hello World!?!
71 | *
72 | * @method promote
73 | * @param {Function} subclass The class to promote super class methods on.
74 | * @param {String} prefix The prefix to add to the promoted method names. Usually the name of the superclass.
75 | * @return {Function} Returns the subclass.
76 | */
77 | createjs.promote = function(subclass, prefix) {
78 | "use strict";
79 |
80 | var subP = subclass.prototype, supP = (Object.getPrototypeOf&&Object.getPrototypeOf(subP))||subP.__proto__;
81 | if (supP) {
82 | subP[(prefix+="_") + "constructor"] = supP.constructor; // constructor is not always innumerable
83 | for (var n in supP) {
84 | if (subP.hasOwnProperty(n) && (typeof supP[n] == "function")) { subP[prefix + n] = supP[n]; }
85 | }
86 | }
87 | return subclass;
88 | };
89 |
--------------------------------------------------------------------------------
/examples/00_Basics.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SoundJS: Basics
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
Basics
16 |
17 |
This example registers and plays a sound with SoundJS.
18 |
19 |
20 |
21 |
Startup.
22 |
23 |
24 |
25 |
Sorry!
26 |
27 |
SoundJS is not currently supported in your browser.
28 |
29 |
Please log a bug
30 | with the device and browser you are using. Thank you.
31 |
32 |
33 |
34 |
Sorry!
35 |
36 |
Mobile devices require sound to be played inside of user events, which
37 | this demo does not do.
38 |
39 |
Please log a bug
40 | with the OS and browser if you see this on a device that is not mobile.
41 | Thank you.
42 |
43 |
44 |
45 |
47 |
48 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/src/preloadjs/utils/DomUtils.js:
--------------------------------------------------------------------------------
1 | /*
2 | * DomUtils
3 | * Visit http://createjs.com/ for documentation, updates and examples.
4 | *
5 | *
6 | * Copyright (c) 2012 gskinner.com, inc.
7 | *
8 | * Permission is hereby granted, free of charge, to any person
9 | * obtaining a copy of this software and associated documentation
10 | * files (the "Software"), to deal in the Software without
11 | * restriction, including without limitation the rights to use,
12 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the
14 | * Software is furnished to do so, subject to the following
15 | * conditions:
16 | *
17 | * The above copyright notice and this permission notice shall be
18 | * included in all copies or substantial portions of the Software.
19 | *
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | * OTHER DEALINGS IN THE SOFTWARE.
28 | */
29 |
30 | /**
31 | * @module PreloadJS
32 | */
33 |
34 | (function () {
35 |
36 | /**
37 | * A few utilities for interacting with the dom.
38 | * @class DomUtils
39 | */
40 | var s = {
41 | container: null
42 | };
43 |
44 | s.appendToHead = function (el) {
45 | s.getHead().appendChild(el);
46 | }
47 |
48 | s.appendToBody = function (el) {
49 | if (s.container == null) {
50 | s.container = document.createElement("div");
51 | s.container.id = "preloadjs-container";
52 | var style = s.container.style;
53 | style.visibility = "hidden";
54 | style.position = "absolute";
55 | style.width = s.container.style.height = "10px";
56 | style.overflow = "hidden";
57 | style.transform = style.msTransform = style.webkitTransform = style.oTransform = "translate(-10px, -10px)"; //LM: Not working
58 | s.getBody().appendChild(s.container);
59 | }
60 | s.container.appendChild(el);
61 | }
62 |
63 | s.getHead = function () {
64 | return document.head || document.getElementsByTagName("head")[0];
65 | }
66 |
67 | s.getBody = function () {
68 | return document.body || document.getElementsByTagName("body")[0];
69 | }
70 |
71 | s.removeChild = function(el) {
72 | if (el.parent) {
73 | el.parent.removeChild(el);
74 | }
75 | }
76 |
77 | /**
78 | * Check if item is a valid HTMLImageElement
79 | * @method isImageTag
80 | * @param {Object} item
81 | * @returns {Boolean}
82 | * @static
83 | */
84 | s.isImageTag = function(item) {
85 | return item instanceof HTMLImageElement;
86 | };
87 |
88 | /**
89 | * Check if item is a valid HTMLAudioElement
90 | * @method isAudioTag
91 | * @param {Object} item
92 | * @returns {Boolean}
93 | * @static
94 | */
95 | s.isAudioTag = function(item) {
96 | if (window.HTMLAudioElement) {
97 | return item instanceof HTMLAudioElement;
98 | } else {
99 | return false;
100 | }
101 | };
102 |
103 | /**
104 | * Check if item is a valid HTMLVideoElement
105 | * @method isVideoTag
106 | * @param {Object} item
107 | * @returns {Boolean}
108 | * @static
109 | */
110 | s.isVideoTag = function(item) {
111 | if (window.HTMLVideoElement) {
112 | return item instanceof HTMLVideoElement;
113 | } else {
114 | return false;
115 | }
116 | };
117 |
118 | createjs.DomUtils = s;
119 |
120 | }());
121 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SoundJS
2 |
3 | SoundJS is a library to make working with audio on the web easier. It provides a consistent API for playing audio in
4 | different browsers, including using a target plugin model to provide an easy way to provide additional audio plugins
5 | like a Flash fallback (included, but must be used separately from the combined/minified version).
6 |
7 | A mechanism has been provided for easily tying in audio preloading to [PreloadJS](http://createjs.com/preloadjs/).
8 |
9 |
10 | ## Example
11 |
12 | ```javascript
13 | createjs.Sound.on("fileload", handleLoadComplete);
14 | createjs.Sound.alternateExtensions = ["mp3"];
15 | createjs.Sound.registerSound({src:"path/to/sound.ogg", id:"sound"});
16 | function handleLoadComplete(event) {
17 | createjs.Sound.play("sound");
18 | }
19 | ```
20 |
21 | ## License
22 | Built by gskinner.com, and released for free under the MIT license, which means you can use it for almost any purpose
23 | (including commercial projects). We appreciate credit where possible, but it is not a requirement.
24 |
25 |
26 | ## Support and Resources
27 | * Find examples and more information at the [SoundJS web site](http://soundjs.com/)
28 | * Read the [documentation](http://createjs.com/docs/soundjs/)
29 | * Discuss, share projects, and interact with other users on [reddit](http://www.reddit.com/r/createjs/).
30 | * Ask technical questions on [Stack Overflow](http://stackoverflow.com/questions/tagged/soundjs).
31 | * File verified bugs or formal feature requests using Issues on [GitHub](https://github.com/CreateJS/SoundJS/issues).
32 | * Have a look at the included [examples](https://github.com/CreateJS/SoundJS/tree/master/examples) and
33 | [API documentation](http://createjs.com/docs/soundjs/) for more in-depth information.
34 |
35 |
36 | ## Classes
37 |
38 | ### [Sound](http://createjs.com/Docs/SoundJS/classes/Sound.html)
39 | The core API for playing sounds. Call createjs.Sound.play(sound, ...options), and a sound instance is created that can be
40 | used to control the audio, and dispatches events when it is complete, loops, or is interrupted.
41 |
42 | ### [SoundInstance](http://createjs.com/Docs/SoundJS/classes/AbstractSoundInstance.html)
43 | A controllable sound object that wraps the actual plugin implementation, providing a consistent API for audio playback,
44 | no matter what happens in the background. Sound instances can be paused, muted, and stopped; and the volume, pan (where
45 | available), and position changed using the simple API.
46 |
47 | ### [WebAudioPlugin](http://createjs.com/Docs/SoundJS/classes/WebAudioPlugin.html)
48 | The default, built-in plugin, which uses Web Audio APIs to playback sounds. Note that WebAudio will fail to load when
49 | run locally, and the HTML audio plugin will be used instead.
50 |
51 | ### [HTMLAudioPlugin](http://createjs.com/Docs/SoundJS/classes/HTMLAudioPlugin.html)
52 | The fallback built-in plugin, which manages audio playback via the HTML5