Skip to content

Commit

Permalink
build v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Matan committed Nov 16, 2010
1 parent 4b26269 commit cf715b3
Show file tree
Hide file tree
Showing 53 changed files with 2,386 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -3,7 +3,8 @@
/html-template/*
/bin-debug/*
/bin-release/*
/bin/**.cache
/bin/*.cache
/bin/testing/*.cache
docs/*
obj/*

Expand Down
21 changes: 21 additions & 0 deletions LICENSE
@@ -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 added bin/AssetLoader-v2.0.0.swc
Binary file not shown.
Binary file added bin/testing/FlexTestSuite.swf
Binary file not shown.
14 changes: 14 additions & 0 deletions bin/testing/assets/test/testCSS.css
@@ -0,0 +1,14 @@
body
{
background-color:#d0e4fe;
}
h1
{
color:orange;
text-align:center;
}
p
{
font-family:"Times New Roman";
font-size:20px;
}
Binary file added bin/testing/assets/test/testIMAGE.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions bin/testing/assets/test/testJSON.json
@@ -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 added bin/testing/assets/test/testSOUND.mp3
Binary file not shown.
Binary file added bin/testing/assets/test/testSWF.swf
Binary file not shown.
26 changes: 26 additions & 0 deletions bin/testing/assets/test/testTXT.txt
@@ -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 added bin/testing/assets/test/testVIDEO.flv
Binary file not shown.
26 changes: 26 additions & 0 deletions bin/testing/assets/test/testXML.xml
@@ -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 added bin/testing/assets/test/testZIP.zip
Binary file not shown.
Binary file added build/libs/as3-signals-v0.8.swc
Binary file not shown.
Binary file added build/libs/as3corelib-json.swc
Binary file not shown.
26 changes: 26 additions & 0 deletions build/libs/flexunit/License.txt
@@ -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 added build/libs/flexunit/flexUnitTasks.jar
Binary file not shown.
Binary file added build/libs/flexunit/flexunit-4.0.0.swc
Binary file not shown.
Binary file not shown.
Binary file added build/libs/flexunit/flexunit-cilistener-4.0.0.swc
Binary file not shown.
Binary file not shown.
Binary file not shown.
173 changes: 173 additions & 0 deletions src/org/assetloader/base/LoaderFactory.as
@@ -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);
}
}
}
}

0 comments on commit cf715b3

Please sign in to comment.