Permalink
Browse files

Build: 2.5.1

Small fixes VideoLoader and SoundLoader.
SoundLoader#onInit signal added.
Removed listeners from not being removed once loading completes. Listeners
will only be removed onError and once the Loader is destroyed.
Added unit tests.

Updated to FlexUnit 4.1 .
Removed junit report due to a JDK security bug.
  • Loading branch information...
1 parent 05dbb0b commit f105a69d0ecdd3742de7865e3960525d0308c9c3 Matan Uberstein committed Mar 12, 2012
Binary file not shown.
View
@@ -2,7 +2,7 @@
project.name = AssetLoader
#Version number for current AssetLoader and AS3Singals releases
-assetloader.ver.num = v2.5.0
+assetloader.ver.num = v2.5.1
as3.signals.version = v0.8
project.name.versioned = ${project.name}-${assetloader.ver.num}
as3.signals.name.versioned = as3-signals-${as3.signals.version}
View
@@ -9,7 +9,7 @@
<!-- identify properties file -->
<property file="build.properties" />
<!-- Set up FlexUnit Ant tasks -->
- <taskdef resource="flexUnitTasks.tasks" classpath="${lib.loc}/flexunit/flexUnitTasks.jar" />
+ <taskdef resource="flexUnitTasks.tasks" classpath="${lib.loc}/flexunit/flexUnitTasks-4.1.0-8.jar" />
<target name="usage">
<echo message="" />
@@ -93,12 +93,12 @@
<echo>[test] Running SWF ${build.loc}/testing/FlexTestSuite.swf</echo>
<flexunit swf="${bin.loc}/testing/FlexTestSuite.swf" toDir="${report.loc}" haltonfailure="true" verbose="true" localTrusted="true" />
<!-- Generate readable JUnit-style reports -->
- <junitreport todir="${report.loc}">
+ <!-- <junitreport todir="${report.loc}">
<fileset dir="${report.loc}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.loc}/html" />
- </junitreport>
+ </junitreport> -->
<echo>[test] Finished running Unit Tests</echo>
</target>
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.
Binary file not shown.
Binary file not shown.
@@ -152,8 +152,6 @@ package org.assetloader.loaders
_stats.done();
_onProgress.dispatch(this, _stats.latency, _stats.speed, _stats.averageSpeed, _stats.progress, _stats.bytesLoaded, _stats.bytesTotal);
- removeListeners(_eventDispatcher);
-
_inProgress = false;
_failed = false;
_loaded = true;
@@ -6,6 +6,7 @@ package org.assetloader.loaders
import flash.display.DisplayObject;
import flash.display.Loader;
+ import flash.display.LoaderInfo;
import flash.events.ErrorEvent;
import flash.events.Event;
import flash.events.IEventDispatcher;
@@ -48,10 +49,6 @@ package org.assetloader.loaders
_loader = new Loader();
return _loader.contentLoaderInfo;
}
- public function get contentLoaderInfo():LoaderInfo
- {
- return _loader ? _loader.contentLoaderInfo : null;
- }
/**
* @private
@@ -126,5 +123,15 @@ package org.assetloader.loaders
{
return _displayObject;
}
+
+ /**
+ * Gets the current content's LoaderInfo.
+ *
+ * @return LoaderInfo
+ */
+ public function get contentLoaderInfo() : LoaderInfo
+ {
+ return _loader ? _loader.contentLoaderInfo : null;
+ }
}
}
@@ -19,6 +19,11 @@ package org.assetloader.loaders
*/
protected var _swf : Sprite;
+ /**
+ * @private
+ */
+ protected var _onInit : LoaderSignal;
+
public function SWFLoader(request : URLRequest, id : String = null)
{
super(request, id);
@@ -34,33 +39,22 @@ package org.assetloader.loaders
_onInit = new LoaderSignal();
_onComplete = new LoaderSignal(Sprite);
}
-
- /**
- * onInit
- */
- protected var _onInit : LoaderSignal;
- public function get onInit() : LoaderSignal
- {
- return _onInit;
- }
+
protected function init_handler(event : Event) : void
{
_data = _displayObject = _loader.content;
-
+
_onInit.dispatch(this, _data);
}
-
+
/**
* @private
*/
override protected function addListeners(dispatcher : IEventDispatcher) : void
{
super.addListeners(dispatcher);
-
if(dispatcher)
- {
dispatcher.addEventListener(Event.INIT, init_handler);
- }
}
/**
@@ -69,11 +63,8 @@ package org.assetloader.loaders
override protected function removeListeners(dispatcher : IEventDispatcher) : void
{
super.removeListeners(dispatcher);
-
if(dispatcher)
- {
dispatcher.removeEventListener(Event.INIT, init_handler);
- }
}
/**
@@ -113,5 +104,20 @@ package org.assetloader.loaders
{
return _swf;
}
+
+ /**
+ * Dispatched when the properties and methods of a loaded SWF file are accessible and ready for use.
+ *
+ * <p>HANDLER ARGUMENTS: (signal:<strong>LoaderSignal</strong>)</p>
+ * <ul>
+ * <li><strong>signal</strong> - The signal that dispatched.</li>
+ * </ul>
+ *
+ * @see org.assetloader.signals.LoaderSignal
+ */
+ public function get onInit() : LoaderSignal
+ {
+ return _onInit;
+ }
}
}
@@ -35,6 +35,7 @@ package org.assetloader.loaders
* @private
*/
protected var _readyTimer : Timer;
+
/**
* @private
*/
@@ -63,12 +64,13 @@ package org.assetloader.loaders
{
_sound = _data = new Sound();
- if(!_readyTimer) {
+ if(!_readyTimer)
+ {
_readyTimer = new Timer(50);
_readyTimer.addEventListener(TimerEvent.TIMER, readyTimer_handler);
- } else {
- _readyTimer.reset();
}
+ else
+ _readyTimer.reset();
return _sound;
}
@@ -190,7 +190,7 @@ package org.assetloader.loaders
*/
protected function netStatus_handler(event : NetStatusEvent) : void
{
- var code : String = event.info["code"];
+ var code : String = event.info.code;
var errorEvent : ErrorEvent;
@@ -237,10 +237,8 @@ package org.assetloader.loaders
protected function metaData_handler(data : Object) : void
{
if(_metaData)
- {
- return ;
- }
-
+ return;
+
_metaData = {};
for(var key : String in data)
@@ -1,6 +1,12 @@
package org.assetloader.loaders
{
import org.assetloader.base.AssetType;
+ import org.assetloader.signals.LoaderSignal;
+ import org.flexunit.asserts.assertEquals;
+ import org.flexunit.asserts.assertNotNull;
+ import org.flexunit.asserts.assertTrue;
+ import org.osflash.signals.utils.SignalAsyncEvent;
+ import org.osflash.signals.utils.handleSignal;
import flash.display.Sprite;
import flash.net.URLRequest;
@@ -21,5 +27,36 @@ package org.assetloader.loaders
_loader = new SWFLoader(new URLRequest(_path), _id);
}
+
+ // NON - STANDARD - LOADER - TESTS -------------------------------------------------------------------------------------------//
+ [Test]
+ override public function signalsReadyOnConstruction() : void
+ {
+ super.signalsReadyOnConstruction();
+ assertNotNull(_loaderName + "#onInit should NOT be null after construction", SWFLoader(_loader).onInit);
+ }
+
+ [Test (async)]
+ public function onInitSignal() : void
+ {
+ // Make sure that the mp3 loaded has ID3 data, otherwise this test will fail.
+ handleSignal(this, SWFLoader(_loader).onInit, onInit_handler);
+ _loader.start();
+ }
+
+ protected function onInit_handler(event : SignalAsyncEvent, data : Object) : void
+ {
+ var values : Array = event.args;
+ assertTrue("Argument 1 should be LoaderSignal", (values[0] is LoaderSignal));
+
+ var signal : LoaderSignal = values[0];
+ assertNotNull("LoaderSignal#loader should NOT be null", signal.loader);
+ }
+
+ override protected function assertPostDestroy() : void
+ {
+ super.assertPostDestroy();
+ assertEquals(_loaderName + "#onInit#numListeners should be equal to 0", SWFLoader(_loader).onInit.numListeners, 0);
+ }
}
}
@@ -78,6 +78,7 @@ package org.assetloader.loaders
{
super.assertPostDestroy();
assertEquals(_loaderName + "#onId3#numListeners should be equal to 0", SoundLoader(_loader).onId3.numListeners, 0);
+ assertEquals(_loaderName + "#onReady#numListeners should be equal to 0", SoundLoader(_loader).onReady.numListeners, 0);
}
// SOUND LOADER DOES NOT DISPATCH HTTP STATUS SIGNAL

0 comments on commit f105a69

Please sign in to comment.