[Laszlo-checkins] r11214 - openlaszlo/trunk/WEB-INF/lps/lfc/services
bargull@openlaszlo.org
bargull at openlaszlo.org
Thu Sep 25 01:29:51 PDT 2008
Author: bargull
Date: 2008-09-25 01:29:47 -0700 (Thu, 25 Sep 2008)
New Revision: 11214
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/services/LzAudio.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/services/LzCursor.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/services/LzGlobalMouse.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/services/LzIdle.lzs
Log:
Change 20080924-bargull-MZG by bargull at dell--p4--2-53 on 2008-09-24 20:41:55
in /home/Admin/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: services updates (partial)
New Features: LPP-7050
Bugs Fixed:
Technical Reviewer: promanik
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
- add typing information
- make service classes "public final"
- add service schema (all Lz*Service classes have a static const field Lz*, which is published as lz.* in the lz-namespace)
- reindent lines if necessary
Tests:
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzAudio.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzAudio.lzs 2008-09-25 08:27:14 UTC (rev 11213)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzAudio.lzs 2008-09-25 08:29:47 UTC (rev 11214)
@@ -20,112 +20,137 @@
</canvas>]]></example>
*
*
- * @shortdesc This service manages audio resource playback. Check canvas.capabilities.audio to ensure your runtime supports audio.
+ * @shortdesc This service manages audio resource playback. Check canvas.capabilities.audio to ensure your runtime supports audio.
* @access public
- *
+ *
*/
-class LzAudioService {
-// TODO [hqm 2008-03] Will asking for LzSprite.prototype.xxx work in SWF9?
-if ($swf9) {
- /** @access private */
- var capabilities = LzSprite.capabilities;
-} else {
- /** @access private */
- var capabilities = LzSprite.prototype.capabilities;
-}
+public final class LzAudioService {
+ // TODO [hqm 2008-03] Will asking for LzSprite.prototype.xxx work in SWF9?
+ if ($swf9) {
+ /** @access private */
+ var capabilities :* = LzSprite.capabilities;
+ } else {
+ /** @access private */
+ var capabilities :* = LzSprite.prototype.capabilities;
+ }
-/**
- * Sets the current sound resource and starts playing it.
- * @param String snd: Name of a sound resource to play
- */
-function playSound( snd ){
- if (this.capabilities.audio) {
- LzAudioKernel.playSound(snd);
- } else if ($debug) {
- this.__warnCapability('lz.Audio.playSound()');
+ /** The audio service. Also available as the global
+ * <code>lz.Audio</code>.
+ *
+ * @type LzAudioService
+ * @keywords readonly
+ * @devnote this should be a public getter to enforce readonly
+ */
+ public static const LzAudio:LzAudioService;
+
+ /** @access private
+ * @devnote AS3 does not allow private constructors, so we need the
+ * error
+ */
+ function LzAudioService () {
+ super();
+ // if (LzAudioService.LzAudio) {
+ // throw new Error("There can be only one LzAudio");
+ // }
}
-}
-/**
- * Stop playing the current sound
- * */
-function stopSound(){
- if (this.capabilities.audio) {
- LzAudioKernel.stopSound();
- } else if ($debug) {
- this.__warnCapability('lz.Audio.stopSound()');
+ // Create the singleton
+ LzAudioService.LzAudio = new LzAudioService();
+
+ /**
+ * Sets the current sound resource and starts playing it.
+ * @param String snd: Name of a sound resource to play
+ */
+ function playSound (snd:String) :void {
+ if (this.capabilities.audio) {
+ LzAudioKernel.playSound(snd);
+ } else if ($debug) {
+ this.__warnCapability('lz.Audio.playSound()');
+ }
}
-}
-/**
- * Start playing the current sound
- *
- */
-function startSound() {
- if (this.capabilities.audio) {
- LzAudioKernel.startSound();
- } else if ($debug) {
- this.__warnCapability('lz.Audio.startSound()');
+ /**
+ * Stop playing the current sound
+ * */
+ function stopSound () :void {
+ if (this.capabilities.audio) {
+ LzAudioKernel.stopSound();
+ } else if ($debug) {
+ this.__warnCapability('lz.Audio.stopSound()');
+ }
}
-}
-/**
- * Get the global volume
- * @return Number: volume from 0 to 100 (0 is silent).
- */
-function getVolume() {
- if (this.capabilities.audio) {
- return LzAudioKernel.getVolume();
- } else if ($debug) {
- this.__warnCapability('lz.Audio.getVolume()');
+ /**
+ * Start playing the current sound
+ *
+ */
+ function startSound () :void {
+ if (this.capabilities.audio) {
+ LzAudioKernel.startSound();
+ } else if ($debug) {
+ this.__warnCapability('lz.Audio.startSound()');
+ }
}
-}
-/**
- * Set the global volume.
- * @param Number v: linear volume from 0 to 100 (0 is silent).
- */
-function setVolume(v) {
- if (this.capabilities.audio) {
- LzAudioKernel.setVolume(v);
- } else if ($debug) {
- this.__warnCapability('lz.Audio.setVolume()');
+ /**
+ * Get the global volume
+ * @return Number: volume from 0 to 100 (0 is silent).
+ */
+ function getVolume () :Number {
+ if (this.capabilities.audio) {
+ return LzAudioKernel.getVolume();
+ } else if ($debug) {
+ this.__warnCapability('lz.Audio.getVolume()');
+ }
}
-}
-/**
- * Get the global pan.
- * @return Number: linear pan from -100 to +100 (left to right)
- */
-function getPan() {
- if (this.capabilities.audio) {
- return LzAudioKernel.getPan();
- } else if ($debug) {
- this.__warnCapability('lz.Audio.getPan()');
+ /**
+ * Set the global volume.
+ * @param Number v: linear volume from 0 to 100 (0 is silent).
+ */
+ function setVolume (v:Number) :void {
+ if (this.capabilities.audio) {
+ LzAudioKernel.setVolume(v);
+ } else if ($debug) {
+ this.__warnCapability('lz.Audio.setVolume()');
+ }
}
-}
-/**
- * Set the global pan.
- * @param Number p: linear pan from -100 to +100 (left to right)
- */
-function setPan(p) {
- if (this.capabilities.audio) {
- LzAudioKernel.setPan(p);
- } else if ($debug) {
- this.__warnCapability('lz.Audio.setPan()');
+ /**
+ * Get the global pan.
+ * @return Number: linear pan from -100 to +100 (left to right)
+ */
+ function getPan () :Number {
+ if (this.capabilities.audio) {
+ return LzAudioKernel.getPan();
+ } else if ($debug) {
+ this.__warnCapability('lz.Audio.getPan()');
+ }
}
-}
-/** @access private */
-function __warnCapability(msg) {
- Debug.warn('The %s runtime does not support %s', canvas['runtime'], msg);
+ /**
+ * Set the global pan.
+ * @param Number p: linear pan from -100 to +100 (left to right)
+ */
+ function setPan (p:Number) :void {
+ if (this.capabilities.audio) {
+ LzAudioKernel.setPan(p);
+ } else if ($debug) {
+ this.__warnCapability('lz.Audio.setPan()');
+ }
+ }
+
+if ($debug) {
+ /** @access private */
+ function __warnCapability (msg:String) :void {
+ Debug.warn('The %s runtime does not support %s', canvas['runtime'], msg);
+ }
}
} // End of LzAudioService
lz.AudioService = LzAudioService; // publish
/**
- * lz.Audio is a shortcut for <a href="LzAudioService.html">LzAudioService</a>.
+ * lz.Audio is a shortcut for <a href="LzAudioService.html">LzAudioService.LzAudio</a>.
*/
-lz.Audio = new LzAudioService();
+lz.Audio = LzAudioService.LzAudio;
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzCursor.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzCursor.lzs 2008-09-25 08:27:14 UTC (rev 11213)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzCursor.lzs 2008-09-25 08:29:47 UTC (rev 11214)
@@ -40,67 +40,70 @@
* </button>
* </canvas>
* </example>
- * @devnote TODO: [2008-03-20 ptw] This should be `implements` not `extends`.
* @access public
* @shortdesc LzCursorService provides methods for changing the mouse cursor.
*/
-public class LzCursorService extends LzEventable {
- /** The cursor service. Also available as the global
- * <code>lz.Cursor</code>.
- *
- * @type LzCursorService
- * @keywords readonly
- * @devnote this should be a public getter to enforce readonly
- */
- public static var LzCursor:LzCursorService;
+public final class LzCursorService extends LzEventable {
+ /** The cursor service. Also available as the global
+ * <code>lz.Cursor</code>.
+ *
+ * @type LzCursorService
+ * @keywords readonly
+ * @devnote this should be a public getter to enforce readonly
+ */
+ public static const LzCursor:LzCursorService;
- /** @access private
- * @devnote AS3 does not allow private constructors, so we need the
- * error
- */
- public function LzCursorService() {
- if (LzCursorService.LzCursor) {
- throw new Error("There can be only one LzCursor");
+ /** @access private
+ * @devnote AS3 does not allow private constructors, so we need the
+ * error
+ */
+ public function LzCursorService () {
+ super();
+ // if (LzCursorService.LzCursor) {
+ // throw new Error("There can be only one LzCursor");
+ // }
}
- }
- /**
- * Shows or hides the hand cursor for all clickable views.
- * @param Boolean show: true shows the hand cursor for buttons, false hides it
- */
- function showHandCursor(show:Boolean) {
- LzMouseKernel.showHandCursor(show);
- }
+ // Create the singleton
+ LzCursorService.LzCursor = new LzCursorService();
- /**
- * Sets the cursor to a resource
- * @param String resource: The resource to use as the cursor.
- */
- function setCursorGlobal(resource:String) {
- LzMouseKernel.setCursorGlobal(resource);
- }
+ /**
+ * Shows or hides the hand cursor for all clickable views.
+ * @param Boolean show: true shows the hand cursor for buttons, false hides it
+ */
+ function showHandCursor (show:Boolean) :void {
+ LzMouseKernel.showHandCursor(show);
+ }
- /**
- * Prevents the cursor from being changed until unlock is called.
- */
- function lock() {
- LzMouseKernel.lock();
- }
+ /**
+ * Sets the cursor to a resource
+ * @param String resource: The resource to use as the cursor.
+ */
+ function setCursorGlobal (resource:String) :void {
+ LzMouseKernel.setCursorGlobal(resource);
+ }
- /**
- * Restores the default cursor.
- */
- function unlock() {
+ /**
+ * Prevents the cursor from being changed until unlock is called.
+ */
+ function lock () :void {
+ LzMouseKernel.lock();
+ }
+
+ /**
+ * Restores the default cursor.
+ */
+ function unlock () :void {
LzMouseKernel.unlock();
- }
+ }
- /**
- * Restores the default cursor if there is no locked cursor on
- * the screen.
- */
- function restoreCursor(ignore=null) {
- LzMouseKernel.restoreCursor();
- }
+ /**
+ * Restores the default cursor if there is no locked cursor on
+ * the screen.
+ */
+ function restoreCursor () :void {
+ LzMouseKernel.restoreCursor();
+ }
}
lz.CursorService = LzCursorService; // publish
@@ -141,4 +144,4 @@
* @type LzCursorService
* @shortdesc lz.Cursor is a shortcut for <link linkend="LzCursorService">LzCursorService.LzCursor</link>
*/
-lz.Cursor = new LzCursorService();
+lz.Cursor = LzCursorService.LzCursor;
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzGlobalMouse.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzGlobalMouse.lzs 2008-09-25 08:27:14 UTC (rev 11213)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzGlobalMouse.lzs 2008-09-25 08:29:47 UTC (rev 11214)
@@ -78,109 +78,112 @@
* rollover or button state changes. The argument sent with the events is the
* view that was clicked. If no view was clicked, the argument is null.
*/
-public class LzGlobalMouseService extends LzEventable {
- /**
- * The global mouse service. Also available as the global
- * <code>lz.GlobalMouse</code>.
- *
- * @type LzGlobalMouseService
- * @keywords readonly
- * @devnote this should be a public getter to enforce readonly
- */
- static var LzGlobalMouse:LzGlobalMouseService;
+public final class LzGlobalMouseService extends LzEventable {
+ /**
+ * The global mouse service. Also available as the global
+ * <code>lz.GlobalMouse</code>.
+ *
+ * @type LzGlobalMouseService
+ * @keywords readonly
+ * @devnote this should be a public getter to enforce readonly
+ */
+ public static const LzGlobalMouse:LzGlobalMouseService;
- /** @access private
- * @devnote AS3 does not allow private constructors, so we need the
- * error
- */
- function LzGlobalMouseService() {
- // if (LzGlobalMouseService.LzGlobalMouse) {
- // throw new Error("There can be only one LzGlobalMouse");
- // }
- }
- LzGlobalMouseService.LzGlobalMouse = new LzGlobalMouseService;
+ /** @access private
+ * @devnote AS3 does not allow private constructors, so we need the
+ * error
+ */
+ function LzGlobalMouseService() {
+ super();
+ // if (LzGlobalMouseService.LzGlobalMouse) {
+ // throw new Error("There can be only one LzGlobalMouse");
+ // }
+ }
- /** Sent whenever the mouse moves
- * @access public
- * @lzxtype event
- */
- var onmousemove = LzDeclaredEvent;
+ // Create the singleton
+ LzGlobalMouseService.LzGlobalMouse = new LzGlobalMouseService();
- /** Sent whenever the mouse button goes up
- * @access public
- * @lzxtype event
- */
- var onmouseup = LzDeclaredEvent;
+ /** Sent whenever the mouse moves
+ * @access public
+ * @lzxtype event
+ */
+ var onmousemove :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse button goes up outside the view where it
- * first went down
- * @access public
- * @lzxtype event
- */
- var onmouseupoutside = LzDeclaredEvent;
+ /** Sent whenever the mouse button goes up
+ * @access public
+ * @lzxtype event
+ */
+ var onmouseup :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse enters a view
- * @access public
- * @lzxtype event
- */
- var onmouseover = LzDeclaredEvent;
+ /** Sent whenever the mouse button goes up outside the view where it
+ * first went down
+ * @access public
+ * @lzxtype event
+ */
+ var onmouseupoutside :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse leaves a view
- * @access public
- * @lzxtype event
- */
- var onmouseout = LzDeclaredEvent;
+ /** Sent whenever the mouse enters a view
+ * @access public
+ * @lzxtype event
+ */
+ var onmouseover :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse button goes down
- * @access public
- * @lzxtype event
- */
- var onmousedown = LzDeclaredEvent;
+ /** Sent whenever the mouse leaves a view
+ * @access public
+ * @lzxtype event
+ */
+ var onmouseout :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse is dragged in to a view
- * @access public
- * @lzxtype event
- */
- var onmousedragin = LzDeclaredEvent;
+ /** Sent whenever the mouse button goes down
+ * @access public
+ * @lzxtype event
+ */
+ var onmousedown :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse is dragged out of a view
- * @access public
- * @lzxtype event
- */
- var onmousedragout = LzDeclaredEvent;
+ /** Sent whenever the mouse is dragged in to a view
+ * @access public
+ * @lzxtype event
+ */
+ var onmousedragin :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse is dragged out of the application window
- * @access public
- * @lzxtype event
- */
- var onmouseleave = LzDeclaredEvent;
+ /** Sent whenever the mouse is dragged out of a view
+ * @access public
+ * @lzxtype event
+ */
+ var onmousedragout :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse button is clicked
- * @access public
- * @lzxtype event
- */
- var onclick = LzDeclaredEvent;
+ /** Sent whenever the mouse is dragged out of the application window
+ * @access public
+ * @lzxtype event
+ */
+ var onmouseleave :LzDeclaredEventClass = LzDeclaredEvent;
- /** Sent whenever the mouse button is double-clicked
- * @access public
- * @lzxtype event
- */
- var ondblclick = LzDeclaredEvent;
+ /** Sent whenever the mouse button is clicked
+ * @access public
+ * @lzxtype event
+ */
+ var onclick :LzDeclaredEventClass = LzDeclaredEvent;
- /** @access private */
- var __movecounter = 0;
+ /** Sent whenever the mouse button is double-clicked
+ * @access public
+ * @lzxtype event
+ */
+ var ondblclick :LzDeclaredEventClass = LzDeclaredEvent;
- /** @access private */
- function __mouseEvent (eventname, view) {
- if (eventname == 'onmouseleave') { canvas.onmouseleave.sendEvent(); }
- if (eventname == 'onmousemove') { this.__movecounter++; }
- var ev = this[eventname];
- if (ev) {
- if (ev.ready) { ev.sendEvent(view); }
- } else if ($debug) {
- Debug.debug("Unknown mouse event %s", eventname);
+ /** @access private */
+ var __movecounter:int = 0;
+
+ /** @access private */
+ function __mouseEvent (eventname:String, view:*) :void {
+ if (eventname == 'onmouseleave') { canvas.onmouseleave.sendEvent(); }
+ else if (eventname == 'onmousemove') { this.__movecounter++; }
+ var ev:LzDeclaredEventClass = this[eventname];
+ if (ev) {
+ if (ev.ready) { ev.sendEvent(view); }
+ } else if ($debug) {
+ Debug.debug("Unknown mouse event %s", eventname);
+ }
}
- }
}
lz.GlobalMouseService = LzGlobalMouseService; // publish
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzIdle.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzIdle.lzs 2008-09-25 08:27:14 UTC (rev 11213)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzIdle.lzs 2008-09-25 08:29:47 UTC (rev 11214)
@@ -32,92 +32,94 @@
* @devnote This object sends an 'onidle' event when there is no synchronous script
* running after each frame update.
*/
-class LzIdleService extends LzEventable {
- /** @access private */
- var coi;
- /** @access private */
- var regNext:Boolean = false;
- /** @access private */
- var removeCOI = null;
+public final class LzIdleService extends LzEventable {
+ /** @access private */
+ var coi :Array;
+ /** @access private */
+ var regNext :Boolean = false;
+ /** @access private */
+ var removeCOI :LzDelegate = null;
- /**
- * The idle service. Also available as the global
- * <code>lz.Idle</code>.
- *
- * @type LzIdleService
- * @keywords readonly
- * @devnote this should be a public getter to enforce readonly
- */
- static var LzIdle:LzIdleService;
+ /**
+ * The idle service. Also available as the global
+ * <code>lz.Idle</code>.
+ *
+ * @type LzIdleService
+ * @keywords readonly
+ * @devnote this should be a public getter to enforce readonly
+ */
+ public static const LzIdle:LzIdleService;
- /** @access private
- * @devnote AS3 does not allow private constructors, so we need the
- * error
- */
- function LzIdleService () {
- // if (LzIdleService.LzIdle) {
- // throw new Error("There can be only one LzIdle");
- // }
- // Create array on instance, not prototype
- this.coi = new Array;
- this.removeCOI = new LzDelegate( this , "removeCallIdleDelegates" );
- LzIdleKernel.addCallback( this, '__idleupdate' );
- }
- /* Avoid idle noise in the profiler */
- {
+ /** @access private
+ * @devnote AS3 does not allow private constructors, so we need the
+ * error
+ */
+ function LzIdleService () {
+ super();
+ // if (LzIdleService.LzIdle) {
+ // throw new Error("There can be only one LzIdle");
+ // }
+ // Create array on instance, not prototype
+ this.coi = new Array;
+ this.removeCOI = new LzDelegate( this, "removeCallIdleDelegates" );
+ LzIdleKernel.addCallback( this, '__idleupdate' );
+ }
+
+/* Avoid idle noise in the profiler */
+{
#pragma "profile=false"
// Create the singleton
LzIdleService.LzIdle = new LzIdleService();
- }
+}
- /**
- * Calls the given delegate at the next idle event. This can be used
- * for a non-repeating callback.
- *
- * @param LzDelegate d: The delegate to be called on the next idle
- * event.
- */
- function callOnIdle ( d ){
- this.coi.push(d);
- if (!this.regNext) {
- this.regNext = true;
- this.removeCOI.register( this , "onidle" );
+ /**
+ * Calls the given delegate at the next idle event. This can be used
+ * for a non-repeating callback.
+ *
+ * @param LzDelegate d: The delegate to be called on the next idle
+ * event.
+ */
+ function callOnIdle (d:LzDelegate) :void {
+ this.coi.push(d);
+ if (! this.regNext) {
+ this.regNext = true;
+ this.removeCOI.register( this , "onidle" );
+ }
}
- }
- /**
- * @access private
- */
- function removeCallIdleDelegates ( t ){
- var arr = this.coi;
- this.coi = new Array;
- //call in order
- for (var i = 0; i < arr.length; i++ ){
- arr[i].execute( t );
- }
+ /**
+ * @access private
+ */
+ function removeCallIdleDelegates (t:*) :void {
+ var arr:Array = this.coi;
+ this.coi = new Array;
+ //call in order
+ for (var i:int = 0; i < arr.length; i++) {
+ arr[i].execute( t );
+ }
- if (this.coi.length == 0) {
- // Note that the executed items may have added to the (new)
- // coi queue, only unregister if the queue is empty
- this.removeCOI.unregisterFrom(this.onidle);
- this.regNext = false;
+ if (this.coi.length == 0) {
+ // Note that the executed items may have added to the (new)
+ // coi queue, only unregister if the queue is empty
+ this.removeCOI.unregisterFrom(this.onidle);
+ this.regNext = false;
+ }
}
- }
- /** This is the idle event for the system, sent by this service
- * @lzxtype event
- */
- var onidle = LzDeclaredEvent;
+ /** This is the idle event for the system, sent by this service
+ * @lzxtype event
+ */
+ var onidle :LzDeclaredEventClass = LzDeclaredEvent;
- /**
- * __idleupdate is a callback function from LzIdleKernel.
- * @access private
- */
- function __idleupdate (t) {
- if (this.onidle.ready) {
- this.onidle.sendEvent(t);
+ /**
+ * __idleupdate is a callback function from LzIdleKernel.
+ * @access private
+ */
+ function __idleupdate (t:*) :void {
+ if (this.onidle.ready) {
+ this.onidle.sendEvent(t);
+ }
}
- }
}
lz.IdleService = LzIdleService; // publish
More information about the Laszlo-checkins
mailing list