[Laszlo-checkins] r13419 - in openlaszlo/trunk/WEB-INF/lps/lfc/kernel: swf swf9
bargull@openlaszlo.org
bargull at openlaszlo.org
Sun Mar 22 14:42:56 PDT 2009
Author: bargull
Date: 2009-03-22 14:42:50 -0700 (Sun, 22 Mar 2009)
New Revision: 13419
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMediaLoader.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMouseKernel.as
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSoundMC.as
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
Log:
Change 20090321-bargull-9i1 by bargull at dell--p4--2-53 on 2009-03-21 14:43:14
in /home/Admin/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: properly unload audio resources
New Features:
Bugs Fixed: LPP-7947 (SWF8: unload() doesn't unload audio)
Technical Reviewer: max
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
LzSprite (swf9):
- set "soundLoading" flag before starting the load operation, don't wait for the open-event
- wrap close() in try..catch (you can't be too cautious in AS3)
LzMediaLoader:
- always convert filetype to lower case (already done in the swf9 kernel)
- emit a debug warning when a erroneous resource was attached (we do this in dhtml/swf9, so no reason to fail silently in swf8)
LzMouseKernel:
- emit a debug warning when a bad cursor-resource was attached
LzSprite (swf8):
- emit a debug warning when a bad resource was attached
- removed (unnecessary) checks for __LZbgRef (everywhere else no measures were taken to avoid null-pointer dereferencing on __LZbgRef..)
- expanded comment on getMCRef()
LzLoader:
- added handling for SoundMC in unload()
LzSoundMC:
- emit warning when user attempts to use POST for audio loading
- added unloadMovie() (there was already unload(), but as SoundMC is a 'pseudo'-movieclip, unloadMovie() should be used...)
- and try to cancel streaming audio in unloadMovie()
Tests:
testcase at bugreport
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs 2009-03-22 20:54:57 UTC (rev 13418)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs 2009-03-22 21:42:50 UTC (rev 13419)
@@ -49,6 +49,8 @@
// clip from anywhere will magically delete any properties that
// reference it (i.e., all movieclip references are weak,
// apparently).
+ // [2009-03-21 anba] Found a page with more information about
+ // movieclip references: http://moock.org/asdg/technotes/movieclipDatatype/
this.mc.removeMovieClip();
super.destroy();
}
@@ -329,6 +331,11 @@
loadobj.lmc.removeMovieClip( );
delete loadobj.lmc;
}
+ } else if (loadobj instanceof SoundMC) {
+ if (loadobj.lmc) {
+ loadobj.lmc.unloadMovie();
+ delete loadobj.lmc;
+ }
} else {
// the request object is a SOLO XML node
// Is there ANY way to abort the LoadVars.sendAndLoad() which may be still open?
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMediaLoader.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMediaLoader.lzs 2009-03-22 20:54:57 UTC (rev 13418)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMediaLoader.lzs 2009-03-22 21:42:50 UTC (rev 13419)
@@ -77,7 +77,7 @@
this.unload( this.mc );
if (this.isaudio != true && this._oldmc != null) {
// restore regular loader if audio was used before.
- this.mc.unload();
+ this.mc.unload(); // this.mc instanceof SoundMC
var m = this._oldmc;
this._oldmc = null;
this.mc = m;
@@ -109,7 +109,12 @@
mc = m;
}
if (resc) {
- mc.attachMovie( resc, "lmc", this.LOADERDEPTH );
+ var lmc = mc.attachMovie( resc, "lmc", this.LOADERDEPTH );
+ if ($debug) {
+ if (typeof(lmc) != 'movieclip') {
+ Debug.warn('Could not find resource', resc);
+ }
+ }
if (this.mc.loading == true) {
if ($debug) {
Debug.error('already loading', this.mc);
@@ -171,7 +176,7 @@
suffix = req.substring(si + 1).toLowerCase();
}
} else {
- suffix = filetype;
+ suffix = filetype.toLowerCase();
}
this.isjpeg = (suffix == 'jpeg' || suffix == 'jpg');
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMouseKernel.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMouseKernel.as 2009-03-22 20:54:57 UTC (rev 13418)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMouseKernel.as 2009-03-22 21:42:50 UTC (rev 13419)
@@ -43,7 +43,14 @@
*/
,setCursorGlobal: function ( what ){
if ( LzMouseKernel.__amLocked ) { return; }
- _root.attachMovie (what , "cCursor" , 5555 );
+ var cr = _root.attachMovie (what , "cCursor" , 5555 );
+ if ($debug) {
+ if (typeof(cr) != 'movieclip') {
+ Debug.warn('Could not find cursor-resource', what);
+ }
+ }
+ // @devnote Intentionally not used local variable cr below:
+ // if attachMovie failed, the previous movieclip remains intact
_root.cCursor._x = _root._xmouse;
_root.cCursor._y = _root._ymouse;
_root.cCursor.startDrag( true );
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSoundMC.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSoundMC.as 2009-03-22 20:54:57 UTC (rev 13418)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSoundMC.as 2009-03-22 21:42:50 UTC (rev 13419)
@@ -10,7 +10,7 @@
/**
* Wraps the streaming MP3 loader in a movieclip-like API.
- * Used for proxyless mp3 audio loading.
+ * Used for mp3 audio loading.
*
* @access private
*/
@@ -87,15 +87,35 @@
/**
* @access private
*/
-SoundMC.prototype.loadMovie = function (reqstr) {
+SoundMC.prototype.loadMovie = function (url, method) {
+ if ($debug) {
+ if (method == "POST") {
+ Debug.warn("You cannot use POST for audio loading ('%s')", url);
+ }
+ }
this.init();
- this._sound.loadSound(reqstr, true);
+ this._sound.loadSound(url, true);
this.loadstate = 1;
}
/**
* @access private
*/
+SoundMC.prototype.unloadMovie = function () {
+ this._sound.stop();
+ delete this._sound.onLoad;
+ // try to cancel streaming, don't use loadSound(null) although it's often
+ // suggested for this purpose, it'll start a download from "%APP_URL%/null".
+ // using the empty string stops the current download and won't create a new
+ // one (at least according to firebug's network control).
+ this._sound.loadSound("");
+ delete this._sound;
+ this.loadstate = 0;
+}
+
+/**
+ * @access private
+ */
SoundMC.prototype.getBytesLoaded = function () {
return this._sound.getBytesLoaded();
}
@@ -108,13 +128,10 @@
}
/**
+ * Alias for unloadMovie
* @access private
*/
-SoundMC.prototype.unload = function () {
- this.stop();
- delete this._sound;
- this.loadstate = 0;
-}
+SoundMC.prototype.unload = SoundMC.prototype.unloadMovie;
/**
* @access private
@@ -164,8 +181,8 @@
* @access private
*/
SoundMC.prototype.init = function (mc) {
- this._sound.stop();
- delete this._sound;
+ // clear previous _sound
+ this.unloadMovie();
if (mc != null) {
this._sound = new Sound(mc);
} else {
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as 2009-03-22 20:54:57 UTC (rev 13418)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as 2009-03-22 21:42:50 UTC (rev 13419)
@@ -421,6 +421,11 @@
this.FOREGROUND_DEPTH_OFFSET;
var newmc = this.__LZmovieClipRef.attachMovie( resourceName, instName, depth);
+ if ($debug) {
+ if (typeof(newmc) != 'movieclip') {
+ Debug.warn('Could not find resource', resourceName);
+ }
+ }
// Install right-click context menu if there is one
if (childsprite.__contextmenu) newmc.menu = childsprite.__contextmenu.kernel.__LZcontextMenu();
@@ -609,14 +614,13 @@
this.__LZmaskClip._xscale = v;
}
}
-
+
this.hassetwidth = true;
-
+
if (this.setButtonSize)
this.setButtonSize( "width", v );
- if (typeof(this.__LZbgRef._xscale) != 'undefined')
- this.__LZbgRef._xscale = v;
+ this.__LZbgRef._xscale = v;
}
/**
@@ -662,12 +666,11 @@
}
}
this.hassetheight = true;
-
+
if (this.setButtonSize)
this.setButtonSize( "height", v );
- if (typeof(this.__LZbgRef._yscale) != 'undefined')
- this.__LZbgRef._yscale = v;
+ this.__LZbgRef._yscale = v;
}
LzSprite.prototype.setOpacity = function ( v ){
@@ -678,7 +681,7 @@
this.__LZmovieClipRef._alpha = 100 * v;
// set the bgcolor alpha if not set by the context menu and overridden by the context menu
- if (this.__LZbgRef && this._bgcolorhidden != true)
+ if (this._bgcolorhidden != true)
this.__LZbgRef._alpha = 100 * v;
}
@@ -943,6 +946,16 @@
/**
* Get a reference to the control mc - may be overridden by loader
+ *
+ * Unless LzMakeLoadSprite.transform() has been called, the following
+ * assertion always yields true: sprite.getMCRef() === sprite.__LZmovieClipRef
+ * The overridden definition of getMCRef() in LzMakeLoadSprite will change
+ * this contract, now we need to distinguish four cases:
+ * a) loading image: sprite.getMCRef() === null
+ * b) loaded image: sprite.getMCRef()._parent === sprite.__LZmovieClipRef
+ * c) unloaded image: sprite.getMCRef() === undefined
+ * d) audio: sprite.getMCRef() instanceof SoundMC
+ *
*/
LzSprite.prototype.getMCRef = function () {
if (this.__LZmovieClipRef == null){
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as 2009-03-22 20:54:57 UTC (rev 13418)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as 2009-03-22 21:42:50 UTC (rev 13419)
@@ -25,6 +25,7 @@
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.display.SWFVersion;
+ import flash.errors.IOError;
import flash.events.Event;
import flash.events.ErrorEvent;
import flash.events.IOErrorEvent;
@@ -498,6 +499,7 @@
this.sound.addEventListener(ProgressEvent.PROGRESS, soundLoadHandler);
this.sound.addEventListener(IOErrorEvent.IO_ERROR, soundLoadHandler);
+ this.soundLoading = true;
this.sound.load(new URLRequest(url), LzSprite.soundLoaderContext);
// TODO: add condition on this
@@ -515,7 +517,11 @@
if (this.sound) {
if (this.soundLoading) {
// stop streaming sound
- this.sound.close();
+ try {
+ this.sound.close();
+ } catch (e:IOError) {
+ // ignore for now
+ }
this.soundLoading = false;
}
this.sound = null;
@@ -535,7 +541,7 @@
this.addEventListener(Event.ENTER_FRAME, soundFrameHandler);
this.soundChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
}
-
+
/**
* Stop sound playback and tracking
* @return Number: the current frame when playback was stopped
More information about the Laszlo-checkins
mailing list