Skip to content
Browse files

fix and add-on for VideoLoader & SWFLoader

- fix in VideoLoader to not hear the sound when it starts loading
- add the onInit signal in SWFLoader so the swf can be controlled when Event.INIT is fired
  • Loading branch information...
1 parent 314470b commit 2cc8888fcb988fac921d330d4126b96f803bad23 @losrebellos losrebellos committed Feb 6, 2012
Showing with 47 additions and 1 deletion.
  1. +44 −0 src/org/assetloader/loaders/SWFLoader.as
  2. +3 −1 src/org/assetloader/loaders/VideoLoader.as
View
44 src/org/assetloader/loaders/SWFLoader.as
@@ -5,6 +5,8 @@ package org.assetloader.loaders
import flash.display.DisplayObject;
import flash.display.Sprite;
+ import flash.events.Event;
+ import flash.events.IEventDispatcher;
import flash.net.URLRequest;
/**
@@ -29,8 +31,50 @@ package org.assetloader.loaders
override protected function initSignals() : void
{
super.initSignals();
+ _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);
+ }
+ }
+
+ /**
+ * @private
+ */
+ override protected function removeListeners(dispatcher : IEventDispatcher) : void
+ {
+ super.removeListeners(dispatcher);
+
+ if(dispatcher)
+ {
+ dispatcher.removeEventListener(Event.INIT, init_handler);
+ }
+ }
/**
* @inheritDoc
View
4 src/org/assetloader/loaders/VideoLoader.as
@@ -112,6 +112,7 @@ package org.assetloader.loaders
try
{
_netStream.play(request.url, getParam(Param.CHECK_POLICY_FILE) || true);
+ _netStream.pause();
}
catch(error : SecurityError)
{
@@ -293,7 +294,8 @@ package org.assetloader.loaders
*
* <p>HANDLER ARGUMENTS: (signal:<strong>LoaderSignal</strong>, netStream:<strong>NetStream</strong>)</p>
* <ul>
- * <li><strong>signal</strong> - The signal that dispatched.</li>
+ * <li><strong>signal</strong> - The signal that dispatched.</li>
+ * <li><strong>netStream</strong> - The NetStream instance.</li>
* </ul>
*
* @see org.assetloader.signals.LoaderSignal

0 comments on commit 2cc8888

Please sign in to comment.
Something went wrong with that request. Please try again.