Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matan
committed
Nov 16, 2010
1 parent
4b26269
commit cf715b3
Showing
53 changed files
with
2,386 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2009, 2010 the original author or authors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
body | ||
{ | ||
background-color:#d0e4fe; | ||
} | ||
h1 | ||
{ | ||
color:orange; | ||
text-align:center; | ||
} | ||
p | ||
{ | ||
font-family:"Times New Roman"; | ||
font-size:20px; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"base":"http://www.matan.co.za/AssetLoader/testAssets/","assets":[{"id":"SAMPLE_GROUP","preventCache":false,"assets":[{"src":"sampleTXT.txt","id":"SAMPLE_TXT"},{"src":"sampleJSON.json","id":"SAMPLE_JSON"},{"src":"sampleXML.xml","id":"SAMPLE_XML"},{"src":"sampleCSS.css","id":"SAMPLE_CSS"},{"src":"sampleZIP.zip","weight":3493,"id":"SAMPLE_BINARY"},{"src":"sampleSOUND.mp3","weight":"213 kb","id":"SAMPLE_SOUND"}],"connections":0},{"assets":[{"src":"sampleIMAGE.jpg","weight":"328.5 kb","id":"SAMPLE_IMAGE"},{"id":"SAMPLE_VIDEO","onDemand":true,"src":"sampleVIDEO.mp4","weight":"10 mb"},{"id":"SAMPLE_SWF","src":"sampleSWF.swf","weight":941410,"priority":1}],"preventCache":true},{"base":"/","id":"SAMPLE_ERROR","src":"fileThatDoesNotExist.php","type":"image","retries":5}],"connections":3} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FlexUnit 4 is under an MIT license. | ||
|
||
Copyright (c) 2007 Digital Primates IT Consulting Group | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
http://flexunit.org/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<loader connections="3" base="test/" > | ||
|
||
<group id="SAMPLE_GROUP_01" connections="1" preventCache="false" > | ||
|
||
<group id="SAMPLE_GROUP_02" connections="2" > | ||
<asset id="SAMPLE_TXT" src="sampleTXT.txt" /> | ||
<asset id="SAMPLE_JSON" src="sampleJSON.json" /> | ||
<asset id="SAMPLE_XML" src="sampleXML.xml" /> | ||
<asset id="SAMPLE_CSS" src="sampleCSS.css" /> | ||
</group> | ||
|
||
<asset id="SAMPLE_BINARY" src="sampleZIP.zip" weight="3493" /> | ||
<asset id="SAMPLE_SOUND" src="sampleSOUND.mp3" weight="213 kb" /> | ||
|
||
</group> | ||
|
||
<assets preventCache="true" > | ||
<asset id="SAMPLE_IMAGE" src="sampleIMAGE.png" weight="5 kb" fillColor="0x0" smoothing="true" transparent="true" /> | ||
<asset id="SAMPLE_VIDEO" src="sampleVIDEO.flv" weight="0.312 mb" onDemand="true" /> | ||
<asset id="SAMPLE_SWF" src="sampleSWF.swf" weight="526" priority="1" /> | ||
</assets> | ||
|
||
<asset id="SAMPLE_ERROR" base="/" src="fileThatDoesNotExist.php" type="image" retries="5" /> | ||
|
||
</loader> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FlexUnit 4 is under an MIT license. | ||
|
||
Copyright (c) 2007 Digital Primates IT Consulting Group | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
http://flexunit.org/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
package org.assetloader.base | ||
{ | ||
import org.assetloader.AssetLoader; | ||
import org.assetloader.core.ILoader; | ||
import org.assetloader.core.IParam; | ||
import org.assetloader.loaders.BinaryLoader; | ||
import org.assetloader.loaders.CSSLoader; | ||
import org.assetloader.loaders.DisplayObjectLoader; | ||
import org.assetloader.loaders.ImageLoader; | ||
import org.assetloader.loaders.JSONLoader; | ||
import org.assetloader.loaders.SWFLoader; | ||
import org.assetloader.loaders.SoundLoader; | ||
import org.assetloader.loaders.TextLoader; | ||
import org.assetloader.loaders.VideoLoader; | ||
import org.assetloader.loaders.XMLLoader; | ||
|
||
import flash.net.URLRequest; | ||
|
||
/** | ||
* @author Matan Uberstein | ||
*/ | ||
public class LoaderFactory | ||
{ | ||
protected var _loader : AbstractLoader; | ||
|
||
public function LoaderFactory() | ||
{ | ||
} | ||
|
||
public function produce(id : String, type : String = "AUTO", request : URLRequest = null, params : Array = null, parent : ILoader = null) : ILoader | ||
{ | ||
if(request) | ||
{ | ||
var urlPattern : RegExp = /((?P<protocol>[a-zA-Z]+: \/\/) (?P<host>[^:\/]*) (:(?P<port>\d+))?)? (?P<path>[^?]*)? ((?P<query>.*))? /x; | ||
var urlMatch : * = urlPattern.exec(request.url); | ||
if(urlMatch) | ||
{ | ||
var path : String = urlMatch.path; | ||
var fileExtension : String = path.slice(path.lastIndexOf(".") + 1); | ||
} | ||
else | ||
throw new AssetLoaderError(AssetLoaderError.INVALID_URL); | ||
|
||
if(type == AssetType.AUTO) | ||
type = getTypeFromExtension(fileExtension); | ||
} | ||
else if(type == AssetType.AUTO) | ||
type = AssetType.GROUP; | ||
|
||
constructLoader(type, id, request, parent); | ||
|
||
if(params) | ||
processParams(params); | ||
|
||
return _loader; | ||
} | ||
|
||
protected function processParams(assetParams : Array) : void | ||
{ | ||
var pL : int = assetParams.length; | ||
for(var i : int = 0;i < pL;i++) | ||
{ | ||
if(assetParams[i] is IParam) | ||
{ | ||
var param : IParam = assetParams[i]; | ||
_loader.setParam(param.id, param.value); | ||
} | ||
else if(assetParams[i] is Array) | ||
processParams(assetParams[i]); | ||
} | ||
} | ||
|
||
protected function getTypeFromExtension(extension : String) : String | ||
{ | ||
extension = extension.toLowerCase(); | ||
|
||
var textExt : Array = ["txt", "js", "html", "htm", "php", "asp", "aspx", "jsp", "cfm"]; | ||
var imageExt : Array = ["jpg", "jpeg", "png", "gif"]; | ||
var videoExt : Array = ["flv", "f4v", "f4p", "mp4", "mov"]; | ||
|
||
if(testExtenstion(textExt, extension)) | ||
return AssetType.TEXT; | ||
|
||
if(extension == "json") | ||
return AssetType.JSON; | ||
|
||
if(extension == "xml") | ||
return AssetType.XML; | ||
|
||
if(extension == "css") | ||
return AssetType.CSS; | ||
|
||
if(extension == "zip") | ||
return AssetType.BINARY; | ||
|
||
if(extension == "swf") | ||
return AssetType.SWF; | ||
|
||
if(testExtenstion(imageExt, extension)) | ||
return AssetType.IMAGE; | ||
|
||
if(extension == "mp3") | ||
return AssetType.SOUND; | ||
|
||
if(testExtenstion(videoExt, extension)) | ||
return AssetType.VIDEO; | ||
|
||
throw new AssetLoaderError(AssetLoaderError.ASSET_AUTO_TYPE_NOT_FOUND); | ||
|
||
return ""; | ||
} | ||
|
||
protected function testExtenstion(extensions : Array, extension : String) : Boolean | ||
{ | ||
if(extensions.indexOf(extension) != -1) | ||
return true; | ||
return false; | ||
} | ||
|
||
protected function constructLoader(type : String, id : String, request : URLRequest, parent : ILoader) : void | ||
{ | ||
switch(type) | ||
{ | ||
case AssetType.TEXT: | ||
_loader = new TextLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.JSON: | ||
_loader = new JSONLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.XML: | ||
_loader = new XMLLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.CSS: | ||
_loader = new CSSLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.BINARY: | ||
_loader = new BinaryLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.DISPLAY_OBJECT: | ||
_loader = new DisplayObjectLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.SWF: | ||
_loader = new SWFLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.IMAGE: | ||
_loader = new ImageLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.SOUND: | ||
_loader = new SoundLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.VIDEO: | ||
_loader = new VideoLoader(id, request, parent); | ||
break; | ||
|
||
case AssetType.GROUP: | ||
_loader = new AssetLoader(id); | ||
break; | ||
|
||
default: | ||
throw new AssetLoaderError(AssetLoaderError.ASSET_TYPE_NOT_RECOGNIZED); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.