[Laszlo-checkins] r10856 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf
bargull@openlaszlo.org
bargull at openlaszlo.org
Wed Sep 3 05:47:05 PDT 2008
Author: bargull
Date: 2008-09-03 05:47:01 -0700 (Wed, 03 Sep 2008)
New Revision: 10856
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
Log:
Change 20080902-bargull-2wD by bargull at dell--p4--2-53 on 2008-09-02 21:31:23
in /home/Admin/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: LzMakeLoadSprite cleanup
New Features:
Bugs Fixed: LPP-5551 (part 1 - cleanup)
Technical Reviewer: max
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
As part of LPP-5551, I like to do some code cleanup.
LzMakeLoadSprite:
- consistent code-formatting
- changed LzMakeLoadSprite from function to object
- removed out commented debug-code
- removed first* properties, instead call "createLoader" directly
- removed override of "doReplaceResource" because it was superfluous as "_newrescname" was never defined
- removed "if (! this.loader)"-check in LzMakeLoadSprite.transform, because it always yield true as there is no "loader"-field defined in LzMakeLoadSprite
- removed "transformerID", no where referenced in the lfc
Tests:
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as 2008-09-03 08:32:47 UTC (rev 10855)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as 2008-09-03 12:47:01 UTC (rev 10856)
@@ -11,130 +11,76 @@
/**
* @access private
*/
-function LzMakeLoadSprite( ){
-
-}
+var LzMakeLoadSprite = {};
-LzMakeLoadSprite.transformerID = 0;
-
-
/**
* Makes the given view able to load a remote resource
*/
-LzMakeLoadSprite.transform = function ( v , src , cache, headers, filetype ){
- //super.transform( v );
-
- for ( var k in this){
- if (typeof v[k] == 'function' && this[k]) {
- // replace old method with _methodname to support super
- //Debug.write('replacing _' + k + ' with ' + k + ' in ' + v);
- v[ '___' + k ] = v[k];
+LzMakeLoadSprite.transform = function (v, src, cache, headers, filetype) {
+ for (var k in this) {
+ if (k != "transform") {
+ if (typeof v[k] == 'function') {
+ // replace old method with _methodname to support super
+ v[ '___' + k ] = v[k];
+ }
v[k] = this[k];
- } else {
- //Debug.write('adding ' + k + ' to ' + v);
- v[k] = this[k];
}
}
-// Debug.trace(v, 'setHeight');
-// Debug.trace(v, 'setWidth');
-// Debug.monitor(v, 'resourcewidth')
-// Debug.monitor(v, 'resourceheight')
-// Debug.monitor(v, '_xscale')
-// Debug.monitor(v, '_yscale')
-
- v.firstsrc = src;
- v.firstcache = cache;
- v.firstheaders = headers;
- v.firstfiletype = filetype;
-
- if ( v.__LZmovieClipRef == null ){
+ if (v.__LZmovieClipRef == null || ! v.__LZhaser) {
+ //the view doesn't have the empty resource. We need to try and replace it
v.makeContainerResource();
}
-
- if (v.__LZhaser ){
- v.createLoader();
- } else {
- //the view doesn't have the empty resource. We need to try and replace
- //it
- v.makeContainerResource();
- if (! this.loader) v.createLoader();
- }
-
-// var mc = v.__LZmovieClipRef;
-// Debug.debug(mc, '_width', mc._width);
-// Debug.debug(mc, '_height', mc._height);
-// Debug.debug(mc, '_xscale', mc._xscale);
-// Debug.debug(mc, '_yscale', mc._yscale);
-}
-/**
- * @access private
- */
-LzMakeLoadSprite.doReplaceResource = function (){
- //this gets called when a view applies the load transformer but it
- //already had a resource
-
- // use shadowed doReplaceResource()
- this.___doReplaceResource( );
- if (this._newrescname.indexOf('http:') == 0 || this._newrescname.indexOf('https:') == 0){
- this.createLoader();
- }
+ v.createLoader(src, cache, headers, filetype);
}
/**
* @access private
*/
-LzMakeLoadSprite.createLoader = function (){
- this.loader = new LzMediaLoader( this , {} );
- this.updateDel = new LzDelegate( this , "updateAfterLoad" );
- this.updateDel.register( this.loader , "onloaddone" );
-
- this.errorDel = new LzDelegate( this , "__LZsendError" );
- this.errorDel.register( this.loader , "onerror" );
+LzMakeLoadSprite.createLoader = function (src, cache, headers, filetype) {
+ this.loader = new LzMediaLoader(this, {});
- this.timeoutDel = new LzDelegate( this , "__LZsendTimeout" );
- this.timeoutDel.register( this.loader , "ontimeout" );
+ this.updateDel = new LzDelegate(this, "updateAfterLoad", this.loader, "onloaddone");
+ this.errorDel = new LzDelegate(this, "__LZsendError", this.loader, "onerror");
+ this.timeoutDel = new LzDelegate(this, "__LZsendTimeout", this.loader, "ontimeout");
- //Debug.write('LzMakeLoadSprite.createLoader', this.firstsrc)
- if ( this.firstsrc != null ){
- this.setSource( this.firstsrc , this.firstcache, this.firstheaders, this.firstfiletype );
+ if (src != null) {
+ this.setSource(src, cache, headers, filetype);
}
}
-
-
/**
* @access private
- * @param String newSrc: The url from which to load the resource for this view.
+ * @param String src: The url from which to load the resource for this view.
* @param String cache: If set, controls caching behavior. Choices are
* "none" , "clientonly" , "serveronly" , "both" -- where both is the default.
* @param String headers: Headers to send with the request (if any.)
* @param String filetype: Filetype, e.g. 'mp3' or 'jpg'. If not specified, it will be derived from the URL.
*/
-LzMakeLoadSprite.setSource = function ( newSrc , cache , headers , filetype ){
+LzMakeLoadSprite.setSource = function (src, cache, header, filetype) {
if (this.loader.mc.loading == true) {
LzLoadQueue.unloadRequest(this.loader.mc);
}
- //Debug.write('setSource', newSrc);
- if (newSrc == '' || newSrc == ' ' || newSrc == null) {
- Debug.error('setSource called with an empty url');
+
+ if (src == '' || src == ' ' || src == null) {
+ if ($debug) Debug.error('setSource called with an empty url');
return;
}
this.stopTrackPlay();
this.isloaded = false;
- if ( this.queuedplayaction == null ){
- this.queuePlayAction( "checkPlayStatus" );
+ if (this.queuedplayaction == null) {
+ this.queuePlayAction("checkPlayStatus");
}
- this.resource = newSrc;
- //this.owner.resource = newSrc;
- //if (this.owner.onresource) this.owner.onresource.sendEvent( newSrc );
+ this.resource = src;
+ //this.owner.resource = src;
+ //if (this.owner.onresource) this.owner.onresource.sendEvent( src );
this.owner.__LZvizLoad = false;
this.owner.__LZupdateShown();
- this.loader.request( newSrc , cache , headers, filetype );
+ this.loader.request(src, cache, headers, filetype);
}
/**
@@ -142,75 +88,60 @@
* load-transformed views and those that aren't
* @access private
*/
-LzMakeLoadSprite.setResource = function ( nresc ){
+LzMakeLoadSprite.setResource = function (nresc) {
// unload anything currently loading...
if (this.loader.mc.loading == true) {
LzLoadQueue.unloadRequest(this.loader.mc);
}
- if ( nresc == "empty" ){
+ if (nresc == "empty") {
// call shadowed setResource()
- this.___setResource( nresc );
- } else {
- if ( nresc.indexOf('http:') == 0 || nresc.indexOf('https:') == 0){
- this.setSource( nresc );
- return;
+ this.___setResource(nresc);
+ } else if (nresc.indexOf('http:') == 0 || nresc.indexOf('https:') == 0) {
+ this.setSource(nresc);
+ } else {
+ this.loader.attachLoadMovie(nresc);
+ if (this.queuedplayaction == null) {
+ this.queuePlayAction("checkPlayStatus");
}
- this.loader.attachLoadMovie( nresc );
- if ( this.queuedplayaction == null ){
- this.queuePlayAction( "checkPlayStatus" );
- }
//this.updateAfterLoad();
}
-
-// var mc = this.__LZmovieClipRef;
-// Debug.debug(mc, '_width', mc._width);
-// Debug.debug(mc, '_height', mc._height);
-// Debug.debug(mc, '_xscale', mc._xscale);
-// Debug.debug(mc, '_yscale', mc._yscale);
}
-//handle error
-
-
/**
* Updates movieclip properties after the resource has loaded
* @access private
*/
-LzMakeLoadSprite.updateAfterLoad = function (ignore){
-
+LzMakeLoadSprite.updateAfterLoad = function (ignore) {
this.isloaded = true;
+
var mc = this.getMCRef();
this.resourcewidth = mc._width;
this.resourceheight = mc._height;
-
this.currentframe = mc._currentframe;
var tfchg = this.totalframes != mc._totalframes;
- if ( tfchg ){
+ if (tfchg) {
this.totalframes = mc._totalframes;
this.owner.resourceevent('totalframes', this.totalframes);
}
- if ( this.totalframes > 1 ){
+ if (this.totalframes > 1) {
this.checkPlayStatus();
}
- this.setHeight(this.hassetheight?this.height:null);
- this.setWidth(this.hassetwidth?this.width:null);
+ this.setHeight(this.hassetheight ? this.height : null);
+ this.setWidth(this.hassetwidth ? this.width : null);
if (this.__contextmenu) {
this.setContextMenu(this.__contextmenu);
}
-
this.owner.__LZvizLoad = true;
this.owner.__LZupdateShown();
this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight, resource: this.resource, skiponload: false});
- this.owner.reevaluateSize( );
+ this.owner.reevaluateSize();
+
//if (this.owner.onload) this.owner.onload.sendEvent( this.loader.mc );
-
- //Debug.write('Sprite.updateAfterLoad', mc, this.resourcewidth, this.resourceheight, this.resource, this.owner.resource, this.owner, this.x);
- //Debug.warn('Sprite.updateAfterLoad');
}
/**
@@ -218,7 +149,7 @@
* @access private
*/
LzMakeLoadSprite.unload = function () {
- this.loader.unload( this.loader.mc );
+ this.loader.unload(this.loader.mc);
}
/**
@@ -235,7 +166,7 @@
* Get the number of bytes loaded so far
* @return: A number that is the maximum offset for this resource
*/
-LzMakeLoadSprite.getLoadBytes = function (){
+LzMakeLoadSprite.getLoadBytes = function () {
return this.getMCRef().getBytesLoaded();
}
@@ -243,26 +174,26 @@
* Get the total number of bytes for the attached resource
* @return: A number that is the maximum offset for this resource
*/
-LzMakeLoadSprite.getMaxBytes = function (){
+LzMakeLoadSprite.getMaxBytes = function () {
return this.getMCRef().getBytesTotal();
}
/**
* @access private
*/
-LzMakeLoadSprite.__LZsendError = function ( e ){
+LzMakeLoadSprite.__LZsendError = function (e) {
this.resourcewidth = 0;
this.resourceheight = 0;
- if (this.owner) this.owner.resourceloaderror( e )
+ if (this.owner) this.owner.resourceloaderror(e)
}
/**
* @access private
*/
-LzMakeLoadSprite.__LZsendTimeout = function ( e ){
+LzMakeLoadSprite.__LZsendTimeout = function (e) {
this.resourcewidth = 0;
this.resourceheight = 0;
- if (this.owner) this.owner.resourceloadtimeout( e )
+ if (this.owner) this.owner.resourceloadtimeout(e)
}
/**
@@ -276,7 +207,7 @@
if ('timeoutDel' in this)
this.timeoutDel.unregisterAll();
- this.loader.unload( this.loader.mc );
+ this.loader.unload(this.loader.mc);
// call shadowed destroy()
this.___destroy();
More information about the Laszlo-checkins
mailing list