You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(109) |
Oct
(25) |
Nov
(6) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(263) |
Feb
(107) |
Mar
(62) |
Apr
(25) |
May
(39) |
Jun
(15) |
Jul
(19) |
Aug
(1) |
Sep
(54) |
Oct
(80) |
Nov
(61) |
Dec
|
2007 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
(22) |
Jun
(36) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
From: <aci...@us...> - 2007-09-21 10:58:54
|
Revision: 718 http://asapframework.svn.sourceforge.net/asapframework/?rev=718&view=rev Author: acidcats Date: 2007-09-21 03:58:50 -0700 (Fri, 21 Sep 2007) Log Message: ----------- added 'public' modifier to make classes visible Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQAddMove.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQPulse.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQAddMove.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQAddMove.as 2007-09-09 16:33:00 UTC (rev 717) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQAddMove.as 2007-09-21 10:58:50 UTC (rev 718) @@ -26,7 +26,7 @@ @author Arthur Clemens */ - class AQAddMove { + public class AQAddMove { private static var START_VALUE:Number = 0; /**< Start animation value to be returned to the perform function. */ private static var END_VALUE:Number = 1; /**< End animation value to be returned to the perform function. */ Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as 2007-09-09 16:33:00 UTC (rev 717) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as 2007-09-21 10:58:50 UTC (rev 718) @@ -26,7 +26,7 @@ @author Arthur Clemens */ - class AQFade { + public class AQFade { private static var START_VALUE:Number = 1; /**< Start animation value to be returned to the perform function. */ private static var END_VALUE:Number = 0; /**< End animation value to be returned to the perform function. */ Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as 2007-09-09 16:33:00 UTC (rev 717) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as 2007-09-21 10:58:50 UTC (rev 718) @@ -31,7 +31,7 @@ @author Arthur Clemens */ - class AQFollowMouse { + public class AQFollowMouse { /** Lets a movieclip follow mouse movements. Control parameters: Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as 2007-09-09 16:33:00 UTC (rev 717) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as 2007-09-21 10:58:50 UTC (rev 718) @@ -25,7 +25,7 @@ @author Arthur Clemens */ - class AQMove { + public class AQMove { private static var START_VALUE:Number = 1; /**< Start animation value to be returned to the perform function. */ private static var END_VALUE:Number = 0; /**< End animation value to be returned to the perform function. */ Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQPulse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQPulse.as 2007-09-09 16:33:00 UTC (rev 717) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQPulse.as 2007-09-21 10:58:50 UTC (rev 718) @@ -27,7 +27,7 @@ import org.asapframework.util.actionqueue.*; import org.asapframework.util.NumberUtils; - class AQPulse { + public class AQPulse { private static var START_VALUE:Number = 0; /**< Start animation value to be returned to the perform function. */ private static var END_VALUE:Number = 1; /**< End animation value to be returned to the perform function. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-09-04 20:11:47
|
Revision: 714 http://asapframework.svn.sourceforge.net/asapframework/?rev=714&view=rev Author: acidcats Date: 2007-09-04 13:11:19 -0700 (Tue, 04 Sep 2007) Log Message: ----------- Minor fixes & comment additions Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as 2007-09-03 08:04:18 UTC (rev 713) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as 2007-09-04 20:11:19 UTC (rev 714) @@ -1,12 +1,10 @@ /* Copyright 2007 by the authors of asapframework, http://asapframework.org - Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as 2007-09-03 08:04:18 UTC (rev 713) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as 2007-09-04 20:11:19 UTC (rev 714) @@ -1,95 +1,79 @@ /* Copyright 2007 by the authors of asapframework, http://asapframework.org - Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ /** Class for managing language dependencies in an application. For text, the language dependent texts are expected to be in an xml per language, with the following structure: <code> <texts> - <text id="1">Hello World</text> - <text id="2"><[!CDATA[<b>Hello</b> World with bold Hello]]></text> - <text id="3" html="false"><[!CDATA[<b>Hello</b> World with visible html tags]]></text> - <text id="4"><[!CDATA[>>>Hello World<<<]]></text> +<text id="1">Hello World</text> +<text id="2"><[!CDATA[<b>Hello</b> World with bold Hello]]></text> +<text id="3" html="false"><[!CDATA[<b>Hello</b> World with visible html tags]]></text> +<text id="4"><[!CDATA[>>>Hello World<<<]]></text> </texts> </code> The 'id' attribute is mandatory, and has to be a number. The 'html' attribute is optional. If left out, text is rendered as HTML text; any other value than "false" is seen as true. When false, the text is set directly into the text field, and any html tags are ignored. In case the text contains xml characters, the text has to be wrapped in a {@code <![CDATA[[]]>} tag. The id is expected to be unique. When it isn't, the last item is taken. - The xml file containing the language dependent texts has to be loaded with the method {@link #loadXML}. When loaded and parsed, the LanguageManager sends an event of type LanguageManager.EVENT_LOADED. Subscribe to this event if you wish to be notified. No event is sent when the loading fails, only a Log message of level ERROR is output. - Once an xml file has been loaded, data is available by id through {@link #getTextByID} and {@link #getDataByID}. Since the LanguageManager is a Singleton, the language dependent data is available throughout your application. - However, the LanguageManager also contains a mechanism for automatic assignment of data. To use this functionality, use the provided class {@link MultiLanguageTextContainer}, or write your own implementation of {@link IMultiLanguageTextContainer}. When writing your own class, allow for a way to determine the id of the text that is to be used by a specific instance for your class. In case of the MultiLanguageTextContainer class, this id is retrieved from the name of the movieclip instance to which the class is linked, by taking everything after the last underscore and converting to a number. So "myText_1" gets the text with id=1. Once the id is known inside your class, add the instance to the LanguageManager with {@link #addContainer}, providing the id and the instance itself as parameters. If data has been loaded, it is provided to the instance immediately. Whenever new data is loaded, the LanguageManager calls "setData" on each instance that was added, thereby updating language dependent text instantaneously. A good spot to add an instance to the LanguageManager is when Event.ADDED is received. Make sure to remove it again when Event.REMOVED is received, to allow for proper memory management. This also makes sure that the instance keeps its text when subject to animation key frames. Instances can share the same id, and thereby have the same text. - By default, the LanguageManager returns an empty string (or provides an empty string in the data) when a requested id is not found. This has two drawbacks: <ul><li>The textfield becomes effectively invisible since there is no text in it</li> <li>Formatting of the textfield (such as weight or alignment) may be lost when the textfield is cleared</li></ul> To allow for easier debugging, the flag {@link #generateDebugText} can be set. If an unknown id is requested, the returned text will be ">> id = #id", where #id is replaced with the actually requested id. This makes it easier to find missing texts from the xml files. - @example <ul> <li>Loading an xml file into the LanguageManager, specifying a language code to be used in determining the name of the xml file to be loaded. <code> // @param inCode: 2-letter ISO language code; will be added to filename. Example: with parameter "en" the file "texts_en.xml" will be loaded. private function loadLanguage (inCode:String) : void { - var lm:LanguageManager = LanguageManager.getInstance(); - lm.addEventListener(LanguageManager.EVENT_LOADED, handleLanguageLoaded); - lm.loadXML("../xml/texts_" + inCode + ".xml"); +var lm:LanguageManager = LanguageManager.getInstance(); +lm.addEventListener(LanguageManager.EVENT_LOADED, handleLanguageLoaded); +lm.loadXML("../xml/texts_" + inCode + ".xml"); } - private function handleLanguageLoaded () : Void { - Log.debug("handleLanguageLoaded: Language file loaded.", toString()); +Log.debug("handleLanguageLoaded: Language file loaded.", toString()); } </code> </li> - <li>Assigning a text to a textfield manually from anywhere in your code: <code>myTextfield.text = LanguageManager.getInstance().getTextByID(23);</code> </li> - <li>A class that gets a random text from the first 10 texts of the LanguageManager each time it is loaded: <code> class MyText extends MovieClip implements IMultiLanguageTextContainer { - private var mID:Number; - private var myTextField:TextField; - - public function MyText () { - addEventListener(Event.ADDED, handleAdded); - addEventListener(Event.REMOVED, handleRemoved); - } - - public function setData (inData : TextItemData) : Void { - setText(inData.text, inData.isHTML); - } - - public function setText (inText:String, inIsHTML:Boolean = true) : Void { - if (inIsHTML) tf_txt.htmlText = inText; - else tf_txt.text = inText; - } - - private function handleAdded (e:Event) : Void { +private var mID:Number; +private var myTextField:TextField; +public function MyText () { +addEventListener(Event.ADDED, handleAdded); +addEventListener(Event.REMOVED, handleRemoved); +} +public function setData (inData : TextItemData) : Void { +setText(inData.text, inData.isHTML); +} +public function setText (inText:String, inIsHTML:Boolean = true) : Void { +if (inIsHTML) tf_txt.htmlText = inText; +else tf_txt.text = inText; +} +private function handleAdded (e:Event) : Void { mID = Math.floor(10 * Math.random()); LanguageManager.getInstance().addContainer(mID, this); @@ -200,7 +184,7 @@ var len:uint = mTextClips.length; for (var i:uint = 0; i < len; ++i) { - var md:MultiLanguageContainerData = MultiLanguageContainerData(mTextClips[i]); + var md:MultiLanguageContainerData = mTextClips[i] as MultiLanguageContainerData; if (md.id == inData.id) { md.container.setData(inData); } @@ -240,7 +224,7 @@ private function getClipDataByContainer (inContainer:IMultiLanguageTextContainer) : MultiLanguageContainerData { var len:uint = mTextClips.length; for (var i:uint = 0; i < len; ++i) { - var md:MultiLanguageContainerData = MultiLanguageContainerData(mTextClips[i]); + var md:MultiLanguageContainerData = mTextClips[i] as MultiLanguageContainerData; if (md.container == inContainer) return md; } return null; @@ -253,7 +237,7 @@ private function getClipDataIndexByContainer (inContainer:IMultiLanguageTextContainer) : uint { var len:uint = mTextClips.length; for (var i:uint = 0; i < len; ++i) { - var md:MultiLanguageContainerData = MultiLanguageContainerData(mTextClips[i]); + var md:MultiLanguageContainerData = mTextClips[i] as MultiLanguageContainerData; if (md.container == inContainer) return i; } return NaN; @@ -278,7 +262,7 @@ */ private function handleLanguageDataLoaded (e:XMLLoaderEvent) : void { // parse XML into TextItemData objects - var items:Array = Parser.parseList(e.data.text, org.asapframework.management.lang.TextItemData); + var items:Array = Parser.parseList(e.data.text as XMLList, org.asapframework.management.lang.TextItemData); // add the items var len:uint = items.length; Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as 2007-09-03 08:04:18 UTC (rev 713) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as 2007-09-04 20:11:19 UTC (rev 714) @@ -1,22 +1,17 @@ /* Copyright 2007 by the authors of asapframework, http://asapframework.org - Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ /** Basic implementation of {@link IMultiLanguageTextContainer} to be used with the {@link LanguageManager} to provide language dependent texts in an application. - To use this class, perform the following steps: <ol> <li>Create a new movieclip in the library</li> @@ -28,69 +23,66 @@ <li>Name the instances whatever you like, as long as the name ends with underscore, followed by the integer id of the text to be associated with the instance. P.e.: "helloWorld_1"</li> <li>In your application, load an xml file containing texts into the LanguageManager: <code>LanguageManager.getInstance().loadXML("texts_en.xml");</code></li> </ol> - This class can be used either <ul><li>directly,</li> <li>as base class for further extension or </li> <li>as example of how to implement the {@link IMultiLanguageTextContainer} interface.</li></ul> -*/ + */ package org.asapframework.management.lang { import flash.display.MovieClip; - import flash.text.TextField; import flash.events.Event; + import flash.text.TextField; - import org.asapframework.util.debug.Log; - - public class MultiLanguageTextContainer extends MovieClip implements IMultiLanguageTextContainer { - public var tf_txt:TextField; + public var tf_txt : TextField; + public function MultiLanguageTextContainer () { addEventListener(Event.ADDED, handleAdded); addEventListener(Event.REMOVED, handleRemoved); } /** - * IMultiLanguageTextContainer implementation - * Set the data for the container - * @param inData: the object containing the data - */ + * IMultiLanguageTextContainer implementation + * Set the data for the container + * @param inData: the object containing the data + */ public function setData (inData : TextItemData) : void { setText(inData.text, inData.isHTML); } /** - * IMultiLanguageTextContainer implementation - * Set the text for the container - * @param inText: the string containing the text - * @param inIsHTML: if true, text is rendered as HTML, otherwise directly - */ - public function setText (inText:String, inIsHTML:Boolean = true) : void { + * IMultiLanguageTextContainer implementation + * Set the text for the container + * @param inText: the string containing the text + * @param inIsHTML: if true, text is rendered as HTML, otherwise directly + */ + public function setText (inText : String, inIsHTML : Boolean = true) : void { if (inIsHTML) tf_txt.htmlText = inText; else tf_txt.text = inText; } - + /** - * Handle internal event that instance has been added to the stage - * @param e - */ - private function handleAdded (e:Event) : void { - var id:uint = parseInt(name.substring(name.lastIndexOf("_")+1), 10); + * Handle internal event that instance has been added to the stage + * @param e + */ + private function handleAdded (e : Event) : void { + var id : uint = parseInt(name.substring(name.lastIndexOf("_") + 1), 10); LanguageManager.getInstance().addContainer(id, this); } /** - * Handle internal event that instance has been removed from the stage - * @param e - */ - private function handleRemoved (e:Event) : void { + * Handle internal event that instance has been removed from the stage + * @param e + */ + private function handleRemoved (e : Event) : void { LanguageManager.getInstance().removeContainer(this); } - override public function toString() : String { + override public function toString () : String { return ";org.asapframework.management.lang.MultiLanguageTextContainer"; } } Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as 2007-09-03 08:04:18 UTC (rev 713) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as 2007-09-04 20:11:19 UTC (rev 714) @@ -1,19 +1,15 @@ /* Copyright 2007 by the authors of asapframework, http://asapframework.org - Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ /** ValueObject class that holds data for a text item. Classes that implement {@link IMultiLanguageTextContainer} get this type of data from the LanguageManager. @@ -22,29 +18,29 @@ package org.asapframework.management.lang { import org.asapframework.data.xml.IParsable; - import org.asapframework.util.debug.Log; - + public class TextItemData implements IParsable { - public var text:String; - public var id:uint; - public var isHTML:Boolean = true; - + public var text : String; + public var id : uint; + public var isHTML : Boolean = true; + + /** Constructor @param inID: unique id of item @param inText: text for item - */ - public function TextItemData (inID:uint = 0, inText:String = null) { + */ + public function TextItemData (inID : uint = 0, inText : String = null) { id = inID; text = inText; } /** - * Parse specified XML data into member variables - * @param o: XML object to be parsed - * @return true if parsing went ok, otherwise false - */ - public function parseXML (o:XML) : Boolean { + * Parse specified XML data into member variables + * @param o: XML object to be parsed + * @return true if parsing went ok, otherwise false + */ + public function parseXML (o : XML) : Boolean { id = parseInt(o.@id, 10); isHTML = o.@html != "false"; text = o.toString(); @@ -56,5 +52,4 @@ return "org.asapframework.management.lang.TextItemData"; } } - } Modified: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as 2007-09-03 08:04:18 UTC (rev 713) +++ branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as 2007-09-04 20:11:19 UTC (rev 714) @@ -1,13 +1,21 @@ -/** -* ... -* @author Default -* @version 0.1 +/* +Copyright 2007 by the authors of asapframework +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + package org.asapframework.ui.buttons { import flash.display.MovieClip; - import flash.events.MouseEvent; - + public class BaseButton extends MovieClip { public var hitArea_mc:MovieClip; @@ -19,8 +27,10 @@ buttonMode = true; // set and hide hit area - hitArea = hitArea_mc; - hitArea_mc.visible = false; + if (hitArea_mc != null) { + hitArea = hitArea_mc; + hitArea_mc.visible = false; + } // don't handle mouse events on children mouseChildren = false; Modified: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as 2007-09-03 08:04:18 UTC (rev 713) +++ branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as 2007-09-04 20:11:19 UTC (rev 714) @@ -1,25 +1,31 @@ -/** -* ... -* @author Default -* @version 0.1 +/* +Copyright 2007 by the authors of asapframework + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + package org.asapframework.ui.buttons { - import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; - import flash.display.FrameLabel; - - import org.asapframework.util.debug.Log; + import org.asapframework.util.FramePulse; - public class HilightButton extends BaseButton { - private static var LABEL_UP:String = "up"; - private static var LABEL_OVER:String = "over"; - private static var LABEL_ON:String = "on"; - private static var LABEL_OUT:String = "out"; - + private static var LABEL_UP : String = "up"; + private static var LABEL_OVER : String = "over"; + private static var LABEL_ON : String = "on"; + private static var LABEL_OUT : String = "out"; private var mForceHilight : Boolean; private var mIsAnimating : Boolean; private var mDoOutAnimation : Boolean; @@ -27,8 +33,8 @@ /** - * Constructor - */ + * Constructor + */ public function HilightButton () { super(); @@ -36,51 +42,51 @@ addEventListener(MouseEvent.ROLL_OVER, handleRollOver); addEventListener(MouseEvent.ROLL_OUT, handleRollOut); } - + /** - * True if the current frame is the hilight frame - */ + * True if the current frame is the hilight frame + */ public function get isLit () : Boolean { return (currentLabel == LABEL_ON); } - + /** - * Go to hilight frame - * @param inAnimate: if true, change will be animated, otherwise immediate - */ - public function hilight (inAnimate:Boolean = false) : void { + * Go to hilight frame + * @param inAnimate: if true, change will be animated, otherwise immediate + */ + public function hilight (inAnimate : Boolean = false) : void { mForceHilight = true; mForceHilightAnimate = inAnimate; if (!inAnimate) gotoAndStop(LABEL_ON); else handleRollOver(); } - + /** - * Go directly to the "up" frame - * @param inAnimate: if true, change will be animated, otherwise immediate - */ - public function unHilight (inAnimate:Boolean = false) : void { + * Go directly to the "up" frame + * @param inAnimate: if true, change will be animated, otherwise immediate + */ + public function unHilight (inAnimate : Boolean = false) : void { if (!inAnimate) gotoAndStop(LABEL_UP); else handleRollOut(); } - + /** - * Handle internal event that instance has been added to the stage - * @param e - * @return - */ - private function handleAdded (e:Event) : void { + * Handle internal event that instance has been added to the stage + * @param e + * @return + */ + private function handleAdded (e : Event) : void { if (mForceHilight) { mForceHilight = false; hilight(mForceHilightAnimate); } } - + /** - * Handle rollover event. - */ - private function handleRollOver (e:MouseEvent = null) : void { + * Handle rollover event. + */ + private function handleRollOver (e : MouseEvent = null) : void { gotoAndPlay(LABEL_OVER); mIsAnimating = true; @@ -89,12 +95,12 @@ } /** - * Handle rollout event - * @param e - * @return - */ - private function handleRollOut (e:MouseEvent = null) : void { - if (mIsAnimating){ + * Handle rollout event + * @param e + * @return + */ + private function handleRollOut (e : MouseEvent = null) : void { + if (mIsAnimating) { mDoOutAnimation = true; } else { gotoAndPlay(LABEL_OUT); @@ -102,14 +108,14 @@ } /** - * enterFrame handler that checks if animation has to continue - */ - private function checkAnimation (e:Event) : void { + * enterFrame handler that checks if animation has to continue + */ + private function checkAnimation (e : Event) : void { if (currentLabel == LABEL_ON) { mIsAnimating = false; FramePulse.removeEnterFrameListener(checkAnimation); - if (mDoOutAnimation){ + if (mDoOutAnimation) { handleRollOut(); } else { stop(); @@ -121,5 +127,4 @@ return ";org.asapframework.ui.buttons.HilightButton"; } } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-09-03 10:20:27
|
Revision: 713 http://asapframework.svn.sourceforge.net/asapframework/?rev=713&view=rev Author: acidcats Date: 2007-09-03 01:04:18 -0700 (Mon, 03 Sep 2007) Log Message: ----------- Removed unneeded class Removed Paths: ------------- branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as Deleted: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as 2007-09-03 08:03:47 UTC (rev 712) +++ branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as 2007-09-03 08:04:18 UTC (rev 713) @@ -1,24 +0,0 @@ -/** -* ... -* @author Default -* @version 0.1 -*/ - -package org.asapframework.ui.buttons { - import flash.events.Event; - - public class ButtonEvent extends Event { - public static const CLICK:String = "buttonclick"; - public static const ROLLOVER:String = "rollover"; - public static const ROLLOUT:String = "rollout"; - - public var name:String; - - public function ButtonEvent (inType:String, inName:String) { - super(inType, true); - - name = inName; - } - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-09-03 09:00:05
|
Revision: 712 http://asapframework.svn.sourceforge.net/asapframework/?rev=712&view=rev Author: acidcats Date: 2007-09-03 01:03:47 -0700 (Mon, 03 Sep 2007) Log Message: ----------- New button classes Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/ui/ branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as Added: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as 2007-09-03 08:03:47 UTC (rev 712) @@ -0,0 +1,34 @@ +/** +* ... +* @author Default +* @version 0.1 +*/ + +package org.asapframework.ui.buttons { + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class BaseButton extends MovieClip { + public var hitArea_mc:MovieClip; + + /** + * Constructor + */ + public function BaseButton () { + // act as button + buttonMode = true; + + // set and hide hit area + hitArea = hitArea_mc; + hitArea_mc.visible = false; + + // don't handle mouse events on children + mouseChildren = false; + } + + override public function toString () : String { + return ";org.asapframework.ui.buttons.BaseButton"; + } + } + +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/BaseButton.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as 2007-09-03 08:03:47 UTC (rev 712) @@ -0,0 +1,24 @@ +/** +* ... +* @author Default +* @version 0.1 +*/ + +package org.asapframework.ui.buttons { + import flash.events.Event; + + public class ButtonEvent extends Event { + public static const CLICK:String = "buttonclick"; + public static const ROLLOVER:String = "rollover"; + public static const ROLLOUT:String = "rollout"; + + public var name:String; + + public function ButtonEvent (inType:String, inName:String) { + super(inType, true); + + name = inName; + } + } + +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/ButtonEvent.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as 2007-09-03 08:03:47 UTC (rev 712) @@ -0,0 +1,125 @@ +/** +* ... +* @author Default +* @version 0.1 +*/ + +package org.asapframework.ui.buttons { + import flash.display.MovieClip; + import flash.events.Event; + import flash.events.MouseEvent; + import flash.display.FrameLabel; + + import org.asapframework.util.debug.Log; + import org.asapframework.util.FramePulse; + + + public class HilightButton extends BaseButton { + private static var LABEL_UP:String = "up"; + private static var LABEL_OVER:String = "over"; + private static var LABEL_ON:String = "on"; + private static var LABEL_OUT:String = "out"; + + private var mForceHilight : Boolean; + private var mIsAnimating : Boolean; + private var mDoOutAnimation : Boolean; + private var mForceHilightAnimate : Boolean; + + + /** + * Constructor + */ + public function HilightButton () { + super(); + + addEventListener(Event.ADDED, handleAdded); + addEventListener(MouseEvent.ROLL_OVER, handleRollOver); + addEventListener(MouseEvent.ROLL_OUT, handleRollOut); + } + + /** + * True if the current frame is the hilight frame + */ + public function get isLit () : Boolean { + return (currentLabel == LABEL_ON); + } + + /** + * Go to hilight frame + * @param inAnimate: if true, change will be animated, otherwise immediate + */ + public function hilight (inAnimate:Boolean = false) : void { + mForceHilight = true; + mForceHilightAnimate = inAnimate; + + if (!inAnimate) gotoAndStop(LABEL_ON); + else handleRollOver(); + } + + /** + * Go directly to the "up" frame + * @param inAnimate: if true, change will be animated, otherwise immediate + */ + public function unHilight (inAnimate:Boolean = false) : void { + if (!inAnimate) gotoAndStop(LABEL_UP); + else handleRollOut(); + } + + /** + * Handle internal event that instance has been added to the stage + * @param e + * @return + */ + private function handleAdded (e:Event) : void { + if (mForceHilight) { + mForceHilight = false; + hilight(mForceHilightAnimate); + } + } + + /** + * Handle rollover event. + */ + private function handleRollOver (e:MouseEvent = null) : void { + gotoAndPlay(LABEL_OVER); + + mIsAnimating = true; + mDoOutAnimation = false; + FramePulse.addEnterFrameListener(checkAnimation); + } + + /** + * Handle rollout event + * @param e + * @return + */ + private function handleRollOut (e:MouseEvent = null) : void { + if (mIsAnimating){ + mDoOutAnimation = true; + } else { + gotoAndPlay(LABEL_OUT); + } + } + + /** + * enterFrame handler that checks if animation has to continue + */ + private function checkAnimation (e:Event) : void { + if (currentLabel == LABEL_ON) { + mIsAnimating = false; + FramePulse.removeEnterFrameListener(checkAnimation); + + if (mDoOutAnimation){ + handleRollOut(); + } else { + stop(); + } + } + } + + override public function toString () : String { + return ";org.asapframework.ui.buttons.HilightButton"; + } + } + +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/ui/buttons/HilightButton.as ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-08-29 14:16:56
|
Revision: 711 http://asapframework.svn.sourceforge.net/asapframework/?rev=711&view=rev Author: acidcats Date: 2007-08-29 07:16:53 -0700 (Wed, 29 Aug 2007) Log Message: ----------- Ported LanguageManager to AS3 Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as Added: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as 2007-08-29 14:16:53 UTC (rev 711) @@ -0,0 +1,41 @@ +/* +Copyright 2007 by the authors of asapframework, http://asapframework.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** +Interface to be implemented by any class that wishes to add itself to the LanguageManager. +This interface provides two functions that the LanguageManager expects. +*/ + +package org.asapframework.management.lang { + import org.asapframework.management.lang.TextItemData; + + public interface IMultiLanguageTextContainer { + /** + * Set the data for the container + * @param inData: the object containing the data + */ + function setData (inData:TextItemData) : void; + + /** + * Set the text for the container + * Utility function, not used by the LanguageManager + * @param inText: the string containing the text + * @param inIsHTML: if true, text is rendered as HTML, otherwise directly + */ + function setText (inText:String, inIsHTML:Boolean = true) : void; + } + +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/IMultiLanguageTextContainer.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as 2007-08-29 14:16:53 UTC (rev 711) @@ -0,0 +1,342 @@ +/* +Copyright 2007 by the authors of asapframework, http://asapframework.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** +Class for managing language dependencies in an application. +For text, the language dependent texts are expected to be in an xml per language, with the following structure: +<code> +<texts> + <text id="1">Hello World</text> + <text id="2"><[!CDATA[<b>Hello</b> World with bold Hello]]></text> + <text id="3" html="false"><[!CDATA[<b>Hello</b> World with visible html tags]]></text> + <text id="4"><[!CDATA[>>>Hello World<<<]]></text> +</texts> +</code> +The 'id' attribute is mandatory, and has to be a number. +The 'html' attribute is optional. If left out, text is rendered as HTML text; any other value than "false" is seen as true. When false, the text is set directly into the text field, and any html tags are ignored. +In case the text contains xml characters, the text has to be wrapped in a {@code <![CDATA[[]]>} tag. +The id is expected to be unique. When it isn't, the last item is taken. + +The xml file containing the language dependent texts has to be loaded with the method {@link #loadXML}. +When loaded and parsed, the LanguageManager sends an event of type LanguageManager.EVENT_LOADED. Subscribe to this event if you wish to be notified. +No event is sent when the loading fails, only a Log message of level ERROR is output. + +Once an xml file has been loaded, data is available by id through {@link #getTextByID} and {@link #getDataByID}. Since the LanguageManager is a Singleton, the language dependent data is available throughout your application. + +However, the LanguageManager also contains a mechanism for automatic assignment of data. To use this functionality, use the provided class {@link MultiLanguageTextContainer}, or write your own implementation of {@link IMultiLanguageTextContainer}. +When writing your own class, allow for a way to determine the id of the text that is to be used by a specific instance for your class. In case of the MultiLanguageTextContainer class, this id is retrieved from the name of the movieclip instance to which the class is linked, by taking everything after the last underscore and converting to a number. So "myText_1" gets the text with id=1. +Once the id is known inside your class, add the instance to the LanguageManager with {@link #addContainer}, providing the id and the instance itself as parameters. If data has been loaded, it is provided to the instance immediately. Whenever new data is loaded, the LanguageManager calls "setData" on each instance that was added, thereby updating language dependent text instantaneously. +A good spot to add an instance to the LanguageManager is when Event.ADDED is received. Make sure to remove it again when Event.REMOVED is received, to allow for proper memory management. This also makes sure that the instance keeps its text when subject to animation key frames. +Instances can share the same id, and thereby have the same text. + +By default, the LanguageManager returns an empty string (or provides an empty string in the data) when a requested id is not found. +This has two drawbacks: +<ul><li>The textfield becomes effectively invisible since there is no text in it</li> +<li>Formatting of the textfield (such as weight or alignment) may be lost when the textfield is cleared</li></ul> +To allow for easier debugging, the flag {@link #generateDebugText} can be set. If an unknown id is requested, the returned text will be ">> id = #id", where #id is replaced with the actually requested id. This makes it easier to find missing texts from the xml files. + +@example +<ul> +<li>Loading an xml file into the LanguageManager, specifying a language code to be used in determining the name of the xml file to be loaded. +<code> +// @param inCode: 2-letter ISO language code; will be added to filename. Example: with parameter "en" the file "texts_en.xml" will be loaded. +private function loadLanguage (inCode:String) : void { + var lm:LanguageManager = LanguageManager.getInstance(); + lm.addEventListener(LanguageManager.EVENT_LOADED, handleLanguageLoaded); + lm.loadXML("../xml/texts_" + inCode + ".xml"); +} + +private function handleLanguageLoaded () : Void { + Log.debug("handleLanguageLoaded: Language file loaded.", toString()); +} +</code> +</li> + +<li>Assigning a text to a textfield manually from anywhere in your code: +<code>myTextfield.text = LanguageManager.getInstance().getTextByID(23);</code> +</li> + +<li>A class that gets a random text from the first 10 texts of the LanguageManager each time it is loaded: +<code> +class MyText extends MovieClip implements IMultiLanguageTextContainer { + private var mID:Number; + private var myTextField:TextField; + + public function MyText () { + addEventListener(Event.ADDED, handleAdded); + addEventListener(Event.REMOVED, handleRemoved); + } + + public function setData (inData : TextItemData) : Void { + setText(inData.text, inData.isHTML); + } + + public function setText (inText:String, inIsHTML:Boolean = true) : Void { + if (inIsHTML) tf_txt.htmlText = inText; + else tf_txt.text = inText; + } + + private function handleAdded (e:Event) : Void { + mID = Math.floor(10 * Math.random()); + + LanguageManager.getInstance().addContainer(mID, this); + } + + private function handleRemoved (e:Event) : Void { + LanguageManager.getInstance().removeContainer(this); + } +} +</code> +</li> +</ul> +*/ + +package org.asapframework.management.lang { + import flash.events.Event; + import flash.events.EventDispatcher; + + import org.asapframework.data.xml.*; + import org.asapframework.util.debug.Log; + + + public class LanguageManager extends EventDispatcher { + /** The event sent when the language xml has been loaded and parsed */ + public static const EVENT_LOADED:String = "onLanguageLoaded"; + + /** name of XML while loading */ + private static const XML_NAME:String = "languagexml"; + + /** objects of type TextItemData */ + private var mTextDataItems:Array; + /** objects of type MultiLanguageContainerData */ + private var mTextClips:Array; + + private var mXMLLoader:XMLLoader; + private var mGenerateDebugText:Boolean = false; + + private var mURL : String; + + // singleton instance + private static var mInstance : LanguageManager = null; + private static var mIsCreating : Boolean = false; + + /** + @return The singleton instance of the LanguageManager + */ + public static function getInstance () : LanguageManager { + if (mInstance == null) { + mIsCreating = true; + mInstance = new LanguageManager(); + mIsCreating = false; + } + return mInstance; + } + + /** + * Load language XML + * @param inURL: full path of the xml file to be loaded + */ + public function loadXML (inURL:String) : void { + mURL = inURL; + + // start loading + mXMLLoader.loadXML(inURL,LanguageManager.XML_NAME); + } + + /** + * Flag indicates whether items show their id as text when no text is found in the xml. When false, an empty string is returned when no text is found. + */ + public function set generateDebugText (inGenerate:Boolean) : void { + mGenerateDebugText = inGenerate; + } + + /** + * Add a multi-laguage container to the LanguageManager. + * If data has been loaded, the container will receive its data immediately. + * If the container had been added already, it will not be added again. + * @param inID: the id to be associated with the container + * @param inContainer: instance of a class implementing {@link IMultiLanguageTextContainer} + */ + public function addContainer (inID:uint, inContainer:IMultiLanguageTextContainer) : void { + if (getClipDataByContainer(inContainer) == null) { + var mlcd:MultiLanguageContainerData = new MultiLanguageContainerData(inID, inContainer); + mTextClips.push(mlcd); + } + inContainer.setData(getDataByID(inID)); + } + + /** + * Remove a multi-language container from the LanguageManager + * @param inContainer: previously added instance of a class implementing {@link IMultiLanguageTextContainer} + */ + public function removeContainer (inContainer:IMultiLanguageTextContainer) : void { + var index:uint = getClipDataIndexByContainer(inContainer); + if (!isNaN(index)) { + mTextClips.splice(index, 1); + } + } + + /** + * Add text for a specific ID to the language manager. + * Set the text in any IMultiLanguageTextContainer instance associated with that id. + * @param inData: {@link TextItemData} instance containing necessary data. + */ + public function addText (inData:TextItemData) : void { + // store item at location of id + mTextDataItems[inData.id] = inData; + + var len:uint = mTextClips.length; + for (var i:uint = 0; i < len; ++i) { + var md:MultiLanguageContainerData = MultiLanguageContainerData(mTextClips[i]); + if (md.id == inData.id) { + md.container.setData(inData); + } + } + } + + /** + * Retrieve a text + * @param inID: the id for the text to be found + * @return the text if found, an empty string if generateDebugText is set to false, or '>> id = ' + id if generateDebugText is set to true + */ + public function getTextByID (inID:uint) : String { + return getDataByID(inID).text; + } + + /** + * Retrieve text data + * @param inID: the id for the text to be found + * @return the text data with the right text if found, with an empty string if generateDebugText is set to false, or with '>> id = ' + id if generateDebugText is set to true + */ + public function getDataByID (inID:uint) : TextItemData { + if (mTextDataItems[inID] == undefined) { + if (mGenerateDebugText) { + return new TextItemData(inID, ">> id = " + inID); + } else { + return new TextItemData(inID, ""); + } + } else { + return TextItemData(mTextDataItems[inID]); + } + } + + /** + * Find the data block for the specified {@link IMultiLanguageTextContainer} instance + * @return the data block for the clip, or null if none was found + */ + private function getClipDataByContainer (inContainer:IMultiLanguageTextContainer) : MultiLanguageContainerData { + var len:uint = mTextClips.length; + for (var i:uint = 0; i < len; ++i) { + var md:MultiLanguageContainerData = MultiLanguageContainerData(mTextClips[i]); + if (md.container == inContainer) return md; + } + return null; + } + + /** + * Find the index of the data block for the specified {@link IMultiLanguageTextContainer} instance + * @return the index of the data block, or NaN if none was found + */ + private function getClipDataIndexByContainer (inContainer:IMultiLanguageTextContainer) : uint { + var len:uint = mTextClips.length; + for (var i:uint = 0; i < len; ++i) { + var md:MultiLanguageContainerData = MultiLanguageContainerData(mTextClips[i]); + if (md.container == inContainer) return i; + } + return NaN; + } + + /** + * Handle event from XMLLoader + * @param e + */ + private function handleXMLLoaded (e:XMLLoaderEvent) : void { + if (e.name != XML_NAME) return; + + switch (e.subtype) { + case XMLLoaderEvent.COMPLETE: handleLanguageDataLoaded(e); break; + case XMLLoaderEvent.ERROR: handleXMLLoadError(e); break; + } + } + + /** + * Handle event from XMLLoader that data has been loaded successfully + * @param e + */ + private function handleLanguageDataLoaded (e:XMLLoaderEvent) : void { + // parse XML into TextItemData objects + var items:Array = Parser.parseList(e.data.text, org.asapframework.management.lang.TextItemData); + + // add the items + var len:uint = items.length; + for (var i:uint = 0; i < len; i++) { + addText(items[i]); + } + + // send event we're done + dispatchEvent(new Event(EVENT_LOADED)); + } + + /** + * Handle event from XMLLoader that there was an error loading the data + * @param e + */ + private function handleXMLLoadError (e:XMLLoaderEvent) : void { + Log.error("Could not load language XML from url " + mURL + ", error = " + e.error, toString()); + } + + /** + * singleton constructor. Do not use externally. + */ + public function LanguageManager() { + // check if constructor was called internally + if (!mIsCreating) throw new Error("Do not use the constructor of this class!" + toString()); + + mXMLLoader = new XMLLoader(); + mXMLLoader.addEventListener(XMLLoaderEvent._EVENT, handleXMLLoaded); + + mTextDataItems = new Array(); + mTextClips = new Array(); + } + + override public function toString () : String { + return ";org.asapframework.management.lang.LanguageManager"; + } + + } + +} + +/** +* Helper class for storing information about IMultiLanguageTextContainer vs. ID +*/ +import org.asapframework.management.lang.IMultiLanguageTextContainer; + +class MultiLanguageContainerData { + + public var id:uint; + public var container:IMultiLanguageTextContainer; + + /** + Constructor + @param inID: the id of the text assigned to the container + @param inContainer: instance of a class implementing {@link IMultiLanguageTextContainer} + */ + public function MultiLanguageContainerData (inID:uint, inContainer:IMultiLanguageTextContainer) { + id = inID; + container = inContainer; + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/LanguageManager.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as 2007-08-29 14:16:53 UTC (rev 711) @@ -0,0 +1,97 @@ +/* +Copyright 2007 by the authors of asapframework, http://asapframework.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** +Basic implementation of {@link IMultiLanguageTextContainer} to be used with the {@link LanguageManager} to provide language dependent texts in an application. + +To use this class, perform the following steps: +<ol> +<li>Create a new movieclip in the library</li> +<li>Give it a significant name containing font information, p.e. "arial 11px center"; this allows for easy reuse of containers</li> +<li>Link it to the class org.asapframework.management.lang.MultiLanguageTextContainer</li> +<li>Inside the movieclip, create a dynamic textfield. Name it "tf_txt"</li> +<li>Set font embedding as necessary</li> +<li>Place instances of the library item on the stage where necessary.</li> +<li>Name the instances whatever you like, as long as the name ends with underscore, followed by the integer id of the text to be associated with the instance. P.e.: "helloWorld_1"</li> +<li>In your application, load an xml file containing texts into the LanguageManager: <code>LanguageManager.getInstance().loadXML("texts_en.xml");</code></li> +</ol> + +This class can be used either +<ul><li>directly,</li> +<li>as base class for further extension or </li> +<li>as example of how to implement the {@link IMultiLanguageTextContainer} interface.</li></ul> +*/ + + +package org.asapframework.management.lang { + import flash.display.MovieClip; + import flash.text.TextField; + import flash.events.Event; + + import org.asapframework.util.debug.Log; + + + public class MultiLanguageTextContainer extends MovieClip implements IMultiLanguageTextContainer { + public var tf_txt:TextField; + + public function MultiLanguageTextContainer () { + addEventListener(Event.ADDED, handleAdded); + addEventListener(Event.REMOVED, handleRemoved); + } + + /** + * IMultiLanguageTextContainer implementation + * Set the data for the container + * @param inData: the object containing the data + */ + public function setData (inData : TextItemData) : void { + setText(inData.text, inData.isHTML); + } + + /** + * IMultiLanguageTextContainer implementation + * Set the text for the container + * @param inText: the string containing the text + * @param inIsHTML: if true, text is rendered as HTML, otherwise directly + */ + public function setText (inText:String, inIsHTML:Boolean = true) : void { + if (inIsHTML) tf_txt.htmlText = inText; + else tf_txt.text = inText; + } + + /** + * Handle internal event that instance has been added to the stage + * @param e + */ + private function handleAdded (e:Event) : void { + var id:uint = parseInt(name.substring(name.lastIndexOf("_")+1), 10); + + LanguageManager.getInstance().addContainer(id, this); + } + + /** + * Handle internal event that instance has been removed from the stage + * @param e + */ + private function handleRemoved (e:Event) : void { + LanguageManager.getInstance().removeContainer(this); + } + + override public function toString() : String { + return ";org.asapframework.management.lang.MultiLanguageTextContainer"; + } + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/MultiLanguageTextContainer.as ___________________________________________________________________ Name: svn:eol-style + native Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as 2007-08-29 14:16:13 UTC (rev 710) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as 2007-08-29 14:16:53 UTC (rev 711) @@ -1,28 +1,60 @@ +/* +Copyright 2007 by the authors of asapframework, http://asapframework.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + /** -* ... -* @author Default -* @version 0.1 +ValueObject class that holds data for a text item. +Classes that implement {@link IMultiLanguageTextContainer} get this type of data from the LanguageManager. +Basic info contained in this class is the text and the id by which it is referenced. */ package org.asapframework.management.lang { import org.asapframework.data.xml.IParsable; + import org.asapframework.util.debug.Log; public class TextItemData implements IParsable { public var text:String; - public var id:Number; + public var id:uint; + public var isHTML:Boolean = true; /** - + Constructor + @param inID: unique id of item + @param inText: text for item */ - public function ItemData (inID:Number, inText:String) { + public function TextItemData (inID:uint = 0, inText:String = null) { id = inID; text = inText; } + /** + * Parse specified XML data into member variables + * @param o: XML object to be parsed + * @return true if parsing went ok, otherwise false + */ public function parseXML (o:XML) : Boolean { - id = o.@id; - text = o; + id = parseInt(o.@id, 10); + isHTML = o.@html != "false"; + text = o.toString(); + + return true; } + + public function toString () : String { + return "org.asapframework.management.lang.TextItemData"; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-08-29 14:16:30
|
Revision: 710 http://asapframework.svn.sourceforge.net/asapframework/?rev=710&view=rev Author: acidcats Date: 2007-08-29 07:16:13 -0700 (Wed, 29 Aug 2007) Log Message: ----------- Typing fix Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-08-29 14:15:39 UTC (rev 709) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-08-29 14:16:13 UTC (rev 710) @@ -107,7 +107,7 @@ } - private function handleLoadStarted (e:Event) { + private function handleLoadStarted (e:Event) : void { // get loader var info:LoaderInfo = e.target as LoaderInfo; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-08-29 14:15:37
|
Revision: 709 http://asapframework.svn.sourceforge.net/asapframework/?rev=709&view=rev Author: acidcats Date: 2007-08-29 07:15:39 -0700 (Wed, 29 Aug 2007) Log Message: ----------- Typing fix Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as 2007-08-21 23:51:35 UTC (rev 708) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as 2007-08-29 14:15:39 UTC (rev 709) @@ -1,4 +1,4 @@ - + package org.asapframework.data.xml { import flash.events.Event; import flash.events.IOErrorEvent; @@ -122,7 +122,7 @@ * Handle ProgressEvent from URLLoader * @param e: ProgressEvent sent */ - private function handleURLLoaderProgressEvent (e:ProgressEvent) { + private function handleURLLoaderProgressEvent (e:ProgressEvent) : void { // get loader var loader:URLLoader = e.target as URLLoader; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-25 20:35:15
|
Revision: 705 http://svn.sourceforge.net/asapframework/?rev=705&view=rev Author: acidcats Date: 2007-06-25 13:35:11 -0700 (Mon, 25 Jun 2007) Log Message: ----------- Updated ActionQueue classes & tests to conform AS3 strict compilation, most tests now run Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueue.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueuePerformData.as branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj branches/dev_as3/asapframework/test/unit/AllTests.as branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as branches/dev_as3/asapframework/test/unit/Tester.fla branches/dev_as3/asapframework/test/unit/Tester.swf branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/actionqueue/ActionQueueTestCase.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as 2007-06-24 19:49:07 UTC (rev 704) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as 2007-06-25 20:35:11 UTC (rev 705) @@ -1,70 +1,70 @@ -/* -Copyright 2005-2006 by the authors of asapframework, http://asapframework.org - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package org.asapframework.util.actionqueue { - - import flash.display.DisplayObject; - - import org.asapframework.util.actionqueue.*; - - /** - ActionQueue method that controls the alpha blend of a movieclip. - See also {@link AQPulse} to fade a movieclip in a pulsating manner. - @author Arthur Clemens - */ - - class AQFade { - - private static var START_VALUE:Number = 1; /**< Start animation value to be returned to the perform function. */ - private static var END_VALUE:Number = 0; /**< End animation value to be returned to the perform function. */ - - /** - @param inMC : movieclip to fade - @param inDuration : length of animation in seconds; 0 is used for perpetual animations - use -1 for instant change - @param inStartAlpha : value to start fading from; if null then inMC's current alpha value is used - @param inEndAlpha : value to start fading to; if null then inMC's current alpha value is used - @param inEffect : (optional) An effect function, for instance one of the mx.transitions.easing methods. Arguments to pass the effect function may be appended as a comma-separated list. - @return A new ActionQueuePerformData object. - @example - This example fades in a movieclip from its current alpha to 100 in 2 seconds: - <code> - queue.addAction( AQFade.fade, my_mc, 2, null, 100, Regular.easeIn ); - </code> - */ - public static function fade (inMC:DisplayObject, - inDuration:Number, - inStartAlpha:* = null, - inEndAlpha:* = null, - inEffect:Function = undefined) : ActionQueuePerformData { - - // get effect parameters that are optionally passed after inEffect - var effectParams:Array = arguments.splice(5, arguments.length - 5); - - var startAlpha:Number = (inStartAlpha != null) ? inStartAlpha : inMC.alpha; - var endAlpha:Number = (inEndAlpha != null) ? inEndAlpha : inMC.alpha; - - var renda:Number, changea:Number; - - var performFunction:Function = function (inPerc:Number) : void { - // inPerc = percentage counting down from {@link #END_VALUE} to {@link #START_VALUE} - renda = (endAlpha == null ? inMC.alpha : endAlpha); - changea = endAlpha - startAlpha; - inMC.alpha = renda - (inPerc * changea); - }; - return new ActionQueuePerformData(performFunction, inDuration, START_VALUE, END_VALUE, inEffect, effectParams); - } - } +/* +Copyright 2005-2006 by the authors of asapframework, http://asapframework.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.asapframework.util.actionqueue { + + import flash.display.DisplayObject; + + import org.asapframework.util.actionqueue.*; + + /** + ActionQueue method that controls the alpha blend of a movieclip. + See also {@link AQPulse} to fade a movieclip in a pulsating manner. + @author Arthur Clemens + */ + + class AQFade { + + private static var START_VALUE:Number = 1; /**< Start animation value to be returned to the perform function. */ + private static var END_VALUE:Number = 0; /**< End animation value to be returned to the perform function. */ + + /** + @param inMC : movieclip to fade + @param inDuration : length of animation in seconds; 0 is used for perpetual animations - use -1 for instant change + @param inStartAlpha : value to start fading from; if null then inMC's current alpha value is used + @param inEndAlpha : value to start fading to; if null then inMC's current alpha value is used + @param inEffect : (optional) An effect function, for instance one of the mx.transitions.easing methods. Arguments to pass the effect function may be appended as a comma-separated list. + @return A new ActionQueuePerformData object. + @example + This example fades in a movieclip from its current alpha to 100 in 2 seconds: + <code> + queue.addAction( AQFade.fade, my_mc, 2, null, 100, Regular.easeIn ); + </code> + */ + public static function fade (inMC:DisplayObject, + inDuration:Number, + inStartAlpha:Number = Number.NaN, + inEndAlpha:Number = Number.NaN, + inEffect:Function = null) : ActionQueuePerformData { + + // get effect parameters that are optionally passed after inEffect + var effectParams:Array = arguments.splice(5, arguments.length - 5); + + var startAlpha:Number = !isNaN(inStartAlpha) ? inStartAlpha : inMC.alpha; + var endAlpha:Number = !isNaN(inEndAlpha) ? inEndAlpha : inMC.alpha; + + var renda:Number, changea:Number; + + var performFunction:Function = function (inPerc:Number) : void { + // inPerc = percentage counting down from {@link #END_VALUE} to {@link #START_VALUE} + renda = (isNaN(endAlpha) ? inMC.alpha : endAlpha); + changea = endAlpha - startAlpha; + inMC.alpha = renda - (inPerc * changea); + }; + return new ActionQueuePerformData(performFunction, inDuration, START_VALUE, END_VALUE, inEffect, effectParams); + } + } } \ No newline at end of file Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as 2007-06-24 19:49:07 UTC (rev 704) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as 2007-06-25 20:35:11 UTC (rev 705) @@ -104,12 +104,12 @@ */ public static function followMouse (inMC:DisplayObject, - inDuration:Number = undefined, - inTimeDiv:Number = undefined, - inLocDiv:Number = undefined, - inOffset:Point = undefined, - inCallbackObject:Object = undefined, - inCallBackMethod:Object = undefined) : ActionQueuePerformData { + inDuration:Number = Number.NaN, + inTimeDiv:Number = Number.NaN, + inLocDiv:Number = Number.NaN, + inOffset:Point = null, + inCallbackObject:Object = null, + inCallBackMethod:Object = null) : ActionQueuePerformData { var duration:Number = !isNaN(inDuration) ? inDuration * 1000 : 0; var endTime:Number = getTimer() + duration; @@ -125,10 +125,10 @@ var offsetY:Number = (inOffset != null) ? inOffset.y : 0; var callbackMethod:Function = null; - if (typeof inCallBackMethod == "string") { + if (inCallBackMethod is String) { callbackMethod = inCallbackObject[inCallBackMethod]; } - if (typeof inCallBackMethod == "function") { + if (inCallBackMethod is Function) { callbackMethod = Function(inCallBackMethod); } @@ -147,7 +147,7 @@ inMC.x = point.x; inMC.y = point.y; } - var draw:Function = (callbackMethod != undefined) ? drawCallback : drawMove; + var draw:Function = (callbackMethod != null) ? drawCallback : drawMove; return new ActionQueuePerformData(draw, duration); } } Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as 2007-06-24 19:49:07 UTC (rev 704) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as 2007-06-25 20:35:11 UTC (rev 705) @@ -47,17 +47,17 @@ */ public static function move (inMC:DisplayObject, inDuration:Number, - inStartX:* = null, - inStartY:* = null, - inEndX:* = null, - inEndY:* = null, + inStartX:Number = Number.NaN, + inStartY:Number = Number.NaN, + inEndX:Number = Number.NaN, + inEndY:Number = Number.NaN, inEffect:Function = undefined) : ActionQueuePerformData { // get effect parameters that are optionally passed after inEffect var effectParams:Array = arguments.splice(7, arguments.length - 7); - var startX:Number = (inStartX != null) ? inStartX : inMC.x; - var startY:Number = (inStartY != null) ? inStartY : inMC.y; + var startX:Number = !isNaN(inStartX) ? inStartX : inMC.x; + var startY:Number = !isNaN(inStartY) ? inStartY : inMC.y; // don't use endX and endY here, but use a relative end position, // to make it possible that another function changes the end value in the meantime @@ -65,8 +65,8 @@ var performFunction:Function = function (inPerc:Number) { // inPerc = percentage counting down from {@link #END_VALUE} to {@link #START_VALUE} - rendx = (inEndX != null ? inEndX : inMC.x); - rendy = (inEndY != null ? inEndY : inMC.y); + rendx = !isNaN(inEndX) ? inEndX : inMC.x; + rendy = !isNaN(inEndY) ? inEndY : inMC.y; changex = rendx - startX; changey = rendy - startY; inMC.x = rendx - (inPerc * changex); Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueue.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueue.as 2007-06-24 19:49:07 UTC (rev 704) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueue.as 2007-06-25 20:35:11 UTC (rev 705) @@ -1,1065 +1,1010 @@ -/* -Copyright 2005-2006 by the authors of asapframework, http://asapframework.org - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package org.asapframework.util.actionqueue { - - import flash.events.EventDispatcher; - - import org.asapframework.util.actionqueue.ActionQueueData; - import org.asapframework.util.actionqueue.ActionQueueEvent; - import org.asapframework.util.actionqueue.ActionQueuePerformData; - import org.asapframework.util.actionqueue.AQWorker; - //import org.asapframework.util.debug.Log; - import org.asapframework.util.framepulse.FramePulse; - import org.asapframework.util.framepulse.FramePulseEvent; - - /** - Scripted animation and function flow class. ActionQueue stores and runs a series of functions/methods one after the other. You can call local functions, object methods and special movieclip control methods, such as timed "fade", "move" or "pulse" functions. - ActionQueue is handy when you need timed animation, state transitions, complex button behavior or a series of functions that need to wait for a certain condition before they are run. You can insert waiting for messages or variable conditions (see {@link ExtendedActionQueue}). - The most common use for ActionQueue is to manipulate movieclips. - - <b>Adding actions to the queue</b> - {@link #addAction} (<code>myFunction</code>) : Adds a (locally scoped) function or an anonymous function. - {@link #addAction} (<code>myObj, myMethod</code>) : Adds an object's method. - {@link #addAction} (<code>myObj, myMethodName</code>) : Adds an object's method by using the method's name. The object's method does not have to be known at the time that it is added to the queue. - {@link #addAction} (<code>myAQAction</code>) : Adds a custom movieclip action from one of the AQxxx classes; use fade, scale, move, etcetera. See the list of available action methods at addAction, or create your own action method. - {@link #addInAction}: As addAction, but in a separately spawned thread; this eliminates the need to create separate methods and queues for movieclip actions that should occur at the same time. - - See also the method list summary. - - <b>On effects</b> - ActionQueue 'AQ' methods such as {@link AQScale#scale} may use Flash' easing effects from mx.transitions.easing. You can use the default mx.transitions.easing effects, or define your own. - - Example with mx.transitions.easing.Elastic: - <code> - import mx.transitions.easing.*; - queue.addAction( AQScale.scale, my_mc, 1, null, null, 100, 100, Elastic.easeIn ); - </code> - - <b>Advanced Queue functions</b> - To use conditional messages, conditions and looping, use {@link ExtendedActionQueue}. - - <b>Simultaneous effects</b> - To control different movieclip aspects at the same time, for instance to move a clip and fade it out, use {@link #addInAction}, or use {@link AQReturnValue} (example given below at {@link #addAction}). - - @author Arthur Clemens - @use - This code example demonstrates a combination of ActionQueue methods, to give an idea of how this class can be used in an application. - <code> - import org.asapframework.util.actionqueue.*; - import mx.transitions.easing.*; - </code> - Create the ActionQueue instance: - <code> - var queue:ActionQueue = new ActionQueue(); - </code> - With addAction you can use methods from AQSet to set properties of movieclips: - <code> - queue.addAction( AQSet.setAlpha, circle_mc, 75 ); - queue.addAction( AQSet.centerOnStage, circle_mc ); - queue.addAction( AQMove.move, circle_mc, 4, null, null, 0, 0, Bounce.easeInOut); - </code> - To add a pause, use <code>addPause(number of seconds)</code>, where 0 means wait forever - indefinite pauses can be terminated by {@link #skip}, {@link ExtendedActionQueue#addContinueOnMessage} and {@link ExtendedActionQueue#addContinueOnCondition}. - <code> - queue.addPause( 0.5 ); - queue.addAction( AQFade.fade, circle_mc, 2, null, 100, Regular.easeIn ); - </code> - All actions are added. Now let them perform: - <code> - queue.run(); - </code> - <hr /> - We decide to let the button pulse, to indicate that the button has primary focus. - We create a pulse queue in the button class: - <code> - import org.asapframework.util.actionqueue.*; - - class LoadButton extends MovieClip { - - private var mQueue:ActionQueue; - - public function activate () : void { - mQueue = new ActionQueue(); - // pulse with infinite duration: - var duration:Number = 0; - mQueue.addAction( AQPulse.pulse, this, null, 0.5, 100, 40, 100, duration ); - mQueue.run(); - } - - public function deactivate () : void { - mQueue.quit(); - } - } - </code> - - @see ExtendedActionQueue - @see AQAddMove - @see AQBlink - @see AQColor - @see AQCurve - @see AQFade - @see AQFollowMouse - @see AQMove - @see AQMoveRel - @see AQProperty - @see AQPulse - @see AQReturnValue - @see AQRotate - @see AQScale - @see AQSet - @see AQSpring - @see AQTimeline - @see AQZoom - */ - - public class ActionQueue extends EventDispatcher { - - private var mFramePulse:FramePulse; - private var mActions:Array; - private var mLoopCount:int; - private var mName:String; - private var mWorker:AQWorker; - private var mIsPaused:Boolean; - private var mNestedQueues:Array; - - // types - private var ACTION_TYPE:int = 0; - - /** - Calculates the relative value between start and end of a function at moment inPercentage in time. For instance with a movieclip that is moved by a function from A to B, <code>relativeValue</code> calculates the position of the movieclip at moment inPercentage. - @param inStart : the start value of the object that is changing, for instance the start _x position - @param inEnd : the end value of the object that is changing, for instance the end _x position - @param inPercentage: the current moment in time expressed as a percentage value - @return The relative value between inStart and inEnd at moment inPercentage. - @implementationNote: The used calculation is <code>inStart + (inPercentage * (inEnd - inStart))</code> - @example - <code> - public function moveToActualPosition () : void { - mStartIntroPosition = new Point(_x, _y); - mStartIntroScale = _xscale; - var duration:Number = 2.0; - var queue:ActionQueue = new ActionQueue(); - queue.addAction( AQReturnValue.returnValue, this, "performMoveToActualPosition", duration, 0, 1); - queue.run(); - } - - private function performMoveToActualPosition (inPercentage:Number) : void { - _x = ActionQueue.relativeValue( mStartIntroPosition.x, mPosition.x, inPercentage ); - _y = ActionQueue.relativeValue( mStartIntroPosition.y, mPosition.y, inPercentage ); - _xscale = _yscale = ActionQueue.relativeValue( mStartIntroScale, mScale, inPercentage ); - } - </code> - */ - public static function relativeValue (inStart:Number, inEnd:Number, inPercentage:Number) : Number { - return inStart + (inPercentage * (inEnd - inStart)); - } - - /** - Creates and initializes a new ActionQueue object. - @param inName : (optional) unique identifying name for the queue - @usageNote When an ActionQueue performs a function on an object or movieclip, the queue will keep on executing when the object is deleted. And because the reference to the queue still exists, the object will stay alive as long as the queue is active. This will lead to a memory leak. So when you delete an object, you are also responsible yourself for deleting the queue. - @example - <code> - public function onActionQueueStarted (e:ActionQueueEvent) : void { - Log.debug("queue " + e.name + " has started"); - } - public function onActionQueueFinished (e:ActionQueueEvent) : void { - Log.debug("queue " + e.name + " has finished"); - } - </code> - <code> - var queue:ActionQueue = new ActionQueue( "main queue" ); - queue.addEventListener(ActionQueueEvent.QUEUE_STARTED, this); - queue.addEventListener(ActionQueueEvent.QUEUE_FINISHED, this); - </code> - <hr /> - If you don't need a queue status report you can create a queue in a more simple way: - <code> - var queue:ActionQueue = new ActionQueue(); - </code> - */ - function ActionQueue (inName:String = "anonymous ActionQueue") { - super(); - mName = inName; - mActions = new Array(); - mWorker = new AQWorker(inName); - mIsPaused = false; - } - - /** - Overloaded method that accepts a number of argument configurations. - - <b>Adding a function</b> - Will be called in local scope. - <code>public function addAction ( inFunction:Function, argument1, argument2, ... ) : ActionQueue</code> - - <b>Adding a object's method</b> - Will be called in the object's scope. - <code>public function addAction ( inMethodObject:Object, inMethod:Function, argument1, argument2, ... ) : ActionQueue</code> - - <b>Adding a object's method by name</b> - Will be called in the object's scope. - <code>public function addAction ( inMethodObject:Object, inMethodName:String, argument1, argument2, ... ) : ActionQueue</code> - - <b>Adding an action that will perform a function on an onEnterFrame</b> - Such as movieclip control methods (like {@link AQMove#move}) (will be called in {@link AQWorker AQWorker's} scope). - <code>public function addAction ( inFunction:Function, argument1, argument2, ... ) : ActionQueue</code> - The function inFunction should return a {@link ActionQueuePerformData} object. - @example - <b>Add a Custom interface/movieclip control method</b> - - Use any function that returns a {@link ActionQueuePerformData}, or use one of the ready made class metods from these classes: - {@link AQAddMove} - {@link AQBlink} - {@link AQColor} - {@link AQFade} - {@link AQFollowMouse} - {@link AQMove} - {@link AQMoveRel} - {@link AQPulse} - {@link AQReturnValue} - {@link AQScale} - {@link AQSet} - {@link AQSpring} - {@link AQTimeline} - - This example will move a movieclip from its current position (null, null) to a new position (500, the current y value), during 1 second: - <code> - queue.addAction( AQMove.move, my_mc, 1, null, null, 500, null ); - </code> - This example sets the alpha property of a movieclip to 50: - <code> - queue.addAction( AQSet.setAlpha, my_mc, 50 ); - </code> - - <hr /> - - You can also create a <b>custom function</b> and pass this to the queue. This is especially useful when you need to have more complex interaction with the objects to control. - - Follows an example of a function that is very similar to AQxxx class methods, and is in fact copied from {@link AQMove#move} - with the difference that we want to fade out the movieclip while it is moving. - <code> - // somewhere in your class - public function moveAndFade (inMC:DisplayObject, - inDuration:Number, - inStartX:Number, - inStartY:Number, - inEndX:Number, - inEndY:Number, - inEffect:Function ) : ActionQueuePerformData { - - // initalize variables here - - var performFunction:Function = function (inPerc:Number) : Boolean { - // do something with the received inPerc - return true; - }; - - // Set up the data so ActionQueue will perform the function performFunction: - var startValue:Number = 1.0; // counting from 1 down to 0 - var endValue:Number = 0; - return new ActionQueuePerformData( performFunction, inDuration, startValue, endValue, inEffect ); - } - </code> - Note that <code>performFunction</code> returns a Boolean. To abort <code>performFunction</code> let it return false. - - Now you add the function to the queue using addAction: - <code> - var queue:ActionQueue = new ActionQueue(); - queue.addAction( this, moveAndFade, my_mc, 5, null, null, 500, 200, Regular.easeInOut ); - queue.run(); - </code> - - */ - public function addAction () : ActionQueue { - - var firstParam = arguments[0]; - - var args:Array = arguments; - - if (firstParam instanceof Array) { - // when sent from addInAction - args = firstParam; - firstParam = args[0]; - } - - - if (typeof firstParam == "function") { - return AQaddFunction(args); - } - - if (firstParam instanceof Object) { - if (typeof args[1] == "string") { - // method name - return AQaddMethod(args); - } - // else scoped object with function reference - args.shift(); - return AQaddObjectMethod(firstParam, args); - } - } - - /** - addInAction stands for 'add Instant Action'. This method adds interface control method to the queue that is performed <b>immediately</b> as it processed by the queue (as soon as Flash triggers a new onEnterFrame). In contrast to {@link #addAction}, the queue won't wait for the end of this method. This eliminates the need to create separate methods and queues for movieclip actions that should occur at the same time. - See for parameters and usage at {@link #addAction}. - @return <b>The internally created ActionQueue</b> - this is useful when you need to end an eternal queue. - @example - The following code lets the movieclip 'ball_mc' move to a certain point, then simultaneously fades out the clip and clip 'square_mc': - <code> - queue.addAction( AQMove.move, ball_mc, 1, null, null, 500, null ); - queue.addInAction( AQFade.fade, square_mc, 2, null, 0 ); - var eternalQueue:ActionQueue = queue.addInAction ( AQPulse.pulse, square_mc, null, 0.5, 100, 40, 100, 0); - queue.addAction( this, "finishUp" ); - </code> - Because the fading of the ball clip is part of the normal queue, the method 'finishUp' is called after ball_mc is finished fading out. - Kill the pulsing of eternalQueue: - <code> - eternalQueue.quit(); - </code> - @implementationNote A separate internal queue is created inside an anonymous function, and this function is added to the external queue. This queue is set to run and cleans up after itself. - */ - public function addInAction () : ActionQueue { - - return AQaddInAction(arguments); - } - - /** - Inserts an ActionQueue that is run immediately as it is processed in the queue. <code>insertQueue</code> is similar to {@link #insertQueueActions}, with the difference that param <code>inActionQueue</code> will be run independently of the current queue. - @param inActionQueue : the ActionQueue to be inserted an run - @return The newly inserted queue inActionQueue. - @example - <code> - var queue1:ActionQueue = new ActionQueue(); - queue1.addAction( this, "write", "A" ); - queue1.addAction( this, "write", "B" ); - - var queue2:ActionQueue = new ActionQueue(); - </code> - Adding a pause will cause the 'write' actions of queue2 to be ran after the actions of queue1 have been finished: - <code> - queue2.addPause(1); - queue2.addAction( this, "write", "C" ); - queue2.addAction( this, "write", "D" ); - - queue1.insertQueue( queue2 ); - queue1.addAction( this, "write", "E" ); - queue1.run(); - </code> - Output: ABE, and somewhat later: CD - <hr /> - The following example shows a combined effect of fading in and zooming in, where the fading is started exactly halfway the zooming: - <code> - var duration:Number = 0.4; - var queue = new ActionQueue(); - queue.insertQueue( new ActionQueue().addPause(duration/2).addAction( AQFade.fade, my_mc, 1.0, null, 100 ) ); - queue.addAction( AQZoom.zoom, my_mc, duration ); - queue.run(); - </code> - */ - public function insertQueue (inActionQueue:ActionQueue) : ActionQueue { - var f:Function = function () : void { - inActionQueue.run(); // default: clean up after running - }; - addFunction(f); - AQaddNestedQueue(inActionQueue); - return inActionQueue; - } - - /** - Inserts the actions of inActionQueue in the current queue. <code>insertQueueActions</code> is similar to {@link #insertQueue}, with the difference that the actions that will be added to the current queue will be performed after the action of param <code>inActionQueue</code> - the order of performed actions will not change. - @param inActionQueue : the ActionQueue which actions are inserted - @return The current ActionQueue. - @example - <code> - var queue1:ActionQueue = new ActionQueue(); - queue1.addAction( this, "write", "A" ); - queue1.addAction( this, "write", "B" ); - - var queue2:ActionQueue = new ActionQueue(); - </code> - Adding a pause will not make a difference in the output, as the pause will also be added to the actions of queue1: - <code> - queue2.addPause(1); - queue2.addAction( this, "write", "C" ); - queue2.addAction( this, "write", "D" ); - - queue1.insertQueue( queue2 ); - queue1.addAction( this, "write", "E" ); - queue1.run(); - </code> - Output: ABCDE - */ - public function insertQueueActions (inActionQueue:ActionQueue) : ActionQueue { - mActions = mActions.concat(inActionQueue.actions()); - return this; - } - - /** - Adds a pause to the queue. The next action in the queue will be called after the duration of the pause. - @param inDuration : pause duration in seconds. Use 0 to pause the queue indefinitely. - @return The current ActionQueue. - @example - This example will pause the queue forever (until {@link #skip} or {@link ExtendedActionQueue#addContinueOnMessage} or {@link ExtendedActionQueue#addContinueOnCondition} is called). - <code> - queue.addPause( 0 ); - </code> - */ - public function addPause (inDuration:Number) : ActionQueue { - addAction(mWorker, "wait", inDuration); - return this; - } - - /** - Starts the queue for the first time. - @param inKeepAlive : If true, further actions can be appended after running; default false: the thread will clean up after itself automatically, and no more actions can be added. - @return The current ActionQueue. - @sends ActionQueueEvent#QUEUE_STARTED - */ - public function run (inKeepAlive:Boolean = false) : ActionQueue { - if (inKeepAlive != true) { - addAction(this, "AQQuit"); - } - AQStartOnEnterFrame(); - mWorker.start(); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_STARTED, mName)); - return this; - } - - /** - Stops and deletes the queue. - @return The current ActionQueue. - @sends ActionQueueEvent#QUEUE_QUIT - */ - public function quit () : ActionQueue { - AQstop(); - AQCleanUp(); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_QUIT, mName)); - return this; - } - - /** - Pauses the queue in the middle of an action. The action can be resumed by calling {@link #play}. {@link #pause} breaks in into a queue and must not be confused with {@link #addPause}, that inserts a waiting time in between actions. - @param inTimerShouldContinue : (optional) if true, the timer continues counting to the set end time; default value is false: the time left is stored and added to the current time when playing is resumed with {@link #play} - @return The current ActionQueue. - @sends ActionQueueEvent#QUEUE_PAUSED - */ - public function pause (inTimerShouldContinue:Boolean = false) : ActionQueue { - mWorker.pause(inTimerShouldContinue); - mIsPaused = true; - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_PAUSED, mName)); - return this; - } - - /** - Resumes the queue after {@link #pause}. The queue will resume with the stored action where it was left, including animations. - @return The current ActionQueue. - @sends ActionQueueEvent#QUEUE_RESUMED - */ - public function play () : ActionQueue { - if (mIsPaused) { - mWorker.resume(); - mIsPaused = false; - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_RESUMED, mName)); - } - return this; - } - - /** - Erases the queued actions and stops the queue. New actions can be added and the queue can be restarted with {@link #run}. - @return The current ActionQueue. - @example - In this example a queue belonging to one button (scale_btn) is cleared by pressing another button (clear_btn). After that a new action is added and run. - <code> - import mx.transitions.easing.*; - - scale_btn.startScale = function () { - var queue:ActionQueue = new ActionQueue(); - this.queue = queue; - this.queue.addAction( AQScale.scale, scale_mc, 5, null, null, 400, 400, Regular.easeOut ); - // possibly other actions... - this.queue.run(true); // note: keepAlive set to true - } - clear_btn.onPress = function() { - scale_btn.queue.clear(); - // add a new method to scale down again - scale_btn.queue.addAction( AQScale.scale, scale_mc, 1, null, null, 100, 100, Regular.easeOut ); - scale_btn.queue.run(true); // note: keepAlive set to true - } - </code> - */ - public function clear () : ActionQueue { - AQstop(); - mActions = new Array(); - return this; - } - - /** - Skips over the current action and calls the next action in the queue. - @return The current ActionQueue. - @example - <code> - - var queue:ActionQueue = new ActionQueue(); - queue.addAction( AQFollowMouse.followMouse, square_mc, 0.1, 0.9); // will not end out of itself - queue.addAction( AQFade.fade, square_mc, 2.0, null, 0 ); - queue.run(); - - // Clicking the skip_btn will stop the followMouse and fade out square_mc - skip_btn.onRelease = function() { - queue.skip(); - } - </code> - */ - public function skip () : ActionQueue { - mWorker.stop(); - return this; - } - - /** - The number of items in the queue; for debugging purposes. - */ - public function get count () : int { - return mActions.length; - } - - /** - Queries the active state of the queue. - @return Whether the ActionQueue is performing any action: true when running or paused, false when the queue is empty. - @example - Example of a pause toggle button that uses isBusy to check if the queue should be ordered to run or to pause: - <code> - pause_btn.onRelease = function() { - if (queue.isBusy()) { - if (queue.isPaused()) { - queue.play(); - } else { - queue.pause(); - } - } else { - queue.run(); - } - } - </code> - */ - public function isBusy () : Boolean { - return mWorker.isBusy(); - } - - /** - @return The array of action objects. - */ - public function actions () : Array { - return mActions; - } - - /** - @return The identifier name of the queue; for debugging purposes. - */ - public function name () : String { - return mName; - } - - /** - Retrieves the paused state of the queue. The queue can be pause using {@link #pause} and restarted using {@link #play}. - @return Whether the queue is paused (true) or not (false). - */ - public function isPaused () : Boolean { - return mIsPaused; - } - - /** - - */ - public override function toString () : String { - var info:String = "ActionQueue " + mName; - if (mActions) info += "; actions=" + mActions.length; - return info; - } - - // DEPRECATED METHODS - - /** - @deprecated As of 3 Feb 2006. Use {@link #addAction}. - */ - public function addAQMethod (inMethod:Object) : ActionQueue { - return AQaddFunction(arguments); - } - - /** - @deprecated As of 3 Feb 2006. Use {@link #addInAction}. - */ - public function addInAQMethod (inFunction:Object) : ActionQueue { - return AQaddInAction(arguments); - } - - /** - Adds a (locally scoped) function or reference (or an anonymous function) to a object's method to the queue. - @deprecated As of 3 Feb 2006. Use {@link #addAction}. - */ - public function addFunction (inFunctionRef:Function) : ActionQueue { - var args:Array = arguments; - return addAction(args); - } - - /** - Adds an object's method to the queue, by using the method's name. This way the object's method does not have to be known at the time that it is added to the queue. - @deprecated As of 3 Feb 2006. Use {@link #addAction}. - */ - public function addMethod (inObject:Object, - inMethodName:String) : ActionQueue { - - // switch inObject and inMethodName - var args:Array = arguments; - return AQaddMethod(args); - } - - /** - Cleans up the ActionQueue object after use, when the queue has been emptied. After this call no more actions can be added. Use this method after the last action. - @deprecated: Use {@link #run}. - */ - public function addCleanup () : ActionQueue { - addAction(this, "quit"); - return this; - } - - /** - Quit nested queues. - TODO: this cannot be called automatically, because nested queues may finish after the outer queue has finished! - @see #nestedQueues; - */ - public function quitNestedQueues () : void { - if (!mNestedQueues) return; - var i:int, ilen:int = mNestedQueues.length; - for (i=0; i<ilen; ++i) { - mNestedQueues[i].AQQuit(); - } - } - - /** - The list of nested queues. May be null. - */ - public function nestedQueues () : Array { - return mNestedQueues; - } - - // PRIVATE METHODS - - /** - @sends ActionQueueEvent#QUEUE_STOPPED - */ - private function AQstop () : void { - AQStopOnEnterFrame(); - mWorker.stop(); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_STOPPED, mName)); - } - - /** - Quits the queue. - @sends ActionQueueEvent#QUEUE_FINISHED - @sends ActionQueueEvent#QUEUE_QUIT - */ - public function AQQuit () : ActionQueue { - AQstop(); - AQCleanUp(); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_FINISHED, mName)); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_QUIT, mName)); - return this; - } - - /** - - */ - private function AQaddNestedQueue (inQueue:ActionQueue) : void { - if (!mNestedQueues) mNestedQueues = new Array(); - mNestedQueues.push(inQueue); - } - - /** - Cleans up the queue. - */ - private function AQCleanUp () : void { - mWorker.die(); - mActions = new Array(); - delete this; - } - - /** - - */ - private function AQStartOnEnterFrame () : void { - if (!mFramePulse) { - mFramePulse = new FramePulse(); - } - mFramePulse.addEnterFrameListener(onEnterFrame); - } - - /** - - */ - private function AQStopOnEnterFrame () : void { - if (mFramePulse) { - mFramePulse.removeEnterFrameListener(onEnterFrame); - mFramePulse.die(); - } - } - - /** - - */ - private function AQNextAction () : void { - mWorker.stop(); - } - - /** - @return The current ActionQueue. - */ - private function AQaddFunction (inArgs:Array) : ActionQueue { - var functionReference:Function = inArgs.shift(); - var o:ActionQueueData = new ActionQueueData(); - o.type = ACTION_TYPE; - o.obj = mWorker; - o.args = inArgs; - o.func = functionReference; - mActions.push(o); - return this; - } - - /** - @return The current ActionQueue. - */ - private function AQaddMethod (inArgs:Array) : ActionQueue { - - var methodObject:Object = inArgs.shift(); - var methodName:String = inArgs.shift(); - - var o:ActionQueueData = new ActionQueueData(); - - o.type = ACTION_TYPE; - o.obj = methodObject; - o.mname = methodName; - o.args = inArgs; - o.func = methodObject[methodName]; - if (o.func == undefined) { - Log.warn("AQaddMethod - Could not resolve method " + methodName + " at this time.", toString()); - } - mActions.push(o); - return this; - } - - /** - @return The current ActionQueue. - */ - private function AQaddObjectMethod (inFunctionOwner:Object, inArgs:Array) : ActionQueue { - - var func:Function = inArgs.shift(); - var o:ActionQueueData = new ActionQueueData(); - o.type = ACTION_TYPE; - o.obj = inFunctionOwner; - o.args = inArgs; - o.func = func; - if (o.func == undefined) { - //Log.warn("AQaddObjectMethod - Could not resolve method " + func + " at this time.", toString()); - } - mActions.push(o); - return this; - } - - /** - @return The current ActionQueue. - */ - private function AQaddInAction (inArgs:Array) : ActionQueue { - - var queue:ActionQueue = new ActionQueue(); - var f:Function = function () : void { - queue.addAction( inArgs ); - queue.run(); - }; - addAction(f); - AQaddNestedQueue(queue); - return queue; - } - - /** - onEnterFrame is called every enter frame - | - -> calls AQnext => while loop is used here whenever possible to bypass onEnterFrame, and AQapplyAction is called instead - | - -> calls AQapplyAction - | - -> calls the action - - Calls {@link #AQstop} when no more actions are in the list. - @param inEvent: not used - */ - public function onEnterFrame (inEvent:FramePulseEvent) : void { - if (!mWorker.onEnterFrame) { - if (mActions.length == 0) { - AQstop(); - return; - } - // get the next action - AQnext( ActionQueueData(mActions.shift()) ); - } - } - - /** - - */ - private function AQnext (o:ActionQueueData) : void { - - // For performance, try to loop through the array as long as possible. - while (o && !AQapplyAction(o)) { - o = ActionQueueData(mActions.shift()); - } - } - - /** - @return The called method's return value: in case of an AQMethod, the called function will return true if it has an onEnterFrame. If so, ActionQueue must pass an onEnterFrame itself. - */ - private function AQapplyAction (o:ActionQueueData) : Boolean { - if (o.func == undefined) { - // try to resolve the method now - o.func = o.obj[o.mname]; - } - // returnValue will be true if the called function returns true - // this happens for AQxxx methods with an onEnterFrame - var performData:* = o.func.apply(o.obj, o.args); - if (performData && performData instanceof ActionQueuePerformData) { - mWorker.returnValue(performData); - return true; - } - return false; - } - - } - - // -------------------------------------------------------------------- - - import flash.utils.getTimer; - - /** - This class is used by ActionQueue and various AQxxx classes; you should not instantiate this class yourself. - */ - - class AQWorker { - - private var mFramePulse:FramePulse; - private var mName:String; - private var mEndTime:Number; - private var mActionFunc:Function; - private var mStoredOnEnterFrame:Function; - private var mDurationLeft:Number; - - /** - @exclude - @param inName : ActionQueue's identifier, to make debugging easier. - */ - function AQWorker (inName:String = "anonymous AQWorker") { - mName = inName; - mFramePulse = new FramePulse(); // should be deferred when needed - } - - /** - @exclude - Pauses the current onEnterFrame. Called by {@link ActionQueue#pause}. - @param inTimerShouldContinue : (optional) if true, the timer continues counting to mEndTime; default value is false: the time left is stored and added to the current time in {@link #resume} - */ - public function pause (inTimerShouldContinue:Boolean) : void { - if (!inTimerShouldContinue) { - mDurationLeft = mEndTime - flash.utils.getTimer(); - } else { - mDurationLeft = undefined; // remove old value - } - mStoredOnEnterFrame = mActionFunc; - idle(); - } - - /** - @exclude - Resumes the paused onEnterFrame. Called by {@link ActionQueue#play}. - */ - public function resume () : void { - if (mDurationLeft != undefined) { - mEndTime = flash.utils.getTimer() + mDurationLeft; - } - setActionFunc(mStoredOnEnterFrame); - } - - /** - @exclude - */ - public function start () : void { - startActionFunc(); - } - - /** - @exclude - */ - public function stop () : void { - stopActionFunc(); - } - - public function die () : void { - stop(); - mFramePulse.die(); - delete mStoredOnEnterFrame; - } - - /** - @exclude - */ - public function idle () : void { - var f:Function = function () {}; - setActionFunc(f); - } - - /** - The worker is busy when its onEnterFrame is not undefined. - @exclude - */ - public function isBusy () : Boolean { - return mActionFunc != undefined; - } - - public function get onEnterFrame () : Function { - return mActionFunc; - } - - /** - @exclude - The end time of the animation. Used by AQxxx classes. - */ - public function get endTime () : Number { - return mEndTime; - } - public function set endTime (t:Number) : void { - mEndTime = t; - } - - /** - @exclude - */ - public function toString () : String { - return "; AQWorker " + mName; - } - - /** - @exclude - Lets the inWorker (thus the queue) pause between actions. Do not call this method directly, but use ActionQueue.addPause(). - @param inDuration : length of wait in seconds; if 0, waiting is infinite - @return A new ActionQueuePerformData object. - @implementationNote This method is called by ActionQueue.addPause(). - */ - public function wait (inDuration:Number) : ActionQueuePerformData { - var waitFunction:Function = function () { - if (inDuration == 0) return; // infinite: do not end - }; - return new ActionQueuePerformData(waitFunction, inDuration); - } - - /** - Do not call this method directly, but use {@link AQReturnValue#returnValue}. - @param inPerformData : data object with perform instructions - @implementationNote This method is called by virtually all AQxxx classes. - */ - public function returnValue (inPerformData:ActionQueuePerformData) : void { - - var effect:Function = inPerformData.effect; - var hasEffectParams:Boolean = (inPerformData.effectParams != undefined) && (inPerformData.effectParams.length > 0); - - var duration:Number = inPerformData.duration * 1000; // translate to milliseconds - var dur_f = 1 / duration; // use a multiply factor for speed - mEndTime = flash.utils.getTimer() + duration; - - var startValue:Number = (inPerformData.start != null) ? inPerformData.start : 0; - var endValue:Number = (inPerformData.end != null) ? inPerformData.end : 1000; - - var perc:Number, value:Number, now:Number; - var range:Number = endValue - startValue; - - var params:Array; - var ref:AQWorker = this; - - if (duration == 0) { - var f = function () { - if (inPerformData.method() == false) { - ref.stop(); - } - }; - setActionFunc(f); - return; - } - - var f:Function = function () { - now = flash.utils.getTimer(); - if (ref.endTime > now) { - perc = (ref.endTime - now) * dur_f; // multiply is faster than division - if (effect) { - if (hasEffectParams) { - params = [1 - perc, startValue, range, 1].concat(inPerformData.effectParams); - value = Number(effect.apply(null, params)); - } else { - value = Number(effect.call(null, 1 - perc, startValue, range, 1)); - } - } else { - value = endValue - (perc * range); - } - if (inPerformData.method.call(inPerformData.methodOwner, value) == false) { - // the performing method has returned false, so end this action - ref.stop(); - } - } else { - // end of loop - if (inPerformData.loop) { - ref.returnValue(inPerformData); - } else { - // not a loop - value = endValue; - ref.stop(); - if (inPerformData.method.call(inPerformData.methodOwner, value) != false) { - // only call the afterMethod function if this action has not been aborted - if (inPerformData.afterMethod != undefined) { - inPerformData.afterMethod.apply(); - } - } - } - } - }; - setActionFunc(f); - } - - private function setActionFunc (inFunction:Function) : void { - stopActionFunc(); - mActionFunc = inFunction; - startActionFunc(); - } - - private function startActionFunc () : void { - if (mActionFunc) { - mFramePulse.addEnterFrameListener(mActionFunc); - } - } - - private function stopActionFunc () : void { - if (mActionFunc) { - mFramePulse.removeEnterFrameListener(mActionFunc); - } - delete mActionFunc; - mActionFunc = null; - } - - } - -} \ No newline at end of file +/* +Copyright 2005-2006 by the authors of asapframework, http://asapframework.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.asapframework.util.actionqueue { + + import flash.events.EventDispatcher; + import flash.events.Event; + + import org.asapframework.util.actionqueue.ActionQueueData; + import org.asapframework.util.actionqueue.ActionQueueEvent; + import org.asapframework.util.actionqueue.ActionQueuePerformData; + import org.asapframework.util.debug.Log; + import org.asapframework.util.FramePulse; + + + /** + Scripted animation and function flow class. ActionQueue stores and runs a series of functions/methods one after the other. You can call local functions, object methods and special movieclip control methods, such as timed "fade", "move" or "pulse" functions. + ActionQueue is handy when you need timed animation, state transitions, complex button behavior or a series of functions that need to wait for a certain condition before they are run. You can insert waiting for messages or variable conditions (see {@link ExtendedActionQueue}). + The most common use for ActionQueue is to manipulate movieclips. + + <b>Adding actions to the queue</b> + {@link #addAction} (<code>myFunction</code>) : Adds a (locally scoped) function or an anonymous function. + {@link #addAction} (<code>myObj, myMethod</code>) : Adds an object's method. + {@link #addAction} (<code>myObj, myMethodName</code>) : Adds an object's method by using the method's name. The object's method does not have to be known at the time that it is added to the queue. + {@link #addAction} (<code>myAQAction</code>) : Adds a custom movieclip action from one of the AQxxx classes; use fade, scale, move, etcetera. See the list of available action methods at addAction, or create your own action method. + {@link #addInAction}: As addAction, but in a separately spawned thread; this eliminates the need to create separate methods and queues for movieclip actions that should occur at the same time. + + See also the method list summary. + + <b>On effects</b> + ActionQueue 'AQ' methods such as {@link AQScale#scale} may use Flash' easing effects from mx.transitions.easing. You can use the default mx.transitions.easing effects, or define your own. + + Example with mx.transitions.easing.Elastic: + <code> + import mx.transitions.easing.*; + queue.addAction( AQScale.scale, my_mc, 1, null, null, 100, 100, Elastic.easeIn ); + </code> + + <b>Advanced Queue functions</b> + To use conditional messages, conditions and looping, use {@link ExtendedActionQueue}. + + <b>Simultaneous effects</b> + To control different movieclip aspects at the same time, for instance to move a clip and fade it out, use {@link #addInAction}, or use {@link AQReturnValue} (example given below at {@link #addAction}). + + @author Arthur Clemens + @use + This code example demonstrates a combination of ActionQueue methods, to give an idea of how this class can be used in an application. + <code> + import org.asapframework.util.actionqueue.*; + import mx.transitions.easing.*; + </code> + Create the ActionQueue instance: + <code> + var queue:ActionQueue = new ActionQueue(); + </code> + With addAction you can use methods from AQSet to set properties of movieclips: + <code> + queue.addAction( AQSet.setAlpha, circle_mc, 75 ); + queue.addAction( AQSet.centerOnStage, circle_mc ); + queue.addAction( AQMove.move, circle_mc, 4, null, null, 0, 0, Bounce.easeInOut); + </code> + To add a pause, use <code>addPause(number of seconds)</code>, where 0 means wait forever - indefinite pauses can be terminated by {@link #skip}, {@link ExtendedActionQueue#addContinueOnMessage} and {@link ExtendedActionQueue#addContinueOnCondition}. + <code> + queue.addPause( 0.5 ); + queue.addAction( AQFade.fade, circle_mc, 2, null, 100, Regular.easeIn ); + </code> + All actions are added. Now let them perform: + <code> + queue.run(); + </code> + <hr /> + We decide to let the button pulse, to indicate that the button has primary focus. + We create a pulse queue in the button class: + <code> + import org.asapframework.util.actionqueue.*; + + class LoadButton extends MovieClip { + + private var mQueue:ActionQueue; + + public function activate () : void { + mQueue = new ActionQueue(); + // pulse with infinite duration: + var duration:Number = 0; + mQueue.addAction( AQPulse.pulse, this, null, 0.5, 100, 40, 100, duration ); + mQueue.run(); + } + + public function deactivate () : void { + mQueue.quit(); + } + } + </code> + + @see ExtendedActionQueue + @see AQAddMove + @see AQBlink + @see AQColor + @see AQCurve + @see AQFade + @see AQFollowMouse + @see AQMove + @see AQMoveRel + @see AQProperty + @see AQPulse + @see AQReturnValue + @see AQRotate + @see AQScale + @see AQSet + @see AQSpring + @see AQTimeline + @see AQZoom + */ + + public class ActionQueue extends EventDispatcher { + + private var mActions:Array; + private var mLoopCount:int; + private var mName:String; + private var mWorker:AQWorker; + private var mIsPaused:Boolean; + private var mNestedQueues:Array; + + // types + private var ACTION_TYPE:int = 0; + + /** + Calculates the relative value between start and end of a function at moment inPercentage in time. For instance with a movieclip that is moved by a function from A to B, <code>relativeValue</code> calculates the position of the movieclip at moment inPercentage. + @param inStart : the start value of the object that is changing, for instance the start _x position + @param inEnd : the end value of the object that is changing, for instance the end _x position + @param inPercentage: the current moment in time expressed as a percentage value + @return The relative value between inStart and inEnd at moment inPercentage. + @implementationNote: The used calculation is <code>inStart + (inPercentage * (inEnd - inStart))</code> + @example + <code> + public function moveToActualPosition () : void { + mStartIntroPosition = new Point(_x, _y); + mStartIntroScale = _xscale; + var duration:Number = 2.0; + var queue:ActionQueue = new ActionQueue(); + queue.addAction( AQReturnValue.returnValue, this, "performMoveToActualPosition", duration, 0, 1); + queue.run(); + } + + private function performMoveToActualPosition (inPercentage:Number) : void { + _x = ActionQueue.relativeValue( mStartIntroPosition.x, mPosition.x, inPercentage ); + _y = ActionQueue.relativeValue( mStartIntroPosition.y, mPosition.y, inPercentage ); + _xscale = _yscale = ActionQueue.relativeValue( mStartIntroScale, mScale, inPercentage ); + } + </code> + */ + public static function relativeValue (inStart:Number, inEnd:Number, inPercentage:Number) : Number { + return inStart + (inPercentage * (inEnd - inStart)); + } + + /** + Creates and initializes a new ActionQueue object. + @param inName : (optional) unique identifying name for the queue + @usageNote When an ActionQueue performs a function on an object or movieclip, the queue will keep on executing when the object is deleted. And because the reference to the queue still exists, the object will stay alive as long as the queue is active. This will lead to a memory leak. So when you delete an object, you are also responsible yourself for deleting the queue. + @example + <code> + public function onActionQueueStarted (e:ActionQueueEvent) : void { + Log.debug("queue " + e.name + " has started"); + } + public function onActionQueueFinished (e:ActionQueueEvent) : void { + Log.debug("queue " + e.name + " has finished"); + } + </code> + <code> + var queue:ActionQueue = new ActionQueue( "main queue" ); + queue.addEventListener(ActionQueueEvent.QUEUE_STARTED, this); + queue.addEventListener(ActionQueueEvent.QUEUE_FINISHED, this); + </code> + <hr /> + If you don't need a queue status report you can create a queue in a more simple way: + <code> + var queue:ActionQueue = new ActionQueue(); + </code> + */ + function ActionQueue (inName:String = "anonymous ActionQueue") { + super(); + mName = inName; + mActions = new Array(); + mWorker = new AQWorker(inName); + mIsPaused = false; + } + + /** + Overloaded method that accepts a number of argument configurations. + + <b>Adding a function</b> + Will be called in local scope. + <code>public function addAction ( inFunction:Function, argument1, argument2, ... ) : ActionQueue</code> + + <b>Adding a object's method</b> + Will be called in the object's scope. + <code>public function addAction ( inMethodObject:Object, inMethod:Function, argument1, argument2, ... ) : ActionQueue</code> + + <b>Adding a object's method by name</b> + Will be called in the object's scope. + <code>public function addAction ( inMethodObject:Object, inMethodName:String, argument1, argument2, ... ) : ActionQueue</code> + + <b>Adding an action that will perform a function on an onEnterFrame</b> + Such as movieclip control methods (like {@link AQMove#move}) (will be called in {@link AQWorker AQWorker's} scope). + <code>public function addAction ( inFunction:Function, argument1, argument2, ... ) : ActionQueue</code> + The function inFunction should return a {@link ActionQueuePerformData} object. + @example + <b>Add a Custom interface/movieclip control method</b> + + Use any function that returns a {@link ActionQueuePerformData}, or use one of the ready made class metods from these classes: + {@link AQAddMove} + {@link AQBlink} + {@link AQColor} + {@link AQFade} + {@link AQFollowMouse} + {@link AQMove} + {@link AQMoveRel} + {@link AQPulse} + {@link AQReturnValue} + {@link AQScale} + {@link AQSet} + {@link AQSpring} + {@link AQTimeline} + + This example will move a movieclip from its current position (null, null) to a new position (500, the current y value), during 1 second: + <code> + queue.addAction( AQMove.move, my_mc, 1, null, null, 500, null ); + </code> + This example sets the alpha property of a movieclip to 50: + <code> + queue.addAction( AQSet.setAlpha, my_mc, 50 ); + </code> + + <hr /> + + You can also create a <b>custom function</b> and pass this to the queue. This is especially useful when you need to have more complex interaction with the objects to control. + + Follows an example of a function that is very similar to AQxxx class methods, and is in fact copied from {@link AQMove#move} - with the difference that we want to fade out the movieclip while it is moving. + <code> + // somewhere in your class + public function moveAndFade (inMC:DisplayObject, + inDuration:Number, + inStartX:Number, + inStartY:Number, + inEndX:Number, + inEndY:Number, + inEffect:Function ) : ActionQueuePerformData { + + // initalize variables here + + var performFunction:Function = function (inPerc:Number) : Boolean { + // do something with the received inPerc + return true; + }; + + // Set up the data so ActionQueue will perform the function performFunction: + var startValue:Number = 1.0; // counting from 1 down to 0 + var endValue:Number = 0; + return new ActionQueuePerformData( performFunction, inDuration, startValue, endValue, inEffect ); + } + </code> + Note that <code>performFunction</code> returns a Boolean. To abort <code>performFunction</code> let it return false. + + Now you add the function to the queue using addAction: + <code> + var queue:ActionQueue = new ActionQueue(); + queue.addAction( this, moveAndFade, my_mc, 5, null, null, 500, 200, Regular.easeInOut ); + queue.run(); + </code> + + */ + public function addAction (...args:Array) : ActionQueue { + + var firstParam:* = args[0]; + + if (firstParam is Array) { + // when sent from addInAction + args = firstParam; + firstParam = args[0]; + } + + + if (firstParam is Function) { + return AQaddFunction(args); + } + + if (f... [truncated message content] |
From: <aci...@us...> - 2007-06-25 20:35:10
|
Revision: 705 http://asapframework.svn.sourceforge.net/asapframework/?rev=705&view=rev Author: acidcats Date: 2007-06-25 13:35:11 -0700 (Mon, 25 Jun 2007) Log Message: ----------- Updated ActionQueue classes & tests to conform AS3 strict compilation, most tests now run Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueue.as branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueuePerformData.as branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj branches/dev_as3/asapframework/test/unit/AllTests.as branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as branches/dev_as3/asapframework/test/unit/Tester.fla branches/dev_as3/asapframework/test/unit/Tester.swf branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/actionqueue/ActionQueueTestCase.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as 2007-06-24 19:49:07 UTC (rev 704) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFade.as 2007-06-25 20:35:11 UTC (rev 705) @@ -1,70 +1,70 @@ -/* -Copyright 2005-2006 by the authors of asapframework, http://asapframework.org - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package org.asapframework.util.actionqueue { - - import flash.display.DisplayObject; - - import org.asapframework.util.actionqueue.*; - - /** - ActionQueue method that controls the alpha blend of a movieclip. - See also {@link AQPulse} to fade a movieclip in a pulsating manner. - @author Arthur Clemens - */ - - class AQFade { - - private static var START_VALUE:Number = 1; /**< Start animation value to be returned to the perform function. */ - private static var END_VALUE:Number = 0; /**< End animation value to be returned to the perform function. */ - - /** - @param inMC : movieclip to fade - @param inDuration : length of animation in seconds; 0 is used for perpetual animations - use -1 for instant change - @param inStartAlpha : value to start fading from; if null then inMC's current alpha value is used - @param inEndAlpha : value to start fading to; if null then inMC's current alpha value is used - @param inEffect : (optional) An effect function, for instance one of the mx.transitions.easing methods. Arguments to pass the effect function may be appended as a comma-separated list. - @return A new ActionQueuePerformData object. - @example - This example fades in a movieclip from its current alpha to 100 in 2 seconds: - <code> - queue.addAction( AQFade.fade, my_mc, 2, null, 100, Regular.easeIn ); - </code> - */ - public static function fade (inMC:DisplayObject, - inDuration:Number, - inStartAlpha:* = null, - inEndAlpha:* = null, - inEffect:Function = undefined) : ActionQueuePerformData { - - // get effect parameters that are optionally passed after inEffect - var effectParams:Array = arguments.splice(5, arguments.length - 5); - - var startAlpha:Number = (inStartAlpha != null) ? inStartAlpha : inMC.alpha; - var endAlpha:Number = (inEndAlpha != null) ? inEndAlpha : inMC.alpha; - - var renda:Number, changea:Number; - - var performFunction:Function = function (inPerc:Number) : void { - // inPerc = percentage counting down from {@link #END_VALUE} to {@link #START_VALUE} - renda = (endAlpha == null ? inMC.alpha : endAlpha); - changea = endAlpha - startAlpha; - inMC.alpha = renda - (inPerc * changea); - }; - return new ActionQueuePerformData(performFunction, inDuration, START_VALUE, END_VALUE, inEffect, effectParams); - } - } +/* +Copyright 2005-2006 by the authors of asapframework, http://asapframework.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.asapframework.util.actionqueue { + + import flash.display.DisplayObject; + + import org.asapframework.util.actionqueue.*; + + /** + ActionQueue method that controls the alpha blend of a movieclip. + See also {@link AQPulse} to fade a movieclip in a pulsating manner. + @author Arthur Clemens + */ + + class AQFade { + + private static var START_VALUE:Number = 1; /**< Start animation value to be returned to the perform function. */ + private static var END_VALUE:Number = 0; /**< End animation value to be returned to the perform function. */ + + /** + @param inMC : movieclip to fade + @param inDuration : length of animation in seconds; 0 is used for perpetual animations - use -1 for instant change + @param inStartAlpha : value to start fading from; if null then inMC's current alpha value is used + @param inEndAlpha : value to start fading to; if null then inMC's current alpha value is used + @param inEffect : (optional) An effect function, for instance one of the mx.transitions.easing methods. Arguments to pass the effect function may be appended as a comma-separated list. + @return A new ActionQueuePerformData object. + @example + This example fades in a movieclip from its current alpha to 100 in 2 seconds: + <code> + queue.addAction( AQFade.fade, my_mc, 2, null, 100, Regular.easeIn ); + </code> + */ + public static function fade (inMC:DisplayObject, + inDuration:Number, + inStartAlpha:Number = Number.NaN, + inEndAlpha:Number = Number.NaN, + inEffect:Function = null) : ActionQueuePerformData { + + // get effect parameters that are optionally passed after inEffect + var effectParams:Array = arguments.splice(5, arguments.length - 5); + + var startAlpha:Number = !isNaN(inStartAlpha) ? inStartAlpha : inMC.alpha; + var endAlpha:Number = !isNaN(inEndAlpha) ? inEndAlpha : inMC.alpha; + + var renda:Number, changea:Number; + + var performFunction:Function = function (inPerc:Number) : void { + // inPerc = percentage counting down from {@link #END_VALUE} to {@link #START_VALUE} + renda = (isNaN(endAlpha) ? inMC.alpha : endAlpha); + changea = endAlpha - startAlpha; + inMC.alpha = renda - (inPerc * changea); + }; + return new ActionQueuePerformData(performFunction, inDuration, START_VALUE, END_VALUE, inEffect, effectParams); + } + } } \ No newline at end of file Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as 2007-06-24 19:49:07 UTC (rev 704) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQFollowMouse.as 2007-06-25 20:35:11 UTC (rev 705) @@ -104,12 +104,12 @@ */ public static function followMouse (inMC:DisplayObject, - inDuration:Number = undefined, - inTimeDiv:Number = undefined, - inLocDiv:Number = undefined, - inOffset:Point = undefined, - inCallbackObject:Object = undefined, - inCallBackMethod:Object = undefined) : ActionQueuePerformData { + inDuration:Number = Number.NaN, + inTimeDiv:Number = Number.NaN, + inLocDiv:Number = Number.NaN, + inOffset:Point = null, + inCallbackObject:Object = null, + inCallBackMethod:Object = null) : ActionQueuePerformData { var duration:Number = !isNaN(inDuration) ? inDuration * 1000 : 0; var endTime:Number = getTimer() + duration; @@ -125,10 +125,10 @@ var offsetY:Number = (inOffset != null) ? inOffset.y : 0; var callbackMethod:Function = null; - if (typeof inCallBackMethod == "string") { + if (inCallBackMethod is String) { callbackMethod = inCallbackObject[inCallBackMethod]; } - if (typeof inCallBackMethod == "function") { + if (inCallBackMethod is Function) { callbackMethod = Function(inCallBackMethod); } @@ -147,7 +147,7 @@ inMC.x = point.x; inMC.y = point.y; } - var draw:Function = (callbackMethod != undefined) ? drawCallback : drawMove; + var draw:Function = (callbackMethod != null) ? drawCallback : drawMove; return new ActionQueuePerformData(draw, duration); } } Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as 2007-06-24 19:49:07 UTC (rev 704) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/AQMove.as 2007-06-25 20:35:11 UTC (rev 705) @@ -47,17 +47,17 @@ */ public static function move (inMC:DisplayObject, inDuration:Number, - inStartX:* = null, - inStartY:* = null, - inEndX:* = null, - inEndY:* = null, + inStartX:Number = Number.NaN, + inStartY:Number = Number.NaN, + inEndX:Number = Number.NaN, + inEndY:Number = Number.NaN, inEffect:Function = undefined) : ActionQueuePerformData { // get effect parameters that are optionally passed after inEffect var effectParams:Array = arguments.splice(7, arguments.length - 7); - var startX:Number = (inStartX != null) ? inStartX : inMC.x; - var startY:Number = (inStartY != null) ? inStartY : inMC.y; + var startX:Number = !isNaN(inStartX) ? inStartX : inMC.x; + var startY:Number = !isNaN(inStartY) ? inStartY : inMC.y; // don't use endX and endY here, but use a relative end position, // to make it possible that another function changes the end value in the meantime @@ -65,8 +65,8 @@ var performFunction:Function = function (inPerc:Number) { // inPerc = percentage counting down from {@link #END_VALUE} to {@link #START_VALUE} - rendx = (inEndX != null ? inEndX : inMC.x); - rendy = (inEndY != null ? inEndY : inMC.y); + rendx = !isNaN(inEndX) ? inEndX : inMC.x; + rendy = !isNaN(inEndY) ? inEndY : inMC.y; changex = rendx - startX; changey = rendy - startY; inMC.x = rendx - (inPerc * changex); Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueue.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueue.as 2007-06-24 19:49:07 UTC (rev 704) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/actionqueue/ActionQueue.as 2007-06-25 20:35:11 UTC (rev 705) @@ -1,1065 +1,1010 @@ -/* -Copyright 2005-2006 by the authors of asapframework, http://asapframework.org - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package org.asapframework.util.actionqueue { - - import flash.events.EventDispatcher; - - import org.asapframework.util.actionqueue.ActionQueueData; - import org.asapframework.util.actionqueue.ActionQueueEvent; - import org.asapframework.util.actionqueue.ActionQueuePerformData; - import org.asapframework.util.actionqueue.AQWorker; - //import org.asapframework.util.debug.Log; - import org.asapframework.util.framepulse.FramePulse; - import org.asapframework.util.framepulse.FramePulseEvent; - - /** - Scripted animation and function flow class. ActionQueue stores and runs a series of functions/methods one after the other. You can call local functions, object methods and special movieclip control methods, such as timed "fade", "move" or "pulse" functions. - ActionQueue is handy when you need timed animation, state transitions, complex button behavior or a series of functions that need to wait for a certain condition before they are run. You can insert waiting for messages or variable conditions (see {@link ExtendedActionQueue}). - The most common use for ActionQueue is to manipulate movieclips. - - <b>Adding actions to the queue</b> - {@link #addAction} (<code>myFunction</code>) : Adds a (locally scoped) function or an anonymous function. - {@link #addAction} (<code>myObj, myMethod</code>) : Adds an object's method. - {@link #addAction} (<code>myObj, myMethodName</code>) : Adds an object's method by using the method's name. The object's method does not have to be known at the time that it is added to the queue. - {@link #addAction} (<code>myAQAction</code>) : Adds a custom movieclip action from one of the AQxxx classes; use fade, scale, move, etcetera. See the list of available action methods at addAction, or create your own action method. - {@link #addInAction}: As addAction, but in a separately spawned thread; this eliminates the need to create separate methods and queues for movieclip actions that should occur at the same time. - - See also the method list summary. - - <b>On effects</b> - ActionQueue 'AQ' methods such as {@link AQScale#scale} may use Flash' easing effects from mx.transitions.easing. You can use the default mx.transitions.easing effects, or define your own. - - Example with mx.transitions.easing.Elastic: - <code> - import mx.transitions.easing.*; - queue.addAction( AQScale.scale, my_mc, 1, null, null, 100, 100, Elastic.easeIn ); - </code> - - <b>Advanced Queue functions</b> - To use conditional messages, conditions and looping, use {@link ExtendedActionQueue}. - - <b>Simultaneous effects</b> - To control different movieclip aspects at the same time, for instance to move a clip and fade it out, use {@link #addInAction}, or use {@link AQReturnValue} (example given below at {@link #addAction}). - - @author Arthur Clemens - @use - This code example demonstrates a combination of ActionQueue methods, to give an idea of how this class can be used in an application. - <code> - import org.asapframework.util.actionqueue.*; - import mx.transitions.easing.*; - </code> - Create the ActionQueue instance: - <code> - var queue:ActionQueue = new ActionQueue(); - </code> - With addAction you can use methods from AQSet to set properties of movieclips: - <code> - queue.addAction( AQSet.setAlpha, circle_mc, 75 ); - queue.addAction( AQSet.centerOnStage, circle_mc ); - queue.addAction( AQMove.move, circle_mc, 4, null, null, 0, 0, Bounce.easeInOut); - </code> - To add a pause, use <code>addPause(number of seconds)</code>, where 0 means wait forever - indefinite pauses can be terminated by {@link #skip}, {@link ExtendedActionQueue#addContinueOnMessage} and {@link ExtendedActionQueue#addContinueOnCondition}. - <code> - queue.addPause( 0.5 ); - queue.addAction( AQFade.fade, circle_mc, 2, null, 100, Regular.easeIn ); - </code> - All actions are added. Now let them perform: - <code> - queue.run(); - </code> - <hr /> - We decide to let the button pulse, to indicate that the button has primary focus. - We create a pulse queue in the button class: - <code> - import org.asapframework.util.actionqueue.*; - - class LoadButton extends MovieClip { - - private var mQueue:ActionQueue; - - public function activate () : void { - mQueue = new ActionQueue(); - // pulse with infinite duration: - var duration:Number = 0; - mQueue.addAction( AQPulse.pulse, this, null, 0.5, 100, 40, 100, duration ); - mQueue.run(); - } - - public function deactivate () : void { - mQueue.quit(); - } - } - </code> - - @see ExtendedActionQueue - @see AQAddMove - @see AQBlink - @see AQColor - @see AQCurve - @see AQFade - @see AQFollowMouse - @see AQMove - @see AQMoveRel - @see AQProperty - @see AQPulse - @see AQReturnValue - @see AQRotate - @see AQScale - @see AQSet - @see AQSpring - @see AQTimeline - @see AQZoom - */ - - public class ActionQueue extends EventDispatcher { - - private var mFramePulse:FramePulse; - private var mActions:Array; - private var mLoopCount:int; - private var mName:String; - private var mWorker:AQWorker; - private var mIsPaused:Boolean; - private var mNestedQueues:Array; - - // types - private var ACTION_TYPE:int = 0; - - /** - Calculates the relative value between start and end of a function at moment inPercentage in time. For instance with a movieclip that is moved by a function from A to B, <code>relativeValue</code> calculates the position of the movieclip at moment inPercentage. - @param inStart : the start value of the object that is changing, for instance the start _x position - @param inEnd : the end value of the object that is changing, for instance the end _x position - @param inPercentage: the current moment in time expressed as a percentage value - @return The relative value between inStart and inEnd at moment inPercentage. - @implementationNote: The used calculation is <code>inStart + (inPercentage * (inEnd - inStart))</code> - @example - <code> - public function moveToActualPosition () : void { - mStartIntroPosition = new Point(_x, _y); - mStartIntroScale = _xscale; - var duration:Number = 2.0; - var queue:ActionQueue = new ActionQueue(); - queue.addAction( AQReturnValue.returnValue, this, "performMoveToActualPosition", duration, 0, 1); - queue.run(); - } - - private function performMoveToActualPosition (inPercentage:Number) : void { - _x = ActionQueue.relativeValue( mStartIntroPosition.x, mPosition.x, inPercentage ); - _y = ActionQueue.relativeValue( mStartIntroPosition.y, mPosition.y, inPercentage ); - _xscale = _yscale = ActionQueue.relativeValue( mStartIntroScale, mScale, inPercentage ); - } - </code> - */ - public static function relativeValue (inStart:Number, inEnd:Number, inPercentage:Number) : Number { - return inStart + (inPercentage * (inEnd - inStart)); - } - - /** - Creates and initializes a new ActionQueue object. - @param inName : (optional) unique identifying name for the queue - @usageNote When an ActionQueue performs a function on an object or movieclip, the queue will keep on executing when the object is deleted. And because the reference to the queue still exists, the object will stay alive as long as the queue is active. This will lead to a memory leak. So when you delete an object, you are also responsible yourself for deleting the queue. - @example - <code> - public function onActionQueueStarted (e:ActionQueueEvent) : void { - Log.debug("queue " + e.name + " has started"); - } - public function onActionQueueFinished (e:ActionQueueEvent) : void { - Log.debug("queue " + e.name + " has finished"); - } - </code> - <code> - var queue:ActionQueue = new ActionQueue( "main queue" ); - queue.addEventListener(ActionQueueEvent.QUEUE_STARTED, this); - queue.addEventListener(ActionQueueEvent.QUEUE_FINISHED, this); - </code> - <hr /> - If you don't need a queue status report you can create a queue in a more simple way: - <code> - var queue:ActionQueue = new ActionQueue(); - </code> - */ - function ActionQueue (inName:String = "anonymous ActionQueue") { - super(); - mName = inName; - mActions = new Array(); - mWorker = new AQWorker(inName); - mIsPaused = false; - } - - /** - Overloaded method that accepts a number of argument configurations. - - <b>Adding a function</b> - Will be called in local scope. - <code>public function addAction ( inFunction:Function, argument1, argument2, ... ) : ActionQueue</code> - - <b>Adding a object's method</b> - Will be called in the object's scope. - <code>public function addAction ( inMethodObject:Object, inMethod:Function, argument1, argument2, ... ) : ActionQueue</code> - - <b>Adding a object's method by name</b> - Will be called in the object's scope. - <code>public function addAction ( inMethodObject:Object, inMethodName:String, argument1, argument2, ... ) : ActionQueue</code> - - <b>Adding an action that will perform a function on an onEnterFrame</b> - Such as movieclip control methods (like {@link AQMove#move}) (will be called in {@link AQWorker AQWorker's} scope). - <code>public function addAction ( inFunction:Function, argument1, argument2, ... ) : ActionQueue</code> - The function inFunction should return a {@link ActionQueuePerformData} object. - @example - <b>Add a Custom interface/movieclip control method</b> - - Use any function that returns a {@link ActionQueuePerformData}, or use one of the ready made class metods from these classes: - {@link AQAddMove} - {@link AQBlink} - {@link AQColor} - {@link AQFade} - {@link AQFollowMouse} - {@link AQMove} - {@link AQMoveRel} - {@link AQPulse} - {@link AQReturnValue} - {@link AQScale} - {@link AQSet} - {@link AQSpring} - {@link AQTimeline} - - This example will move a movieclip from its current position (null, null) to a new position (500, the current y value), during 1 second: - <code> - queue.addAction( AQMove.move, my_mc, 1, null, null, 500, null ); - </code> - This example sets the alpha property of a movieclip to 50: - <code> - queue.addAction( AQSet.setAlpha, my_mc, 50 ); - </code> - - <hr /> - - You can also create a <b>custom function</b> and pass this to the queue. This is especially useful when you need to have more complex interaction with the objects to control. - - Follows an example of a function that is very similar to AQxxx class methods, and is in fact copied from {@link AQMove#move} - with the difference that we want to fade out the movieclip while it is moving. - <code> - // somewhere in your class - public function moveAndFade (inMC:DisplayObject, - inDuration:Number, - inStartX:Number, - inStartY:Number, - inEndX:Number, - inEndY:Number, - inEffect:Function ) : ActionQueuePerformData { - - // initalize variables here - - var performFunction:Function = function (inPerc:Number) : Boolean { - // do something with the received inPerc - return true; - }; - - // Set up the data so ActionQueue will perform the function performFunction: - var startValue:Number = 1.0; // counting from 1 down to 0 - var endValue:Number = 0; - return new ActionQueuePerformData( performFunction, inDuration, startValue, endValue, inEffect ); - } - </code> - Note that <code>performFunction</code> returns a Boolean. To abort <code>performFunction</code> let it return false. - - Now you add the function to the queue using addAction: - <code> - var queue:ActionQueue = new ActionQueue(); - queue.addAction( this, moveAndFade, my_mc, 5, null, null, 500, 200, Regular.easeInOut ); - queue.run(); - </code> - - */ - public function addAction () : ActionQueue { - - var firstParam = arguments[0]; - - var args:Array = arguments; - - if (firstParam instanceof Array) { - // when sent from addInAction - args = firstParam; - firstParam = args[0]; - } - - - if (typeof firstParam == "function") { - return AQaddFunction(args); - } - - if (firstParam instanceof Object) { - if (typeof args[1] == "string") { - // method name - return AQaddMethod(args); - } - // else scoped object with function reference - args.shift(); - return AQaddObjectMethod(firstParam, args); - } - } - - /** - addInAction stands for 'add Instant Action'. This method adds interface control method to the queue that is performed <b>immediately</b> as it processed by the queue (as soon as Flash triggers a new onEnterFrame). In contrast to {@link #addAction}, the queue won't wait for the end of this method. This eliminates the need to create separate methods and queues for movieclip actions that should occur at the same time. - See for parameters and usage at {@link #addAction}. - @return <b>The internally created ActionQueue</b> - this is useful when you need to end an eternal queue. - @example - The following code lets the movieclip 'ball_mc' move to a certain point, then simultaneously fades out the clip and clip 'square_mc': - <code> - queue.addAction( AQMove.move, ball_mc, 1, null, null, 500, null ); - queue.addInAction( AQFade.fade, square_mc, 2, null, 0 ); - var eternalQueue:ActionQueue = queue.addInAction ( AQPulse.pulse, square_mc, null, 0.5, 100, 40, 100, 0); - queue.addAction( this, "finishUp" ); - </code> - Because the fading of the ball clip is part of the normal queue, the method 'finishUp' is called after ball_mc is finished fading out. - Kill the pulsing of eternalQueue: - <code> - eternalQueue.quit(); - </code> - @implementationNote A separate internal queue is created inside an anonymous function, and this function is added to the external queue. This queue is set to run and cleans up after itself. - */ - public function addInAction () : ActionQueue { - - return AQaddInAction(arguments); - } - - /** - Inserts an ActionQueue that is run immediately as it is processed in the queue. <code>insertQueue</code> is similar to {@link #insertQueueActions}, with the difference that param <code>inActionQueue</code> will be run independently of the current queue. - @param inActionQueue : the ActionQueue to be inserted an run - @return The newly inserted queue inActionQueue. - @example - <code> - var queue1:ActionQueue = new ActionQueue(); - queue1.addAction( this, "write", "A" ); - queue1.addAction( this, "write", "B" ); - - var queue2:ActionQueue = new ActionQueue(); - </code> - Adding a pause will cause the 'write' actions of queue2 to be ran after the actions of queue1 have been finished: - <code> - queue2.addPause(1); - queue2.addAction( this, "write", "C" ); - queue2.addAction( this, "write", "D" ); - - queue1.insertQueue( queue2 ); - queue1.addAction( this, "write", "E" ); - queue1.run(); - </code> - Output: ABE, and somewhat later: CD - <hr /> - The following example shows a combined effect of fading in and zooming in, where the fading is started exactly halfway the zooming: - <code> - var duration:Number = 0.4; - var queue = new ActionQueue(); - queue.insertQueue( new ActionQueue().addPause(duration/2).addAction( AQFade.fade, my_mc, 1.0, null, 100 ) ); - queue.addAction( AQZoom.zoom, my_mc, duration ); - queue.run(); - </code> - */ - public function insertQueue (inActionQueue:ActionQueue) : ActionQueue { - var f:Function = function () : void { - inActionQueue.run(); // default: clean up after running - }; - addFunction(f); - AQaddNestedQueue(inActionQueue); - return inActionQueue; - } - - /** - Inserts the actions of inActionQueue in the current queue. <code>insertQueueActions</code> is similar to {@link #insertQueue}, with the difference that the actions that will be added to the current queue will be performed after the action of param <code>inActionQueue</code> - the order of performed actions will not change. - @param inActionQueue : the ActionQueue which actions are inserted - @return The current ActionQueue. - @example - <code> - var queue1:ActionQueue = new ActionQueue(); - queue1.addAction( this, "write", "A" ); - queue1.addAction( this, "write", "B" ); - - var queue2:ActionQueue = new ActionQueue(); - </code> - Adding a pause will not make a difference in the output, as the pause will also be added to the actions of queue1: - <code> - queue2.addPause(1); - queue2.addAction( this, "write", "C" ); - queue2.addAction( this, "write", "D" ); - - queue1.insertQueue( queue2 ); - queue1.addAction( this, "write", "E" ); - queue1.run(); - </code> - Output: ABCDE - */ - public function insertQueueActions (inActionQueue:ActionQueue) : ActionQueue { - mActions = mActions.concat(inActionQueue.actions()); - return this; - } - - /** - Adds a pause to the queue. The next action in the queue will be called after the duration of the pause. - @param inDuration : pause duration in seconds. Use 0 to pause the queue indefinitely. - @return The current ActionQueue. - @example - This example will pause the queue forever (until {@link #skip} or {@link ExtendedActionQueue#addContinueOnMessage} or {@link ExtendedActionQueue#addContinueOnCondition} is called). - <code> - queue.addPause( 0 ); - </code> - */ - public function addPause (inDuration:Number) : ActionQueue { - addAction(mWorker, "wait", inDuration); - return this; - } - - /** - Starts the queue for the first time. - @param inKeepAlive : If true, further actions can be appended after running; default false: the thread will clean up after itself automatically, and no more actions can be added. - @return The current ActionQueue. - @sends ActionQueueEvent#QUEUE_STARTED - */ - public function run (inKeepAlive:Boolean = false) : ActionQueue { - if (inKeepAlive != true) { - addAction(this, "AQQuit"); - } - AQStartOnEnterFrame(); - mWorker.start(); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_STARTED, mName)); - return this; - } - - /** - Stops and deletes the queue. - @return The current ActionQueue. - @sends ActionQueueEvent#QUEUE_QUIT - */ - public function quit () : ActionQueue { - AQstop(); - AQCleanUp(); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_QUIT, mName)); - return this; - } - - /** - Pauses the queue in the middle of an action. The action can be resumed by calling {@link #play}. {@link #pause} breaks in into a queue and must not be confused with {@link #addPause}, that inserts a waiting time in between actions. - @param inTimerShouldContinue : (optional) if true, the timer continues counting to the set end time; default value is false: the time left is stored and added to the current time when playing is resumed with {@link #play} - @return The current ActionQueue. - @sends ActionQueueEvent#QUEUE_PAUSED - */ - public function pause (inTimerShouldContinue:Boolean = false) : ActionQueue { - mWorker.pause(inTimerShouldContinue); - mIsPaused = true; - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_PAUSED, mName)); - return this; - } - - /** - Resumes the queue after {@link #pause}. The queue will resume with the stored action where it was left, including animations. - @return The current ActionQueue. - @sends ActionQueueEvent#QUEUE_RESUMED - */ - public function play () : ActionQueue { - if (mIsPaused) { - mWorker.resume(); - mIsPaused = false; - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_RESUMED, mName)); - } - return this; - } - - /** - Erases the queued actions and stops the queue. New actions can be added and the queue can be restarted with {@link #run}. - @return The current ActionQueue. - @example - In this example a queue belonging to one button (scale_btn) is cleared by pressing another button (clear_btn). After that a new action is added and run. - <code> - import mx.transitions.easing.*; - - scale_btn.startScale = function () { - var queue:ActionQueue = new ActionQueue(); - this.queue = queue; - this.queue.addAction( AQScale.scale, scale_mc, 5, null, null, 400, 400, Regular.easeOut ); - // possibly other actions... - this.queue.run(true); // note: keepAlive set to true - } - clear_btn.onPress = function() { - scale_btn.queue.clear(); - // add a new method to scale down again - scale_btn.queue.addAction( AQScale.scale, scale_mc, 1, null, null, 100, 100, Regular.easeOut ); - scale_btn.queue.run(true); // note: keepAlive set to true - } - </code> - */ - public function clear () : ActionQueue { - AQstop(); - mActions = new Array(); - return this; - } - - /** - Skips over the current action and calls the next action in the queue. - @return The current ActionQueue. - @example - <code> - - var queue:ActionQueue = new ActionQueue(); - queue.addAction( AQFollowMouse.followMouse, square_mc, 0.1, 0.9); // will not end out of itself - queue.addAction( AQFade.fade, square_mc, 2.0, null, 0 ); - queue.run(); - - // Clicking the skip_btn will stop the followMouse and fade out square_mc - skip_btn.onRelease = function() { - queue.skip(); - } - </code> - */ - public function skip () : ActionQueue { - mWorker.stop(); - return this; - } - - /** - The number of items in the queue; for debugging purposes. - */ - public function get count () : int { - return mActions.length; - } - - /** - Queries the active state of the queue. - @return Whether the ActionQueue is performing any action: true when running or paused, false when the queue is empty. - @example - Example of a pause toggle button that uses isBusy to check if the queue should be ordered to run or to pause: - <code> - pause_btn.onRelease = function() { - if (queue.isBusy()) { - if (queue.isPaused()) { - queue.play(); - } else { - queue.pause(); - } - } else { - queue.run(); - } - } - </code> - */ - public function isBusy () : Boolean { - return mWorker.isBusy(); - } - - /** - @return The array of action objects. - */ - public function actions () : Array { - return mActions; - } - - /** - @return The identifier name of the queue; for debugging purposes. - */ - public function name () : String { - return mName; - } - - /** - Retrieves the paused state of the queue. The queue can be pause using {@link #pause} and restarted using {@link #play}. - @return Whether the queue is paused (true) or not (false). - */ - public function isPaused () : Boolean { - return mIsPaused; - } - - /** - - */ - public override function toString () : String { - var info:String = "ActionQueue " + mName; - if (mActions) info += "; actions=" + mActions.length; - return info; - } - - // DEPRECATED METHODS - - /** - @deprecated As of 3 Feb 2006. Use {@link #addAction}. - */ - public function addAQMethod (inMethod:Object) : ActionQueue { - return AQaddFunction(arguments); - } - - /** - @deprecated As of 3 Feb 2006. Use {@link #addInAction}. - */ - public function addInAQMethod (inFunction:Object) : ActionQueue { - return AQaddInAction(arguments); - } - - /** - Adds a (locally scoped) function or reference (or an anonymous function) to a object's method to the queue. - @deprecated As of 3 Feb 2006. Use {@link #addAction}. - */ - public function addFunction (inFunctionRef:Function) : ActionQueue { - var args:Array = arguments; - return addAction(args); - } - - /** - Adds an object's method to the queue, by using the method's name. This way the object's method does not have to be known at the time that it is added to the queue. - @deprecated As of 3 Feb 2006. Use {@link #addAction}. - */ - public function addMethod (inObject:Object, - inMethodName:String) : ActionQueue { - - // switch inObject and inMethodName - var args:Array = arguments; - return AQaddMethod(args); - } - - /** - Cleans up the ActionQueue object after use, when the queue has been emptied. After this call no more actions can be added. Use this method after the last action. - @deprecated: Use {@link #run}. - */ - public function addCleanup () : ActionQueue { - addAction(this, "quit"); - return this; - } - - /** - Quit nested queues. - TODO: this cannot be called automatically, because nested queues may finish after the outer queue has finished! - @see #nestedQueues; - */ - public function quitNestedQueues () : void { - if (!mNestedQueues) return; - var i:int, ilen:int = mNestedQueues.length; - for (i=0; i<ilen; ++i) { - mNestedQueues[i].AQQuit(); - } - } - - /** - The list of nested queues. May be null. - */ - public function nestedQueues () : Array { - return mNestedQueues; - } - - // PRIVATE METHODS - - /** - @sends ActionQueueEvent#QUEUE_STOPPED - */ - private function AQstop () : void { - AQStopOnEnterFrame(); - mWorker.stop(); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_STOPPED, mName)); - } - - /** - Quits the queue. - @sends ActionQueueEvent#QUEUE_FINISHED - @sends ActionQueueEvent#QUEUE_QUIT - */ - public function AQQuit () : ActionQueue { - AQstop(); - AQCleanUp(); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_FINISHED, mName)); - dispatchEvent(new ActionQueueEvent(ActionQueueEvent.QUEUE_QUIT, mName)); - return this; - } - - /** - - */ - private function AQaddNestedQueue (inQueue:ActionQueue) : void { - if (!mNestedQueues) mNestedQueues = new Array(); - mNestedQueues.push(inQueue); - } - - /** - Cleans up the queue. - */ - private function AQCleanUp () : void { - mWorker.die(); - mActions = new Array(); - delete this; - } - - /** - - */ - private function AQStartOnEnterFrame () : void { - if (!mFramePulse) { - mFramePulse = new FramePulse(); - } - mFramePulse.addEnterFrameListener(onEnterFrame); - } - - /** - - */ - private function AQStopOnEnterFrame () : void { - if (mFramePulse) { - mFramePulse.removeEnterFrameListener(onEnterFrame); - mFramePulse.die(); - } - } - - /** - - */ - private function AQNextAction () : void { - mWorker.stop(); - } - - /** - @return The current ActionQueue. - */ - private function AQaddFunction (inArgs:Array) : ActionQueue { - var functionReference:Function = inArgs.shift(); - var o:ActionQueueData = new ActionQueueData(); - o.type = ACTION_TYPE; - o.obj = mWorker; - o.args = inArgs; - o.func = functionReference; - mActions.push(o); - return this; - } - - /** - @return The current ActionQueue. - */ - private function AQaddMethod (inArgs:Array) : ActionQueue { - - var methodObject:Object = inArgs.shift(); - var methodName:String = inArgs.shift(); - - var o:ActionQueueData = new ActionQueueData(); - - o.type = ACTION_TYPE; - o.obj = methodObject; - o.mname = methodName; - o.args = inArgs; - o.func = methodObject[methodName]; - if (o.func == undefined) { - Log.warn("AQaddMethod - Could not resolve method " + methodName + " at this time.", toString()); - } - mActions.push(o); - return this; - } - - /** - @return The current ActionQueue. - */ - private function AQaddObjectMethod (inFunctionOwner:Object, inArgs:Array) : ActionQueue { - - var func:Function = inArgs.shift(); - var o:ActionQueueData = new ActionQueueData(); - o.type = ACTION_TYPE; - o.obj = inFunctionOwner; - o.args = inArgs; - o.func = func; - if (o.func == undefined) { - //Log.warn("AQaddObjectMethod - Could not resolve method " + func + " at this time.", toString()); - } - mActions.push(o); - return this; - } - - /** - @return The current ActionQueue. - */ - private function AQaddInAction (inArgs:Array) : ActionQueue { - - var queue:ActionQueue = new ActionQueue(); - var f:Function = function () : void { - queue.addAction( inArgs ); - queue.run(); - }; - addAction(f); - AQaddNestedQueue(queue); - return queue; - } - - /** - onEnterFrame is called every enter frame - | - -> calls AQnext => while loop is used here whenever possible to bypass onEnterFrame, and AQapplyAction is called instead - | - -> calls AQapplyAction - | - -> calls the action - - Calls {@link #AQstop} when no more actions are in the list. - @param inEvent: not used - */ - public function onEnterFrame (inEvent:FramePulseEvent) : void { - if (!mWorker.onEnterFrame) { - if (mActions.length == 0) { - AQstop(); - return; - } - // get the next action - AQnext( ActionQueueData(mActions.shift()) ); - } - } - - /** - - */ - private function AQnext (o:ActionQueueData) : void { - - // For performance, try to loop through the array as long as possible. - while (o && !AQapplyAction(o)) { - o = ActionQueueData(mActions.shift()); - } - } - - /** - @return The called method's return value: in case of an AQMethod, the called function will return true if it has an onEnterFrame. If so, ActionQueue must pass an onEnterFrame itself. - */ - private function AQapplyAction (o:ActionQueueData) : Boolean { - if (o.func == undefined) { - // try to resolve the method now - o.func = o.obj[o.mname]; - } - // returnValue will be true if the called function returns true - // this happens for AQxxx methods with an onEnterFrame - var performData:* = o.func.apply(o.obj, o.args); - if (performData && performData instanceof ActionQueuePerformData) { - mWorker.returnValue(performData); - return true; - } - return false; - } - - } - - // -------------------------------------------------------------------- - - import flash.utils.getTimer; - - /** - This class is used by ActionQueue and various AQxxx classes; you should not instantiate this class yourself. - */ - - class AQWorker { - - private var mFramePulse:FramePulse; - private var mName:String; - private var mEndTime:Number; - private var mActionFunc:Function; - private var mStoredOnEnterFrame:Function; - private var mDurationLeft:Number; - - /** - @exclude - @param inName : ActionQueue's identifier, to make debugging easier. - */ - function AQWorker (inName:String = "anonymous AQWorker") { - mName = inName; - mFramePulse = new FramePulse(); // should be deferred when needed - } - - /** - @exclude - Pauses the current onEnterFrame. Called by {@link ActionQueue#pause}. - @param inTimerShouldContinue : (optional) if true, the timer continues counting to mEndTime; default value is false: the time left is stored and added to the current time in {@link #resume} - */ - public function pause (inTimerShouldContinue:Boolean) : void { - if (!inTimerShouldContinue) { - mDurationLeft = mEndTime - flash.utils.getTimer(); - } else { - mDurationLeft = undefined; // remove old value - } - mStoredOnEnterFrame = mActionFunc; - idle(); - } - - /** - @exclude - Resumes the paused onEnterFrame. Called by {@link ActionQueue#play}. - */ - public function resume () : void { - if (mDurationLeft != undefined) { - mEndTime = flash.utils.getTimer() + mDurationLeft; - } - setActionFunc(mStoredOnEnterFrame); - } - - /** - @exclude - */ - public function start () : void { - startActionFunc(); - } - - /** - @exclude - */ - public function stop () : void { - stopActionFunc(); - } - - public function die () : void { - stop(); - mFramePulse.die(); - delete mStoredOnEnterFrame; - } - - /** - @exclude - */ - public function idle () : void { - var f:Function = function () {}; - setActionFunc(f); - } - - /** - The worker is busy when its onEnterFrame is not undefined. - @exclude - */ - public function isBusy () : Boolean { - return mActionFunc != undefined; - } - - public function get onEnterFrame () : Function { - return mActionFunc; - } - - /** - @exclude - The end time of the animation. Used by AQxxx classes. - */ - public function get endTime () : Number { - return mEndTime; - } - public function set endTime (t:Number) : void { - mEndTime = t; - } - - /** - @exclude - */ - public function toString () : String { - return "; AQWorker " + mName; - } - - /** - @exclude - Lets the inWorker (thus the queue) pause between actions. Do not call this method directly, but use ActionQueue.addPause(). - @param inDuration : length of wait in seconds; if 0, waiting is infinite - @return A new ActionQueuePerformData object. - @implementationNote This method is called by ActionQueue.addPause(). - */ - public function wait (inDuration:Number) : ActionQueuePerformData { - var waitFunction:Function = function () { - if (inDuration == 0) return; // infinite: do not end - }; - return new ActionQueuePerformData(waitFunction, inDuration); - } - - /** - Do not call this method directly, but use {@link AQReturnValue#returnValue}. - @param inPerformData : data object with perform instructions - @implementationNote This method is called by virtually all AQxxx classes. - */ - public function returnValue (inPerformData:ActionQueuePerformData) : void { - - var effect:Function = inPerformData.effect; - var hasEffectParams:Boolean = (inPerformData.effectParams != undefined) && (inPerformData.effectParams.length > 0); - - var duration:Number = inPerformData.duration * 1000; // translate to milliseconds - var dur_f = 1 / duration; // use a multiply factor for speed - mEndTime = flash.utils.getTimer() + duration; - - var startValue:Number = (inPerformData.start != null) ? inPerformData.start : 0; - var endValue:Number = (inPerformData.end != null) ? inPerformData.end : 1000; - - var perc:Number, value:Number, now:Number; - var range:Number = endValue - startValue; - - var params:Array; - var ref:AQWorker = this; - - if (duration == 0) { - var f = function () { - if (inPerformData.method() == false) { - ref.stop(); - } - }; - setActionFunc(f); - return; - } - - var f:Function = function () { - now = flash.utils.getTimer(); - if (ref.endTime > now) { - perc = (ref.endTime - now) * dur_f; // multiply is faster than division - if (effect) { - if (hasEffectParams) { - params = [1 - perc, startValue, range, 1].concat(inPerformData.effectParams); - value = Number(effect.apply(null, params)); - } else { - value = Number(effect.call(null, 1 - perc, startValue, range, 1)); - } - } else { - value = endValue - (perc * range); - } - if (inPerformData.method.call(inPerformData.methodOwner, value) == false) { - // the performing method has returned false, so end this action - ref.stop(); - } - } else { - // end of loop - if (inPerformData.loop) { - ref.returnValue(inPerformData); - } else { - // not a loop - value = endValue; - ref.stop(); - if (inPerformData.method.call(inPerformData.methodOwner, value) != false) { - // only call the afterMethod function if this action has not been aborted - if (inPerformData.afterMethod != undefined) { - inPerformData.afterMethod.apply(); - } - } - } - } - }; - setActionFunc(f); - } - - private function setActionFunc (inFunction:Function) : void { - stopActionFunc(); - mActionFunc = inFunction; - startActionFunc(); - } - - private function startActionFunc () : void { - if (mActionFunc) { - mFramePulse.addEnterFrameListener(mActionFunc); - } - } - - private function stopActionFunc () : void { - if (mActionFunc) { - mFramePulse.removeEnterFrameListener(mActionFunc); - } - delete mActionFunc; - mActionFunc = null; - } - - } - -} \ No newline at end of file +/* +Copyright 2005-2006 by the authors of asapframework, http://asapframework.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.asapframework.util.actionqueue { + + import flash.events.EventDispatcher; + import flash.events.Event; + + import org.asapframework.util.actionqueue.ActionQueueData; + import org.asapframework.util.actionqueue.ActionQueueEvent; + import org.asapframework.util.actionqueue.ActionQueuePerformData; + import org.asapframework.util.debug.Log; + import org.asapframework.util.FramePulse; + + + /** + Scripted animation and function flow class. ActionQueue stores and runs a series of functions/methods one after the other. You can call local functions, object methods and special movieclip control methods, such as timed "fade", "move" or "pulse" functions. + ActionQueue is handy when you need timed animation, state transitions, complex button behavior or a series of functions that need to wait for a certain condition before they are run. You can insert waiting for messages or variable conditions (see {@link ExtendedActionQueue}). + The most common use for ActionQueue is to manipulate movieclips. + + <b>Adding actions to the queue</b> + {@link #addAction} (<code>myFunction</code>) : Adds a (locally scoped) function or an anonymous function. + {@link #addAction} (<code>myObj, myMethod</code>) : Adds an object's method. + {@link #addAction} (<code>myObj, myMethodName</code>) : Adds an object's method by using the method's name. The object's method does not have to be known at the time that it is added to the queue. + {@link #addAction} (<code>myAQAction</code>) : Adds a custom movieclip action from one of the AQxxx classes; use fade, scale, move, etcetera. See the list of available action methods at addAction, or create your own action method. + {@link #addInAction}: As addAction, but in a separately spawned thread; this eliminates the need to create separate methods and queues for movieclip actions that should occur at the same time. + + See also the method list summary. + + <b>On effects</b> + ActionQueue 'AQ' methods such as {@link AQScale#scale} may use Flash' easing effects from mx.transitions.easing. You can use the default mx.transitions.easing effects, or define your own. + + Example with mx.transitions.easing.Elastic: + <code> + import mx.transitions.easing.*; + queue.addAction( AQScale.scale, my_mc, 1, null, null, 100, 100, Elastic.easeIn ); + </code> + + <b>Advanced Queue functions</b> + To use conditional messages, conditions and looping, use {@link ExtendedActionQueue}. + + <b>Simultaneous effects</b> + To control different movieclip aspects at the same time, for instance to move a clip and fade it out, use {@link #addInAction}, or use {@link AQReturnValue} (example given below at {@link #addAction}). + + @author Arthur Clemens + @use + This code example demonstrates a combination of ActionQueue methods, to give an idea of how this class can be used in an application. + <code> + import org.asapframework.util.actionqueue.*; + import mx.transitions.easing.*; + </code> + Create the ActionQueue instance: + <code> + var queue:ActionQueue = new ActionQueue(); + </code> + With addAction you can use methods from AQSet to set properties of movieclips: + <code> + queue.addAction( AQSet.setAlpha, circle_mc, 75 ); + queue.addAction( AQSet.centerOnStage, circle_mc ); + queue.addAction( AQMove.move, circle_mc, 4, null, null, 0, 0, Bounce.easeInOut); + </code> + To add a pause, use <code>addPause(number of seconds)</code>, where 0 means wait forever - indefinite pauses can be terminated by {@link #skip}, {@link ExtendedActionQueue#addContinueOnMessage} and {@link ExtendedActionQueue#addContinueOnCondition}. + <code> + queue.addPause( 0.5 ); + queue.addAction( AQFade.fade, circle_mc, 2, null, 100, Regular.easeIn ); + </code> + All actions are added. Now let them perform: + <code> + queue.run(); + </code> + <hr /> + We decide to let the button pulse, to indicate that the button has primary focus. + We create a pulse queue in the button class: + <code> + import org.asapframework.util.actionqueue.*; + + class LoadButton extends MovieClip { + + private var mQueue:ActionQueue; + + public function activate () : void { + mQueue = new ActionQueue(); + // pulse with infinite duration: + var duration:Number = 0; + mQueue.addAction( AQPulse.pulse, this, null, 0.5, 100, 40, 100, duration ); + mQueue.run(); + } + + public function deactivate () : void { + mQueue.quit(); + } + } + </code> + + @see ExtendedActionQueue + @see AQAddMove + @see AQBlink + @see AQColor + @see AQCurve + @see AQFade + @see AQFollowMouse + @see AQMove + @see AQMoveRel + @see AQProperty + @see AQPulse + @see AQReturnValue + @see AQRotate + @see AQScale + @see AQSet + @see AQSpring + @see AQTimeline + @see AQZoom + */ + + public class ActionQueue extends EventDispatcher { + + private var mActions:Array; + private var mLoopCount:int; + private var mName:String; + private var mWorker:AQWorker; + private var mIsPaused:Boolean; + private var mNestedQueues:Array; + + // types + private var ACTION_TYPE:int = 0; + + /** + Calculates the relative value between start and end of a function at moment inPercentage in time. For instance with a movieclip that is moved by a function from A to B, <code>relativeValue</code> calculates the position of the movieclip at moment inPercentage. + @param inStart : the start value of the object that is changing, for instance the start _x position + @param inEnd : the end value of the object that is changing, for instance the end _x position + @param inPercentage: the current moment in time expressed as a percentage value + @return The relative value between inStart and inEnd at moment inPercentage. + @implementationNote: The used calculation is <code>inStart + (inPercentage * (inEnd - inStart))</code> + @example + <code> + public function moveToActualPosition () : void { + mStartIntroPosition = new Point(_x, _y); + mStartIntroScale = _xscale; + var duration:Number = 2.0; + var queue:ActionQueue = new ActionQueue(); + queue.addAction( AQReturnValue.returnValue, this, "performMoveToActualPosition", duration, 0, 1); + queue.run(); + } + + private function performMoveToActualPosition (inPercentage:Number) : void { + _x = ActionQueue.relativeValue( mStartIntroPosition.x, mPosition.x, inPercentage ); + _y = ActionQueue.relativeValue( mStartIntroPosition.y, mPosition.y, inPercentage ); + _xscale = _yscale = ActionQueue.relativeValue( mStartIntroScale, mScale, inPercentage ); + } + </code> + */ + public static function relativeValue (inStart:Number, inEnd:Number, inPercentage:Number) : Number { + return inStart + (inPercentage * (inEnd - inStart)); + } + + /** + Creates and initializes a new ActionQueue object. + @param inName : (optional) unique identifying name for the queue + @usageNote When an ActionQueue performs a function on an object or movieclip, the queue will keep on executing when the object is deleted. And because the reference to the queue still exists, the object will stay alive as long as the queue is active. This will lead to a memory leak. So when you delete an object, you are also responsible yourself for deleting the queue. + @example + <code> + public function onActionQueueStarted (e:ActionQueueEvent) : void { + Log.debug("queue " + e.name + " has started"); + } + public function onActionQueueFinished (e:ActionQueueEvent) : void { + Log.debug("queue " + e.name + " has finished"); + } + </code> + <code> + var queue:ActionQueue = new ActionQueue( "main queue" ); + queue.addEventListener(ActionQueueEvent.QUEUE_STARTED, this); + queue.addEventListener(ActionQueueEvent.QUEUE_FINISHED, this); + </code> + <hr /> + If you don't need a queue status report you can create a queue in a more simple way: + <code> + var queue:ActionQueue = new ActionQueue(); + </code> + */ + function ActionQueue (inName:String = "anonymous ActionQueue") { + super(); + mName = inName; + mActions = new Array(); + mWorker = new AQWorker(inName); + mIsPaused = false; + } + + /** + Overloaded method that accepts a number of argument configurations. + + <b>Adding a function</b> + Will be called in local scope. + <code>public function addAction ( inFunction:Function, argument1, argument2, ... ) : ActionQueue</code> + + <b>Adding a object's method</b> + Will be called in the object's scope. + <code>public function addAction ( inMethodObject:Object, inMethod:Function, argument1, argument2, ... ) : ActionQueue</code> + + <b>Adding a object's method by name</b> + Will be called in the object's scope. + <code>public function addAction ( inMethodObject:Object, inMethodName:String, argument1, argument2, ... ) : ActionQueue</code> + + <b>Adding an action that will perform a function on an onEnterFrame</b> + Such as movieclip control methods (like {@link AQMove#move}) (will be called in {@link AQWorker AQWorker's} scope). + <code>public function addAction ( inFunction:Function, argument1, argument2, ... ) : ActionQueue</code> + The function inFunction should return a {@link ActionQueuePerformData} object. + @example + <b>Add a Custom interface/movieclip control method</b> + + Use any function that returns a {@link ActionQueuePerformData}, or use one of the ready made class metods from these classes: + {@link AQAddMove} + {@link AQBlink} + {@link AQColor} + {@link AQFade} + {@link AQFollowMouse} + {@link AQMove} + {@link AQMoveRel} + {@link AQPulse} + {@link AQReturnValue} + {@link AQScale} + {@link AQSet} + {@link AQSpring} + {@link AQTimeline} + + This example will move a movieclip from its current position (null, null) to a new position (500, the current y value), during 1 second: + <code> + queue.addAction( AQMove.move, my_mc, 1, null, null, 500, null ); + </code> + This example sets the alpha property of a movieclip to 50: + <code> + queue.addAction( AQSet.setAlpha, my_mc, 50 ); + </code> + + <hr /> + + You can also create a <b>custom function</b> and pass this to the queue. This is especially useful when you need to have more complex interaction with the objects to control. + + Follows an example of a function that is very similar to AQxxx class methods, and is in fact copied from {@link AQMove#move} - with the difference that we want to fade out the movieclip while it is moving. + <code> + // somewhere in your class + public function moveAndFade (inMC:DisplayObject, + inDuration:Number, + inStartX:Number, + inStartY:Number, + inEndX:Number, + inEndY:Number, + inEffect:Function ) : ActionQueuePerformData { + + // initalize variables here + + var performFunction:Function = function (inPerc:Number) : Boolean { + // do something with the received inPerc + return true; + }; + + // Set up the data so ActionQueue will perform the function performFunction: + var startValue:Number = 1.0; // counting from 1 down to 0 + var endValue:Number = 0; + return new ActionQueuePerformData( performFunction, inDuration, startValue, endValue, inEffect ); + } + </code> + Note that <code>performFunction</code> returns a Boolean. To abort <code>performFunction</code> let it return false. + + Now you add the function to the queue using addAction: + <code> + var queue:ActionQueue = new ActionQueue(); + queue.addAction( this, moveAndFade, my_mc, 5, null, null, 500, 200, Regular.easeInOut ); + queue.run(); + </code> + + */ + public function addAction (...args:Array) : ActionQueue { + + var firstParam:* = args[0]; + + if (firstParam is Array) { + // when sent from addInAction + args = firstParam; + firstParam = args[0]; + } + + + if (firstParam is Function) { + return AQaddFunction(args); + } ... [truncated message content] |
From: <aci...@us...> - 2007-06-24 19:49:15
|
Revision: 704 http://asapframework.svn.sourceforge.net/asapframework/?rev=704&view=rev Author: acidcats Date: 2007-06-24 12:49:07 -0700 (Sun, 24 Jun 2007) Log Message: ----------- Obsolete folder removed Removed Paths: ------------- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-24 19:49:06
|
Revision: 704 http://svn.sourceforge.net/asapframework/?rev=704&view=rev Author: acidcats Date: 2007-06-24 12:49:07 -0700 (Sun, 24 Jun 2007) Log Message: ----------- Obsolete folder removed Removed Paths: ------------- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-24 19:46:57
|
Revision: 703 http://asapframework.svn.sourceforge.net/asapframework/?rev=703&view=rev Author: acidcats Date: 2007-06-24 12:46:58 -0700 (Sun, 24 Jun 2007) Log Message: ----------- Adapted FramePulseTestCase to FramePulse interface Modified Paths: -------------- branches/dev_as3/asapframework/test/unit/AllTests.as branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as Modified: branches/dev_as3/asapframework/test/unit/AllTests.as =================================================================== --- branches/dev_as3/asapframework/test/unit/AllTests.as 2007-06-24 19:41:19 UTC (rev 702) +++ branches/dev_as3/asapframework/test/unit/AllTests.as 2007-06-24 19:46:58 UTC (rev 703) @@ -16,8 +16,8 @@ //addTest(new TreeTestCase()); //addTest(new TreeEnumeratorTestCase()); //addTest(new BooleanUtilsTestCase()); - //addTest(new FramePulseTestCase()); - addTest(new FrameDelayTestCase()); + addTest(new FramePulseTestCase()); + //addTest(new FrameDelayTestCase()); //addTest(new ActionQueueTestCase()); } } Modified: branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as =================================================================== --- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as 2007-06-24 19:41:19 UTC (rev 702) +++ branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as 2007-06-24 19:46:58 UTC (rev 703) @@ -1,24 +1,20 @@ -package org.asapframework.util.framepulse { +package org.asapframework.util { import asunit.framework.TestCase; import flash.events.Event; - import org.asapframework.util.framepulse.FramePulse; + import org.asapframework.util.FramePulse; public class FramePulseTestCase extends TestCase { private static var ALL_METHODS_CALLED_COUNT:Number = 1; private static var sMethodsCalledCount:Number = 0; - private static var sCallTestCalled:Boolean = false; - private static var sFramePulse:FramePulse; + /** Override run to pause test */ public override function run() : void { - if (!sFramePulse) { - sFramePulse = new FramePulse(); - } - sFramePulse.addEnterFrameListener(callTest); + FramePulse.addEnterFrameListener(callTest); } /** @@ -26,18 +22,14 @@ */ private function callTest (e:Event) : void { sMethodsCalledCount++; - sCallTestCalled = true; + super.run(); } public function testEvaluateResult () : void { - assertTrue("FramePulseTestCase testEvaluateResult", sMethodsCalledCount == ALL_METHODS_CALLED_COUNT); - sFramePulse.removeEnterFrameListener(callTest); + assertEquals(sMethodsCalledCount, ALL_METHODS_CALLED_COUNT); + + FramePulse.removeEnterFrameListener(callTest); } - - public function testDie () : void { - sFramePulse.die(); - } - } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-24 19:46:57
|
Revision: 703 http://svn.sourceforge.net/asapframework/?rev=703&view=rev Author: acidcats Date: 2007-06-24 12:46:58 -0700 (Sun, 24 Jun 2007) Log Message: ----------- Adapted FramePulseTestCase to FramePulse interface Modified Paths: -------------- branches/dev_as3/asapframework/test/unit/AllTests.as branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as Modified: branches/dev_as3/asapframework/test/unit/AllTests.as =================================================================== --- branches/dev_as3/asapframework/test/unit/AllTests.as 2007-06-24 19:41:19 UTC (rev 702) +++ branches/dev_as3/asapframework/test/unit/AllTests.as 2007-06-24 19:46:58 UTC (rev 703) @@ -16,8 +16,8 @@ //addTest(new TreeTestCase()); //addTest(new TreeEnumeratorTestCase()); //addTest(new BooleanUtilsTestCase()); - //addTest(new FramePulseTestCase()); - addTest(new FrameDelayTestCase()); + addTest(new FramePulseTestCase()); + //addTest(new FrameDelayTestCase()); //addTest(new ActionQueueTestCase()); } } Modified: branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as =================================================================== --- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as 2007-06-24 19:41:19 UTC (rev 702) +++ branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as 2007-06-24 19:46:58 UTC (rev 703) @@ -1,24 +1,20 @@ -package org.asapframework.util.framepulse { +package org.asapframework.util { import asunit.framework.TestCase; import flash.events.Event; - import org.asapframework.util.framepulse.FramePulse; + import org.asapframework.util.FramePulse; public class FramePulseTestCase extends TestCase { private static var ALL_METHODS_CALLED_COUNT:Number = 1; private static var sMethodsCalledCount:Number = 0; - private static var sCallTestCalled:Boolean = false; - private static var sFramePulse:FramePulse; + /** Override run to pause test */ public override function run() : void { - if (!sFramePulse) { - sFramePulse = new FramePulse(); - } - sFramePulse.addEnterFrameListener(callTest); + FramePulse.addEnterFrameListener(callTest); } /** @@ -26,18 +22,14 @@ */ private function callTest (e:Event) : void { sMethodsCalledCount++; - sCallTestCalled = true; + super.run(); } public function testEvaluateResult () : void { - assertTrue("FramePulseTestCase testEvaluateResult", sMethodsCalledCount == ALL_METHODS_CALLED_COUNT); - sFramePulse.removeEnterFrameListener(callTest); + assertEquals(sMethodsCalledCount, ALL_METHODS_CALLED_COUNT); + + FramePulse.removeEnterFrameListener(callTest); } - - public function testDie () : void { - sFramePulse.die(); - } - } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-24 19:41:57
|
Revision: 702 http://asapframework.svn.sourceforge.net/asapframework/?rev=702&view=rev Author: acidcats Date: 2007-06-24 12:41:19 -0700 (Sun, 24 Jun 2007) Log Message: ----------- Moved FramePulseTestCase conform location of FramePulse class in lib package Added Paths: ----------- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as Removed Paths: ------------- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as Copied: branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as (from rev 701, branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as) =================================================================== --- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as (rev 0) +++ branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as 2007-06-24 19:41:19 UTC (rev 702) @@ -0,0 +1,43 @@ +package org.asapframework.util.framepulse { + + import asunit.framework.TestCase; + import flash.events.Event; + import org.asapframework.util.framepulse.FramePulse; + + public class FramePulseTestCase extends TestCase { + + private static var ALL_METHODS_CALLED_COUNT:Number = 1; + private static var sMethodsCalledCount:Number = 0; + private static var sCallTestCalled:Boolean = false; + private static var sFramePulse:FramePulse; + + /** + Override run to pause test + */ + public override function run() : void { + if (!sFramePulse) { + sFramePulse = new FramePulse(); + } + sFramePulse.addEnterFrameListener(callTest); + } + + /** + Resume test + */ + private function callTest (e:Event) : void { + sMethodsCalledCount++; + sCallTestCalled = true; + super.run(); + } + + public function testEvaluateResult () : void { + assertTrue("FramePulseTestCase testEvaluateResult", sMethodsCalledCount == ALL_METHODS_CALLED_COUNT); + sFramePulse.removeEnterFrameListener(callTest); + } + + public function testDie () : void { + sFramePulse.die(); + } + + } +} \ No newline at end of file Deleted: branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as =================================================================== --- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as 2007-06-24 19:15:55 UTC (rev 701) +++ branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as 2007-06-24 19:41:19 UTC (rev 702) @@ -1,43 +0,0 @@ -package org.asapframework.util.framepulse { - - import asunit.framework.TestCase; - import flash.events.Event; - import org.asapframework.util.framepulse.FramePulse; - - public class FramePulseTestCase extends TestCase { - - private static var ALL_METHODS_CALLED_COUNT:Number = 1; - private static var sMethodsCalledCount:Number = 0; - private static var sCallTestCalled:Boolean = false; - private static var sFramePulse:FramePulse; - - /** - Override run to pause test - */ - public override function run() : void { - if (!sFramePulse) { - sFramePulse = new FramePulse(); - } - sFramePulse.addEnterFrameListener(callTest); - } - - /** - Resume test - */ - private function callTest (e:Event) : void { - sMethodsCalledCount++; - sCallTestCalled = true; - super.run(); - } - - public function testEvaluateResult () : void { - assertTrue("FramePulseTestCase testEvaluateResult", sMethodsCalledCount == ALL_METHODS_CALLED_COUNT); - sFramePulse.removeEnterFrameListener(callTest); - } - - public function testDie () : void { - sFramePulse.die(); - } - - } -} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-24 19:41:56
|
Revision: 702 http://svn.sourceforge.net/asapframework/?rev=702&view=rev Author: acidcats Date: 2007-06-24 12:41:19 -0700 (Sun, 24 Jun 2007) Log Message: ----------- Moved FramePulseTestCase conform location of FramePulse class in lib package Added Paths: ----------- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as Removed Paths: ------------- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as Copied: branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as (from rev 701, branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as) =================================================================== --- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as (rev 0) +++ branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FramePulseTestCase.as 2007-06-24 19:41:19 UTC (rev 702) @@ -0,0 +1,43 @@ +package org.asapframework.util.framepulse { + + import asunit.framework.TestCase; + import flash.events.Event; + import org.asapframework.util.framepulse.FramePulse; + + public class FramePulseTestCase extends TestCase { + + private static var ALL_METHODS_CALLED_COUNT:Number = 1; + private static var sMethodsCalledCount:Number = 0; + private static var sCallTestCalled:Boolean = false; + private static var sFramePulse:FramePulse; + + /** + Override run to pause test + */ + public override function run() : void { + if (!sFramePulse) { + sFramePulse = new FramePulse(); + } + sFramePulse.addEnterFrameListener(callTest); + } + + /** + Resume test + */ + private function callTest (e:Event) : void { + sMethodsCalledCount++; + sCallTestCalled = true; + super.run(); + } + + public function testEvaluateResult () : void { + assertTrue("FramePulseTestCase testEvaluateResult", sMethodsCalledCount == ALL_METHODS_CALLED_COUNT); + sFramePulse.removeEnterFrameListener(callTest); + } + + public function testDie () : void { + sFramePulse.die(); + } + + } +} \ No newline at end of file Deleted: branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as =================================================================== --- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as 2007-06-24 19:15:55 UTC (rev 701) +++ branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/framepulse/FramePulseTestCase.as 2007-06-24 19:41:19 UTC (rev 702) @@ -1,43 +0,0 @@ -package org.asapframework.util.framepulse { - - import asunit.framework.TestCase; - import flash.events.Event; - import org.asapframework.util.framepulse.FramePulse; - - public class FramePulseTestCase extends TestCase { - - private static var ALL_METHODS_CALLED_COUNT:Number = 1; - private static var sMethodsCalledCount:Number = 0; - private static var sCallTestCalled:Boolean = false; - private static var sFramePulse:FramePulse; - - /** - Override run to pause test - */ - public override function run() : void { - if (!sFramePulse) { - sFramePulse = new FramePulse(); - } - sFramePulse.addEnterFrameListener(callTest); - } - - /** - Resume test - */ - private function callTest (e:Event) : void { - sMethodsCalledCount++; - sCallTestCalled = true; - super.run(); - } - - public function testEvaluateResult () : void { - assertTrue("FramePulseTestCase testEvaluateResult", sMethodsCalledCount == ALL_METHODS_CALLED_COUNT); - sFramePulse.removeEnterFrameListener(callTest); - } - - public function testDie () : void { - sFramePulse.die(); - } - - } -} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-24 19:17:34
|
Revision: 701 http://asapframework.svn.sourceforge.net/asapframework/?rev=701&view=rev Author: acidcats Date: 2007-06-24 12:15:55 -0700 (Sun, 24 Jun 2007) Log Message: ----------- Adapted test code to Flash CS3 - AsUnitTestRunner is now Document Class, moved to test folder Modified Paths: -------------- branches/dev_as3/asapframework/test/unit/AllTests.as branches/dev_as3/asapframework/test/unit/Tester.fla branches/dev_as3/asapframework/test/unit/Tester.swf branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as Removed Paths: ------------- branches/dev_as3/asapframework/test/unit/lib/asunit3/AsUnitTestRunner.as Added: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as 2007-06-24 19:15:55 UTC (rev 701) @@ -0,0 +1,28 @@ +/** +* ... +* @author Default +* @version 0.1 +*/ + +package org.asapframework.management.lang { + import org.asapframework.data.xml.IParsable; + + public class TextItemData implements IParsable { + public var text:String; + public var id:Number; + + /** + + */ + public function ItemData (inID:Number, inText:String) { + id = inID; + text = inText; + } + + public function parseXML (o:XML) : Boolean { + id = o.@id; + text = o; + } + } + +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj =================================================================== --- branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj (rev 0) +++ branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj 2007-06-24 19:15:55 UTC (rev 701) @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <!-- Output SWF options --> + <output> + <movie disabled="True" /> + <movie input="" /> + <movie path="" /> + <movie fps="21" /> + <movie width="300" /> + <movie height="300" /> + <movie version="9" /> + <movie background="#FFFFFF" /> + </output> + <!-- Other classes to be compiled into your SWF --> + <classpaths> + <class path="." /> + <class path="..\..\lib" /> + <class path="..\..\..\..\..\..\..\Yalog\Yalog_AS3" /> + </classpaths> + <!-- Build options --> + <build> + <option accessible="False" /> + <option allowSourcePathOverlap="False" /> + <option benchmark="False" /> + <option es="False" /> + <option loadConfig="" /> + <option optimize="False" /> + <option showActionScriptWarnings="True" /> + <option showBindingWarnings="True" /> + <option showDeprecationWarnings="True" /> + <option showUnusedTypeSelectorWarnings="True" /> + <option strict="True" /> + <option useNetwork="True" /> + <option useResourceBundleMetadata="True" /> + <option warnings="True" /> + <option verboseStackTraces="False" /> + <option additional="" /> + </build> + <!-- SWC Include Libraries --> + <includeLibraries> + <!-- example: <element path="..." /> --> + </includeLibraries> + <!-- SWC Libraries --> + <libraryPaths> + <!-- example: <element path="..." /> --> + </libraryPaths> + <!-- External Libraries --> + <externalLibraryPaths> + <!-- example: <element path="..." /> --> + </externalLibraryPaths> + <!-- Runtime Shared Libraries --> + <rslPaths> + <!-- example: <element path="..." /> --> + </rslPaths> + <!-- Class files to compile (other referenced classes will automatically be included) --> + <compileTargets> + <!-- example: <compile path="..." /> --> + </compileTargets> + <!-- Paths to exclude from the Project Explorer tree --> + <hiddenPaths> + <!-- example: <hidden path="..." /> --> + </hiddenPaths> + <!-- Executed before build --> + <preBuildCommand>cmd /k "$(ToolsDir)/flashide/buildmovie.jsfl"</preBuildCommand> + <!-- Executed after build --> + <postBuildCommand alwaysRun="False" /> + <!-- Other project options --> + <options> + <option showHiddenPaths="False" /> + <option testMovie="NewTab" /> + </options> +</project> \ No newline at end of file Property changes on: branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj ___________________________________________________________________ Name: svn:eol-style + native Modified: branches/dev_as3/asapframework/test/unit/AllTests.as =================================================================== --- branches/dev_as3/asapframework/test/unit/AllTests.as 2007-06-11 20:10:44 UTC (rev 700) +++ branches/dev_as3/asapframework/test/unit/AllTests.as 2007-06-24 19:15:55 UTC (rev 701) @@ -17,8 +17,8 @@ //addTest(new TreeEnumeratorTestCase()); //addTest(new BooleanUtilsTestCase()); //addTest(new FramePulseTestCase()); - //addTest(new FrameDelayTestCase()); - addTest(new ActionQueueTestCase()); + addTest(new FrameDelayTestCase()); + //addTest(new ActionQueueTestCase()); } } Added: branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as =================================================================== --- branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as (rev 0) +++ branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as 2007-06-24 19:15:55 UTC (rev 701) @@ -0,0 +1,10 @@ +package { + import asunit.textui.TestRunner; + + public class AsUnitTestRunner extends TestRunner { + + public function AsUnitTestRunner() { + start(AllTests, null, TestRunner.SHOW_TRACE); + } + } +} Property changes on: branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as ___________________________________________________________________ Name: svn:eol-style + native Modified: branches/dev_as3/asapframework/test/unit/Tester.fla =================================================================== (Binary files differ) Modified: branches/dev_as3/asapframework/test/unit/Tester.swf =================================================================== (Binary files differ) Deleted: branches/dev_as3/asapframework/test/unit/lib/asunit3/AsUnitTestRunner.as =================================================================== --- branches/dev_as3/asapframework/test/unit/lib/asunit3/AsUnitTestRunner.as 2007-06-11 20:10:44 UTC (rev 700) +++ branches/dev_as3/asapframework/test/unit/lib/asunit3/AsUnitTestRunner.as 2007-06-24 19:15:55 UTC (rev 701) @@ -1,15 +0,0 @@ -package { - - import flash.display.Stage; - import asunit.textui.TestRunner; - - public class AsUnitTestRunner extends TestRunner { - - public static var timeline:Stage; - - public function AsUnitTestRunner(inStage:Stage) { - timeline = inStage; - start(AllTests, null, TestRunner.SHOW_TRACE); - } - } -} Modified: branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as =================================================================== --- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as 2007-06-11 20:10:44 UTC (rev 700) +++ branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as 2007-06-24 19:15:55 UTC (rev 701) @@ -1,8 +1,10 @@ package org.asapframework.util { import asunit.framework.TestCase; - import org.asapframework.util.*; - + + import org.asapframework.util.FrameDelay; + + public class FrameDelayTestCase extends TestCase { private static var sMethodsCalledCount:Number = 0; @@ -10,7 +12,7 @@ private static var sCallTestCalled:Boolean = false; public override function run () : void { - var fd:FrameDelay = new FrameDelay(this, callTest, 2); + var fd:FrameDelay = new FrameDelay(callTest, 2); } public function testEvaluateResult () : void { @@ -25,5 +27,9 @@ super.run(); } + public override function toString () : String { + return ";org.asapframework.util.FrameDelayTestCase"; + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-24 19:17:02
|
Revision: 701 http://svn.sourceforge.net/asapframework/?rev=701&view=rev Author: acidcats Date: 2007-06-24 12:15:55 -0700 (Sun, 24 Jun 2007) Log Message: ----------- Adapted test code to Flash CS3 - AsUnitTestRunner is now Document Class, moved to test folder Modified Paths: -------------- branches/dev_as3/asapframework/test/unit/AllTests.as branches/dev_as3/asapframework/test/unit/Tester.fla branches/dev_as3/asapframework/test/unit/Tester.swf branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as Removed Paths: ------------- branches/dev_as3/asapframework/test/unit/lib/asunit3/AsUnitTestRunner.as Added: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as 2007-06-24 19:15:55 UTC (rev 701) @@ -0,0 +1,28 @@ +/** +* ... +* @author Default +* @version 0.1 +*/ + +package org.asapframework.management.lang { + import org.asapframework.data.xml.IParsable; + + public class TextItemData implements IParsable { + public var text:String; + public var id:Number; + + /** + + */ + public function ItemData (inID:Number, inText:String) { + id = inID; + text = inText; + } + + public function parseXML (o:XML) : Boolean { + id = o.@id; + text = o; + } + } + +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/lang/TextItemData.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj =================================================================== --- branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj (rev 0) +++ branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj 2007-06-24 19:15:55 UTC (rev 701) @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <!-- Output SWF options --> + <output> + <movie disabled="True" /> + <movie input="" /> + <movie path="" /> + <movie fps="21" /> + <movie width="300" /> + <movie height="300" /> + <movie version="9" /> + <movie background="#FFFFFF" /> + </output> + <!-- Other classes to be compiled into your SWF --> + <classpaths> + <class path="." /> + <class path="..\..\lib" /> + <class path="..\..\..\..\..\..\..\Yalog\Yalog_AS3" /> + </classpaths> + <!-- Build options --> + <build> + <option accessible="False" /> + <option allowSourcePathOverlap="False" /> + <option benchmark="False" /> + <option es="False" /> + <option loadConfig="" /> + <option optimize="False" /> + <option showActionScriptWarnings="True" /> + <option showBindingWarnings="True" /> + <option showDeprecationWarnings="True" /> + <option showUnusedTypeSelectorWarnings="True" /> + <option strict="True" /> + <option useNetwork="True" /> + <option useResourceBundleMetadata="True" /> + <option warnings="True" /> + <option verboseStackTraces="False" /> + <option additional="" /> + </build> + <!-- SWC Include Libraries --> + <includeLibraries> + <!-- example: <element path="..." /> --> + </includeLibraries> + <!-- SWC Libraries --> + <libraryPaths> + <!-- example: <element path="..." /> --> + </libraryPaths> + <!-- External Libraries --> + <externalLibraryPaths> + <!-- example: <element path="..." /> --> + </externalLibraryPaths> + <!-- Runtime Shared Libraries --> + <rslPaths> + <!-- example: <element path="..." /> --> + </rslPaths> + <!-- Class files to compile (other referenced classes will automatically be included) --> + <compileTargets> + <!-- example: <compile path="..." /> --> + </compileTargets> + <!-- Paths to exclude from the Project Explorer tree --> + <hiddenPaths> + <!-- example: <hidden path="..." /> --> + </hiddenPaths> + <!-- Executed before build --> + <preBuildCommand>cmd /k "$(ToolsDir)/flashide/buildmovie.jsfl"</preBuildCommand> + <!-- Executed after build --> + <postBuildCommand alwaysRun="False" /> + <!-- Other project options --> + <options> + <option showHiddenPaths="False" /> + <option testMovie="NewTab" /> + </options> +</project> \ No newline at end of file Property changes on: branches/dev_as3/asapframework/test/unit/ASAPTest.as3proj ___________________________________________________________________ Name: svn:eol-style + native Modified: branches/dev_as3/asapframework/test/unit/AllTests.as =================================================================== --- branches/dev_as3/asapframework/test/unit/AllTests.as 2007-06-11 20:10:44 UTC (rev 700) +++ branches/dev_as3/asapframework/test/unit/AllTests.as 2007-06-24 19:15:55 UTC (rev 701) @@ -17,8 +17,8 @@ //addTest(new TreeEnumeratorTestCase()); //addTest(new BooleanUtilsTestCase()); //addTest(new FramePulseTestCase()); - //addTest(new FrameDelayTestCase()); - addTest(new ActionQueueTestCase()); + addTest(new FrameDelayTestCase()); + //addTest(new ActionQueueTestCase()); } } Added: branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as =================================================================== --- branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as (rev 0) +++ branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as 2007-06-24 19:15:55 UTC (rev 701) @@ -0,0 +1,10 @@ +package { + import asunit.textui.TestRunner; + + public class AsUnitTestRunner extends TestRunner { + + public function AsUnitTestRunner() { + start(AllTests, null, TestRunner.SHOW_TRACE); + } + } +} Property changes on: branches/dev_as3/asapframework/test/unit/AsUnitTestRunner.as ___________________________________________________________________ Name: svn:eol-style + native Modified: branches/dev_as3/asapframework/test/unit/Tester.fla =================================================================== (Binary files differ) Modified: branches/dev_as3/asapframework/test/unit/Tester.swf =================================================================== (Binary files differ) Deleted: branches/dev_as3/asapframework/test/unit/lib/asunit3/AsUnitTestRunner.as =================================================================== --- branches/dev_as3/asapframework/test/unit/lib/asunit3/AsUnitTestRunner.as 2007-06-11 20:10:44 UTC (rev 700) +++ branches/dev_as3/asapframework/test/unit/lib/asunit3/AsUnitTestRunner.as 2007-06-24 19:15:55 UTC (rev 701) @@ -1,15 +0,0 @@ -package { - - import flash.display.Stage; - import asunit.textui.TestRunner; - - public class AsUnitTestRunner extends TestRunner { - - public static var timeline:Stage; - - public function AsUnitTestRunner(inStage:Stage) { - timeline = inStage; - start(AllTests, null, TestRunner.SHOW_TRACE); - } - } -} Modified: branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as =================================================================== --- branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as 2007-06-11 20:10:44 UTC (rev 700) +++ branches/dev_as3/asapframework/test/unit/tests/org/asapframework/util/FrameDelayTestCase.as 2007-06-24 19:15:55 UTC (rev 701) @@ -1,8 +1,10 @@ package org.asapframework.util { import asunit.framework.TestCase; - import org.asapframework.util.*; - + + import org.asapframework.util.FrameDelay; + + public class FrameDelayTestCase extends TestCase { private static var sMethodsCalledCount:Number = 0; @@ -10,7 +12,7 @@ private static var sCallTestCalled:Boolean = false; public override function run () : void { - var fd:FrameDelay = new FrameDelay(this, callTest, 2); + var fd:FrameDelay = new FrameDelay(callTest, 2); } public function testEvaluateResult () : void { @@ -25,5 +27,9 @@ super.run(); } + public override function toString () : String { + return ";org.asapframework.util.FrameDelayTestCase"; + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-11 20:10:42
|
Revision: 700 http://asapframework.svn.sourceforge.net/asapframework/?rev=700&view=rev Author: acidcats Date: 2007-06-11 13:10:44 -0700 (Mon, 11 Jun 2007) Log Message: ----------- Fixing removeMovie(), which now also removes loaded movie from display list & calls controller's die() method Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as 2007-06-11 20:09:53 UTC (rev 699) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as 2007-06-11 20:10:44 UTC (rev 700) @@ -69,10 +69,10 @@ } /** - Tries to find the movie with the specified name or controller, empties the attached movieclip and removes the movie data from the list - after this action, a movie has to be loaded again using loadMovieInClip - it is not checked whether a movie is being loaded, has been loaded or has been started, so this is tricky when a movie is in the loader - @param inMovie either :String: the name used as identifier for the movie to be removed, or :LocalController: the LocalController or :DisplayObject: the asset that was originally loaded + Find the movie with the specified name, container or controller, remove the object from the display list and remove the movie data from the list of movies + After this action, a movie has to be loaded again using loadMovie() + It is not checked whether a movie is being loaded, has been loaded or has been started, so this is tricky when a movie is in the loader + @param inMovie either :String: the name used as identifier for the movie to be removed, :LocalController: the LocalController or :DisplayObject: the asset that was originally loaded @return : false if the movie wasn't found, true otherwise */ public function removeMovie (inMovie:*) : Boolean { @@ -102,6 +102,12 @@ return false; } + // tell the controller to cleanup after itself + md.controller.die(); + + // remove the asset from the display list + md.container.parent.removeChild(md.container); + // remove from list of data objects mMovies.splice(mMovies.indexOf(md), 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-11 20:10:42
|
Revision: 700 http://svn.sourceforge.net/asapframework/?rev=700&view=rev Author: acidcats Date: 2007-06-11 13:10:44 -0700 (Mon, 11 Jun 2007) Log Message: ----------- Fixing removeMovie(), which now also removes loaded movie from display list & calls controller's die() method Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as 2007-06-11 20:09:53 UTC (rev 699) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as 2007-06-11 20:10:44 UTC (rev 700) @@ -69,10 +69,10 @@ } /** - Tries to find the movie with the specified name or controller, empties the attached movieclip and removes the movie data from the list - after this action, a movie has to be loaded again using loadMovieInClip - it is not checked whether a movie is being loaded, has been loaded or has been started, so this is tricky when a movie is in the loader - @param inMovie either :String: the name used as identifier for the movie to be removed, or :LocalController: the LocalController or :DisplayObject: the asset that was originally loaded + Find the movie with the specified name, container or controller, remove the object from the display list and remove the movie data from the list of movies + After this action, a movie has to be loaded again using loadMovie() + It is not checked whether a movie is being loaded, has been loaded or has been started, so this is tricky when a movie is in the loader + @param inMovie either :String: the name used as identifier for the movie to be removed, :LocalController: the LocalController or :DisplayObject: the asset that was originally loaded @return : false if the movie wasn't found, true otherwise */ public function removeMovie (inMovie:*) : Boolean { @@ -102,6 +102,12 @@ return false; } + // tell the controller to cleanup after itself + md.controller.die(); + + // remove the asset from the display list + md.container.parent.removeChild(md.container); + // remove from list of data objects mMovies.splice(mMovies.indexOf(md), 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-11 20:09:51
|
Revision: 699 http://svn.sourceforge.net/asapframework/?rev=699&view=rev Author: acidcats Date: 2007-06-11 13:09:53 -0700 (Mon, 11 Jun 2007) Log Message: ----------- Change in internal working of isStandalone() method Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-10 21:02:00 UTC (rev 698) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-11 20:09:53 UTC (rev 699) @@ -18,13 +18,19 @@ import flash.display.MovieClip; import org.asapframework.management.movie.MovieManager; + import org.asapframework.util.debug.Log; public class LocalController extends MovieClip implements ILocalController { private var mName : String; + private var mIsStandalone : Boolean; public function LocalController () { + // initialize standalone flag + mIsStandalone = ((stage != null) && (parent == stage)); + + // add to moviemanager if standalone if (isStandalone()) { MovieManager.getInstance().addLocalController(this); } @@ -50,7 +56,7 @@ } public function isStandalone () : Boolean { - return ((stage != null) && (parent == stage)); + return mIsStandalone; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-11 20:09:50
|
Revision: 699 http://asapframework.svn.sourceforge.net/asapframework/?rev=699&view=rev Author: acidcats Date: 2007-06-11 13:09:53 -0700 (Mon, 11 Jun 2007) Log Message: ----------- Change in internal working of isStandalone() method Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-10 21:02:00 UTC (rev 698) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-11 20:09:53 UTC (rev 699) @@ -18,13 +18,19 @@ import flash.display.MovieClip; import org.asapframework.management.movie.MovieManager; + import org.asapframework.util.debug.Log; public class LocalController extends MovieClip implements ILocalController { private var mName : String; + private var mIsStandalone : Boolean; public function LocalController () { + // initialize standalone flag + mIsStandalone = ((stage != null) && (parent == stage)); + + // add to moviemanager if standalone if (isStandalone()) { MovieManager.getInstance().addLocalController(this); } @@ -50,7 +56,7 @@ } public function isStandalone () : Boolean { - return ((stage != null) && (parent == stage)); + return mIsStandalone; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-10 21:01:59
|
Revision: 698 http://asapframework.svn.sourceforge.net/asapframework/?rev=698&view=rev Author: acidcats Date: 2007-06-10 14:02:00 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Changed to "2007" instead of "2005-2006" in copyright since it's all new code anyway Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as 2007-06-10 21:01:04 UTC (rev 697) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as 2007-06-10 21:02:00 UTC (rev 698) @@ -1,5 +1,5 @@ /* -Copyright 2005-2006 by the authors of asapframework, http://asapframework.org +Copyright 2007 by the authors of asapframework, http://asapframework.org Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as 2007-06-10 21:01:04 UTC (rev 697) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as 2007-06-10 21:02:00 UTC (rev 698) @@ -1,5 +1,5 @@ /* -Copyright 2005-2006 by the authors of asapframework, http://asapframework.org +Copyright 2007 by the authors of asapframework, http://asapframework.org Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-10 21:01:58
|
Revision: 698 http://svn.sourceforge.net/asapframework/?rev=698&view=rev Author: acidcats Date: 2007-06-10 14:02:00 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Changed to "2007" instead of "2005-2006" in copyright since it's all new code anyway Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as 2007-06-10 21:01:04 UTC (rev 697) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as 2007-06-10 21:02:00 UTC (rev 698) @@ -1,5 +1,5 @@ /* -Copyright 2005-2006 by the authors of asapframework, http://asapframework.org +Copyright 2007 by the authors of asapframework, http://asapframework.org Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as 2007-06-10 21:01:04 UTC (rev 697) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as 2007-06-10 21:02:00 UTC (rev 698) @@ -1,5 +1,5 @@ /* -Copyright 2005-2006 by the authors of asapframework, http://asapframework.org +Copyright 2007 by the authors of asapframework, http://asapframework.org Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-10 21:01:09
|
Revision: 697 http://asapframework.svn.sourceforge.net/asapframework/?rev=697&view=rev Author: acidcats Date: 2007-06-10 14:01:04 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Minor refactorings; Moved dispatching of START event to the moment the OPEN event from Loader is received Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-06-10 20:59:41 UTC (rev 696) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-06-10 21:01:04 UTC (rev 697) @@ -92,6 +92,7 @@ // create loader object var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaderEvent); + loader.contentLoaderInfo.addEventListener(Event.OPEN, handleLoadStarted); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleLoaderProgressEvent); //ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleLoaderEvent); @@ -104,12 +105,25 @@ // load object loader.load(new URLRequest(fd.url)); + } + + private function handleLoadStarted (e:Event) { + // get loader + var info:LoaderInfo = e.target as LoaderInfo; + + // get data for loader + var fd:FileData = getDataForLoaderInfo(info); + if (fd == null) { + Log.error("handleLoaderEvent: data for loader not found", toString()); + return; + } + // dispatch event we've started loading - var e:AssetLoaderEvent = new AssetLoaderEvent(AssetLoaderEvent.START, fd.name); - e.loader = loader; - e.loadedBytesCount = 0; - e.totalBytesCount = 0; - dispatchEvent(e); + var evt:AssetLoaderEvent = new AssetLoaderEvent(AssetLoaderEvent.START, fd.name); + evt.loader = fd.loader; + evt.loadedBytesCount = 0; + evt.totalBytesCount = 0; + dispatchEvent(evt); } private function handleLoaderEvent (e:Event) : void { @@ -122,7 +136,6 @@ Log.error("handleLoaderEvent: data for loader not found", toString()); return; } - var loader:Loader = fd.loader; // check if an IOError occurred var evt:AssetLoaderEvent; @@ -134,8 +147,8 @@ } else { // notify we're done loading this file evt = new AssetLoaderEvent(AssetLoaderEvent.COMPLETE, fd.name); - evt.loader = loader; - evt.asset = loader.content; + evt.loader = fd.loader; + evt.asset = fd.loader.content; } dispatchEvent(evt); @@ -160,11 +173,10 @@ Log.error("handleLoaderProgressEvent: data for loader not found", toString()); return; } - var loader:Loader = fd.loader; - + // create & dispatch event with relevant data var evt:AssetLoaderEvent = new AssetLoaderEvent(AssetLoaderEvent.PROGRESS, fd.name); - evt.loader = loader; + evt.loader = fd.loader; evt.loadedBytesCount = e.bytesLoaded; evt.totalBytesCount = e.bytesTotal; dispatchEvent(evt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-10 21:01:04
|
Revision: 697 http://svn.sourceforge.net/asapframework/?rev=697&view=rev Author: acidcats Date: 2007-06-10 14:01:04 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Minor refactorings; Moved dispatching of START event to the moment the OPEN event from Loader is received Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-06-10 20:59:41 UTC (rev 696) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-06-10 21:01:04 UTC (rev 697) @@ -92,6 +92,7 @@ // create loader object var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaderEvent); + loader.contentLoaderInfo.addEventListener(Event.OPEN, handleLoadStarted); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleLoaderProgressEvent); //ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleLoaderEvent); @@ -104,12 +105,25 @@ // load object loader.load(new URLRequest(fd.url)); + } + + private function handleLoadStarted (e:Event) { + // get loader + var info:LoaderInfo = e.target as LoaderInfo; + + // get data for loader + var fd:FileData = getDataForLoaderInfo(info); + if (fd == null) { + Log.error("handleLoaderEvent: data for loader not found", toString()); + return; + } + // dispatch event we've started loading - var e:AssetLoaderEvent = new AssetLoaderEvent(AssetLoaderEvent.START, fd.name); - e.loader = loader; - e.loadedBytesCount = 0; - e.totalBytesCount = 0; - dispatchEvent(e); + var evt:AssetLoaderEvent = new AssetLoaderEvent(AssetLoaderEvent.START, fd.name); + evt.loader = fd.loader; + evt.loadedBytesCount = 0; + evt.totalBytesCount = 0; + dispatchEvent(evt); } private function handleLoaderEvent (e:Event) : void { @@ -122,7 +136,6 @@ Log.error("handleLoaderEvent: data for loader not found", toString()); return; } - var loader:Loader = fd.loader; // check if an IOError occurred var evt:AssetLoaderEvent; @@ -134,8 +147,8 @@ } else { // notify we're done loading this file evt = new AssetLoaderEvent(AssetLoaderEvent.COMPLETE, fd.name); - evt.loader = loader; - evt.asset = loader.content; + evt.loader = fd.loader; + evt.asset = fd.loader.content; } dispatchEvent(evt); @@ -160,11 +173,10 @@ Log.error("handleLoaderProgressEvent: data for loader not found", toString()); return; } - var loader:Loader = fd.loader; - + // create & dispatch event with relevant data var evt:AssetLoaderEvent = new AssetLoaderEvent(AssetLoaderEvent.PROGRESS, fd.name); - evt.loader = loader; + evt.loader = fd.loader; evt.loadedBytesCount = e.bytesLoaded; evt.totalBytesCount = e.bytesTotal; dispatchEvent(evt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |