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-06-10 20:59:45
|
Revision: 696 http://svn.sourceforge.net/asapframework/?rev=696&view=rev Author: acidcats Date: 2007-06-10 13:59:41 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Changes to comply with new MovieManager 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 20:59:05 UTC (rev 695) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-10 20:59:41 UTC (rev 696) @@ -1,6 +1,23 @@ +/* +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. +*/ + package org.asapframework.management.movie { import flash.display.MovieClip; + import org.asapframework.management.movie.MovieManager; public class LocalController extends MovieClip implements ILocalController { @@ -8,6 +25,9 @@ public function LocalController () { + if (isStandalone()) { + MovieManager.getInstance().addLocalController(this); + } } public function startMovie () : void { @@ -30,7 +50,7 @@ } public function isStandalone () : Boolean { - return (parent == stage); + return ((stage != null) && (parent == stage)); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-10 20:59:40
|
Revision: 696 http://asapframework.svn.sourceforge.net/asapframework/?rev=696&view=rev Author: acidcats Date: 2007-06-10 13:59:41 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Changes to comply with new MovieManager 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 20:59:05 UTC (rev 695) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-10 20:59:41 UTC (rev 696) @@ -1,6 +1,23 @@ +/* +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. +*/ + package org.asapframework.management.movie { import flash.display.MovieClip; + import org.asapframework.management.movie.MovieManager; public class LocalController extends MovieClip implements ILocalController { @@ -8,6 +25,9 @@ public function LocalController () { + if (isStandalone()) { + MovieManager.getInstance().addLocalController(this); + } } public function startMovie () : void { @@ -30,7 +50,7 @@ } public function isStandalone () : Boolean { - return (parent == stage); + return ((stage != null) && (parent == stage)); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-10 20:59:06
|
Revision: 695 http://asapframework.svn.sourceforge.net/asapframework/?rev=695&view=rev Author: acidcats Date: 2007-06-10 13:59:05 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Added first version of MovieManager & -Event Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.as Added: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as 2007-06-10 20:59:05 UTC (rev 695) @@ -0,0 +1,317 @@ +/* +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. +*/ + +package org.asapframework.management.movie { + import flash.display.DisplayObject; + import flash.events.EventDispatcher; + import org.asapframework.util.loader.AssetLoader; + import org.asapframework.util.loader.AssetLoaderEvent; + import org.asapframework.management.movie.LocalController; + import org.asapframework.util.debug.Log; + + + public class MovieManager extends EventDispatcher { + /** MovieData */ + private var mMovies:Array = new Array(); + private var mLoader:AssetLoader; + + private static var mInstance:MovieManager = null; + + + /** + Access point for the one instance of the MovieManager + */ + public static function getInstance () : MovieManager { + if (mInstance == null) { + mInstance = new MovieManager(); + } + + return mInstance; + } + + /** + The {@link org.asapframework.util.loader.AssetLoader} loader class used by MovieManager. + */ + public function getLoader () : AssetLoader { + return mLoader; + } + + /** + Start loading the movie with path inSource.url, and adds it to the list of movies under the name inSource.name + @param inName: unique identifying name for the movie to be loaded + @param inURL: url where the swf can be found + @param inIsVisible: visibility of movie when loaded, default = true + @return: false if the loader cannot load the movie, or the movie could not be added to the list (usually because another or the same movie with the same name exists already), otherwise true + */ + public function loadMovie (inURL:String, inName:String, inIsVisible:Boolean = true) : Boolean { + // try adding + if (!addMovie(inURL, inName)) { + return false; + } + + // start loading + mLoader.loadAsset(inURL, inName, inIsVisible); + + return true; + } + + /** + 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 + @return : false if the movie wasn't found, true otherwise + */ + public function removeMovie (inMovie:*) : Boolean { + // retrieve data block depending on type of inMovie + var md:MovieData; + + if (inMovie is LocalController) { + md = getMovieDataByController(inMovie as LocalController); + if (md == null) { + Log.error("removeMovie; data for controller '" + inMovie + "' not found", toString()); + return false; + } + } else if (inMovie is String) { + md = getMovieDataByName(inMovie as String); + if (md == null) { + Log.error("removeMovie; data for movie with name '" + inMovie + "' not found", toString()); + return false; + } + } else if (inMovie is DisplayObject) { + md = getMovieDataByContainer(inMovie as DisplayObject); + if (md == null) { + Log.error("removeMovie; data for movie for container '" + inMovie + "' not found", toString()); + return false; + } + } else { + Log.error("removeMovie; no string or movieclip passed to function", toString()); + return false; + } + + // remove from list of data objects + mMovies.splice(mMovies.indexOf(md), 1); + + return true; + } + + /** + Finds a local controller by name + @param inName: unique identifier for the loaded movie + @returns The controller for that movie, or null if none was found + */ + public function getLocalControllerByName (inName:String) : LocalController { + var md:MovieData = getMovieDataByName(inName); + if (md == null) { + Log.warn("getLocalControllerByName; controller with name '" + inName + "' not found.", toString()); + return null; + } + + return md.controller; + } + + /** + * Add a specific controller; used by standalone LocalController to notify its existence to the MovieManager + * @param inController + */ + public function addLocalController (inController:LocalController) : void { + // check if movie has been added previously via loadMovie() + var md:MovieData = getMovieDataByContainer(inController as DisplayObject); + if (md == null) { + // create new data for movie + md = new MovieData(""); + mMovies.push(md); + } + + // store controller only if not stored during handleMovieLoaded + if (md.controller == null) { + storeLocalController(inController, md); + } + } + + /** + Adds a movie with specified properties to the list, after checking if a movie with the same name exists already + @param inName: unique identifying name for the movie to be loaded + @param inURL: url where the swf can be found + @return : false if another movie with the same name exists in the list, otherwise true + */ + private function addMovie (inURL:String, inName:String) : Boolean { + var md:MovieData = getMovieDataByName(inName); + if (md != null) { + Log.error("addMovie; movie with name '" + inName + "' is already added to MovieManager", toString()); + return false; + } + + // create & store data + md = new MovieData(inName); + mMovies.push(md); + + return true; + } + + /** + * Find MovieData object for specified name + * @param inName + * @return data object, or null if none was found + */ + private function getMovieDataByName (inName:String) : MovieData { + var len:int = mMovies.length; + for (var i:int = 0; i < len; i++) { + var md:MovieData = mMovies[i] as MovieData; + if (md.name == inName) return md; + } + return null; + } + + /** + * Find MovieData object for specified controller + * @param inName + * @return data object, or null if none was found + */ + private function getMovieDataByController (inController:LocalController) : MovieData { + var len:int = mMovies.length; + for (var i:int = 0; i < len; i++) { + var md:MovieData = mMovies[i] as MovieData; + if (md.controller == inController) return md; + } + return null; + } + + /** + * Find MovieData object for specified container + * @param inName + * @return data object, or null if none was found + */ + private function getMovieDataByContainer (inObject:DisplayObject) : MovieData { + var len:int = mMovies.length; + for (var i:int = 0; i < len; i++) { + var md:MovieData = mMovies[i] as MovieData; + if (md.container == inObject) return md; + } + return null; + } + + /** + * Handle AssetLoaderEvent from AssetLoader + * @param e + */ + private function handleLoaderEvent (e:AssetLoaderEvent) : void { + switch (e.subtype) { + case AssetLoaderEvent.ERROR: handleLoaderError(e); break; + case AssetLoaderEvent.COMPLETE: handleMovieLoaded(e); break; + } + } + + /** + * Handle error during loading + * @param e + * @return + */ + private function handleLoaderError (e:AssetLoaderEvent) : void { + var evt:MovieManagerEvent = new MovieManagerEvent(MovieManagerEvent.ERROR, e.name); + evt.error = e.error; + dispatchEvent(evt); + } + + private function handleMovieLoadingStarted (e:AssetLoaderEvent) : void { + } + + /** + * Handle event that movie has been loaded + * @param e + * @return + */ + private function handleMovieLoaded (e:AssetLoaderEvent) : void { + var md:MovieData = getMovieDataByName(e.name); + if (md == null) { + Log.error("handleMovieLoaded: MovieData for name = '" + e.name + "' not found", toString()); + return; + } + + // store asset + md.container = e.asset; + + // store controller if container is controller and controller hasn't been set by addLocalController + if ((md.container is LocalController) && (md.controller == null)) { + storeLocalController(md.container as LocalController, md); + } + + // dispatch event + var evt:MovieManagerEvent = new MovieManagerEvent(MovieManagerEvent.MOVIE_LOADED, e.name); + evt.container = e.asset; + dispatchEvent(e); + + // check if all done + checkLoadProgress(md); + } + + /** + * Set local controller for specified data object + * @param inController + * @param inData + */ + private function storeLocalController (inController:LocalController, inData:MovieData) : void { + // set name of local controller + inController.setName(inData.name); + + // store local controller in data + inData.controller = inController; + + // dispatch event + var e:MovieManagerEvent = new MovieManagerEvent(MovieManagerEvent.CONTROLLER_INITIALIZED, inData.name); + e.controller = inController; + dispatchEvent(e); + } + + private function checkLoadProgress (inData:MovieData) : void { + if ((inData.controller != null) && (inData.container != null)) { + var e:MovieManagerEvent = new MovieManagerEvent(MovieManagerEvent.MOVIE_READY, inData.name); + e.controller = inData.controller; + e.container = inData.container; + dispatchEvent(e); + } + } + + /** + Supposedly private constructor + */ + function MovieManager () { + super(); + + // create loader & listen to events + mLoader = new AssetLoader(); + mLoader.addEventListener(AssetLoaderEvent._EVENT, handleLoaderEvent); + } + + override public function toString () : String { + return ";org.asapframework.management.movie.MovieManager"; + } + } + +} + +import org.asapframework.management.movie.LocalController; +import flash.display.DisplayObject; + +class MovieData { + public var name : String; + public var controller : LocalController; + public var container : DisplayObject; + + public function MovieData (inName:String) { + name = inName; + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.as 2007-06-10 20:59:05 UTC (rev 695) @@ -0,0 +1,43 @@ +/* +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. +*/ + +package org.asapframework.management.movie { + import flash.display.DisplayObject; + import flash.events.Event; + + public class MovieManagerEvent extends Event { + public static var _EVENT:String = "onMovieManagerEvent"; + + public static var MOVIE_LOADED:String = "movieLoaded"; + public static var CONTROLLER_INITIALIZED:String = "controllerInitialized"; + public static var MOVIE_READY:String = "movieReady"; + public static var ERROR:String = "error"; + + public var subtype:String; + public var name:String; + public var container:DisplayObject; + public var controller:LocalController; + public var error:String; + + public function MovieManagerEvent (inSubtype:String, inName:String) { + super(_EVENT); + + subtype = inSubtype; + name = inName; + } + } + +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.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-06-10 20:59:06
|
Revision: 695 http://svn.sourceforge.net/asapframework/?rev=695&view=rev Author: acidcats Date: 2007-06-10 13:59:05 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Added first version of MovieManager & -Event Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.as Added: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as 2007-06-10 20:59:05 UTC (rev 695) @@ -0,0 +1,317 @@ +/* +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. +*/ + +package org.asapframework.management.movie { + import flash.display.DisplayObject; + import flash.events.EventDispatcher; + import org.asapframework.util.loader.AssetLoader; + import org.asapframework.util.loader.AssetLoaderEvent; + import org.asapframework.management.movie.LocalController; + import org.asapframework.util.debug.Log; + + + public class MovieManager extends EventDispatcher { + /** MovieData */ + private var mMovies:Array = new Array(); + private var mLoader:AssetLoader; + + private static var mInstance:MovieManager = null; + + + /** + Access point for the one instance of the MovieManager + */ + public static function getInstance () : MovieManager { + if (mInstance == null) { + mInstance = new MovieManager(); + } + + return mInstance; + } + + /** + The {@link org.asapframework.util.loader.AssetLoader} loader class used by MovieManager. + */ + public function getLoader () : AssetLoader { + return mLoader; + } + + /** + Start loading the movie with path inSource.url, and adds it to the list of movies under the name inSource.name + @param inName: unique identifying name for the movie to be loaded + @param inURL: url where the swf can be found + @param inIsVisible: visibility of movie when loaded, default = true + @return: false if the loader cannot load the movie, or the movie could not be added to the list (usually because another or the same movie with the same name exists already), otherwise true + */ + public function loadMovie (inURL:String, inName:String, inIsVisible:Boolean = true) : Boolean { + // try adding + if (!addMovie(inURL, inName)) { + return false; + } + + // start loading + mLoader.loadAsset(inURL, inName, inIsVisible); + + return true; + } + + /** + 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 + @return : false if the movie wasn't found, true otherwise + */ + public function removeMovie (inMovie:*) : Boolean { + // retrieve data block depending on type of inMovie + var md:MovieData; + + if (inMovie is LocalController) { + md = getMovieDataByController(inMovie as LocalController); + if (md == null) { + Log.error("removeMovie; data for controller '" + inMovie + "' not found", toString()); + return false; + } + } else if (inMovie is String) { + md = getMovieDataByName(inMovie as String); + if (md == null) { + Log.error("removeMovie; data for movie with name '" + inMovie + "' not found", toString()); + return false; + } + } else if (inMovie is DisplayObject) { + md = getMovieDataByContainer(inMovie as DisplayObject); + if (md == null) { + Log.error("removeMovie; data for movie for container '" + inMovie + "' not found", toString()); + return false; + } + } else { + Log.error("removeMovie; no string or movieclip passed to function", toString()); + return false; + } + + // remove from list of data objects + mMovies.splice(mMovies.indexOf(md), 1); + + return true; + } + + /** + Finds a local controller by name + @param inName: unique identifier for the loaded movie + @returns The controller for that movie, or null if none was found + */ + public function getLocalControllerByName (inName:String) : LocalController { + var md:MovieData = getMovieDataByName(inName); + if (md == null) { + Log.warn("getLocalControllerByName; controller with name '" + inName + "' not found.", toString()); + return null; + } + + return md.controller; + } + + /** + * Add a specific controller; used by standalone LocalController to notify its existence to the MovieManager + * @param inController + */ + public function addLocalController (inController:LocalController) : void { + // check if movie has been added previously via loadMovie() + var md:MovieData = getMovieDataByContainer(inController as DisplayObject); + if (md == null) { + // create new data for movie + md = new MovieData(""); + mMovies.push(md); + } + + // store controller only if not stored during handleMovieLoaded + if (md.controller == null) { + storeLocalController(inController, md); + } + } + + /** + Adds a movie with specified properties to the list, after checking if a movie with the same name exists already + @param inName: unique identifying name for the movie to be loaded + @param inURL: url where the swf can be found + @return : false if another movie with the same name exists in the list, otherwise true + */ + private function addMovie (inURL:String, inName:String) : Boolean { + var md:MovieData = getMovieDataByName(inName); + if (md != null) { + Log.error("addMovie; movie with name '" + inName + "' is already added to MovieManager", toString()); + return false; + } + + // create & store data + md = new MovieData(inName); + mMovies.push(md); + + return true; + } + + /** + * Find MovieData object for specified name + * @param inName + * @return data object, or null if none was found + */ + private function getMovieDataByName (inName:String) : MovieData { + var len:int = mMovies.length; + for (var i:int = 0; i < len; i++) { + var md:MovieData = mMovies[i] as MovieData; + if (md.name == inName) return md; + } + return null; + } + + /** + * Find MovieData object for specified controller + * @param inName + * @return data object, or null if none was found + */ + private function getMovieDataByController (inController:LocalController) : MovieData { + var len:int = mMovies.length; + for (var i:int = 0; i < len; i++) { + var md:MovieData = mMovies[i] as MovieData; + if (md.controller == inController) return md; + } + return null; + } + + /** + * Find MovieData object for specified container + * @param inName + * @return data object, or null if none was found + */ + private function getMovieDataByContainer (inObject:DisplayObject) : MovieData { + var len:int = mMovies.length; + for (var i:int = 0; i < len; i++) { + var md:MovieData = mMovies[i] as MovieData; + if (md.container == inObject) return md; + } + return null; + } + + /** + * Handle AssetLoaderEvent from AssetLoader + * @param e + */ + private function handleLoaderEvent (e:AssetLoaderEvent) : void { + switch (e.subtype) { + case AssetLoaderEvent.ERROR: handleLoaderError(e); break; + case AssetLoaderEvent.COMPLETE: handleMovieLoaded(e); break; + } + } + + /** + * Handle error during loading + * @param e + * @return + */ + private function handleLoaderError (e:AssetLoaderEvent) : void { + var evt:MovieManagerEvent = new MovieManagerEvent(MovieManagerEvent.ERROR, e.name); + evt.error = e.error; + dispatchEvent(evt); + } + + private function handleMovieLoadingStarted (e:AssetLoaderEvent) : void { + } + + /** + * Handle event that movie has been loaded + * @param e + * @return + */ + private function handleMovieLoaded (e:AssetLoaderEvent) : void { + var md:MovieData = getMovieDataByName(e.name); + if (md == null) { + Log.error("handleMovieLoaded: MovieData for name = '" + e.name + "' not found", toString()); + return; + } + + // store asset + md.container = e.asset; + + // store controller if container is controller and controller hasn't been set by addLocalController + if ((md.container is LocalController) && (md.controller == null)) { + storeLocalController(md.container as LocalController, md); + } + + // dispatch event + var evt:MovieManagerEvent = new MovieManagerEvent(MovieManagerEvent.MOVIE_LOADED, e.name); + evt.container = e.asset; + dispatchEvent(e); + + // check if all done + checkLoadProgress(md); + } + + /** + * Set local controller for specified data object + * @param inController + * @param inData + */ + private function storeLocalController (inController:LocalController, inData:MovieData) : void { + // set name of local controller + inController.setName(inData.name); + + // store local controller in data + inData.controller = inController; + + // dispatch event + var e:MovieManagerEvent = new MovieManagerEvent(MovieManagerEvent.CONTROLLER_INITIALIZED, inData.name); + e.controller = inController; + dispatchEvent(e); + } + + private function checkLoadProgress (inData:MovieData) : void { + if ((inData.controller != null) && (inData.container != null)) { + var e:MovieManagerEvent = new MovieManagerEvent(MovieManagerEvent.MOVIE_READY, inData.name); + e.controller = inData.controller; + e.container = inData.container; + dispatchEvent(e); + } + } + + /** + Supposedly private constructor + */ + function MovieManager () { + super(); + + // create loader & listen to events + mLoader = new AssetLoader(); + mLoader.addEventListener(AssetLoaderEvent._EVENT, handleLoaderEvent); + } + + override public function toString () : String { + return ";org.asapframework.management.movie.MovieManager"; + } + } + +} + +import org.asapframework.management.movie.LocalController; +import flash.display.DisplayObject; + +class MovieData { + public var name : String; + public var controller : LocalController; + public var container : DisplayObject; + + public function MovieData (inName:String) { + name = inName; + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManager.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.as 2007-06-10 20:59:05 UTC (rev 695) @@ -0,0 +1,43 @@ +/* +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. +*/ + +package org.asapframework.management.movie { + import flash.display.DisplayObject; + import flash.events.Event; + + public class MovieManagerEvent extends Event { + public static var _EVENT:String = "onMovieManagerEvent"; + + public static var MOVIE_LOADED:String = "movieLoaded"; + public static var CONTROLLER_INITIALIZED:String = "controllerInitialized"; + public static var MOVIE_READY:String = "movieReady"; + public static var ERROR:String = "error"; + + public var subtype:String; + public var name:String; + public var container:DisplayObject; + public var controller:LocalController; + public var error:String; + + public function MovieManagerEvent (inSubtype:String, inName:String) { + super(_EVENT); + + subtype = inSubtype; + name = inName; + } + } + +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/MovieManagerEvent.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-06-09 21:09:32
|
Revision: 694 http://asapframework.svn.sourceforge.net/asapframework/?rev=694&view=rev Author: acidcats Date: 2007-06-09 14:09:23 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Added property 'asset' to AssetLoader & -Event Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.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-09 21:06:26 UTC (rev 693) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-06-09 21:09:23 UTC (rev 694) @@ -135,6 +135,7 @@ // notify we're done loading this file evt = new AssetLoaderEvent(AssetLoaderEvent.COMPLETE, fd.name); evt.loader = loader; + evt.asset = loader.content; } dispatchEvent(evt); Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as 2007-06-09 21:06:26 UTC (rev 693) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as 2007-06-09 21:09:23 UTC (rev 694) @@ -15,6 +15,7 @@ */ package org.asapframework.util.loader { + import flash.display.DisplayObject; import flash.display.Loader; import flash.events.Event; @@ -39,6 +40,7 @@ public var loadedBytesCount : uint; public var error:String; public var loader:Loader; + public var asset:DisplayObject; public function AssetLoaderEvent (inSubtype:String, inName:String = "") { super(_EVENT); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-09 21:09:32
|
Revision: 694 http://svn.sourceforge.net/asapframework/?rev=694&view=rev Author: acidcats Date: 2007-06-09 14:09:23 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Added property 'asset' to AssetLoader & -Event Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.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-09 21:06:26 UTC (rev 693) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-06-09 21:09:23 UTC (rev 694) @@ -135,6 +135,7 @@ // notify we're done loading this file evt = new AssetLoaderEvent(AssetLoaderEvent.COMPLETE, fd.name); evt.loader = loader; + evt.asset = loader.content; } dispatchEvent(evt); Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as 2007-06-09 21:06:26 UTC (rev 693) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as 2007-06-09 21:09:23 UTC (rev 694) @@ -15,6 +15,7 @@ */ package org.asapframework.util.loader { + import flash.display.DisplayObject; import flash.display.Loader; import flash.events.Event; @@ -39,6 +40,7 @@ public var loadedBytesCount : uint; public var error:String; public var loader:Loader; + public var asset:DisplayObject; public function AssetLoaderEvent (inSubtype:String, inName:String = "") { super(_EVENT); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-09 21:06:25
|
Revision: 693 http://asapframework.svn.sourceforge.net/asapframework/?rev=693&view=rev Author: acidcats Date: 2007-06-09 14:06:26 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Added AssetLoader & -Event Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as Added: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-06-09 21:06:26 UTC (rev 693) @@ -0,0 +1,208 @@ +/* +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. +*/ + +package org.asapframework.util.loader { + + import flash.events.EventDispatcher; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.net.URLRequest; + import flash.display.Loader; + import flash.display.LoaderInfo; + import flash.events.ProgressEvent; + + import org.asapframework.util.debug.Log; + + + public class AssetLoader extends EventDispatcher { + /** Default number of loaders before queueing */ + private static var DEFAULT_LOADER_COUNT:Number = 1; + + /** FileData */ + private var mWaitingStack : Array = new Array(); + /** FileData */ + private var mLoadingStack : Array = new Array(); + + private var mLoaderCount : int; + + + /** + * Constructor + * @param inLoaderCount: number of parallel loaders + */ + public function AssetLoader (inLoaderCount:Number = 1) { + mLoaderCount = inLoaderCount; + } + + /** + * Load an asset + * @param inURL: source url of the file + * @param inName: (optional) unique identifying name + * @param inIsVisible: (optional) visibility state of loaded item + */ + public function loadAsset (inUrl:String, inName:String = "", inIsVisible:Boolean = true) : void { + // Check if url is valid + if ((inUrl== null) || (inUrl.length == 0)) { + Log.error("loadXML: url is not valid", toString()); + // dispatch error event + var e:AssetLoaderEvent = new AssetLoaderEvent(AssetLoaderEvent.ERROR, inName); + e.error = "invalid url"; + dispatchEvent(e); + + return; + } + + var fd:FileData = new FileData(inUrl, inName, inIsVisible); + mWaitingStack.push(fd); + + loadNext(); + } + + /** + * Load next asset if the waiting stack isn't empty + */ + private function loadNext () : void { + // quit if all loaders taken + if (mLoadingStack.length == mLoaderCount) return; + + // quit if no waiting data + if (mWaitingStack.length == 0) { + if (mLoadingStack.length == 0) { + dispatchEvent(new AssetLoaderEvent(AssetLoaderEvent.ALL_LOADED)); + } + return; + } + + // get next object to load + var fd:FileData = mWaitingStack.shift() as FileData; + + // create loader object + var loader:Loader = new Loader(); + loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaderEvent); + loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleLoaderProgressEvent); + //ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleLoaderEvent); + + // store loader in data + fd.loader = loader; + + // store object in loading list + mLoadingStack.push(fd); + + // load object + loader.load(new URLRequest(fd.url)); + + // 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); + } + + private function handleLoaderEvent (e:Event) : void { + // 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; + } + var loader:Loader = fd.loader; + + // check if an IOError occurred + var evt:AssetLoaderEvent; + if (e is IOErrorEvent) { + // fill error event + var errorEvent:IOErrorEvent = e as IOErrorEvent; + evt = new AssetLoaderEvent(AssetLoaderEvent.ERROR, fd.name); + evt.error = errorEvent.text; + } else { + // notify we're done loading this file + evt = new AssetLoaderEvent(AssetLoaderEvent.COMPLETE, fd.name); + evt.loader = loader; + } + dispatchEvent(evt); + + // remove data from stack + mLoadingStack.splice(mLoadingStack.indexOf(fd), 1); + + // continue loading + loadNext(); + } + + /** + * Handle ProgressEvent from Loader + * @param e: ProgressEvent sent + */ + private function handleLoaderProgressEvent (e:ProgressEvent) : void { + // get loader + var info:LoaderInfo = e.target as LoaderInfo; + + // get data for loader + var fd:FileData = getDataForLoaderInfo(info); + if (fd == null) { + 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.loadedBytesCount = e.bytesLoaded; + evt.totalBytesCount = e.bytesTotal; + dispatchEvent(evt); + } + + /** + * Get the data block in the loading stack for the specified LoaderInfo + * @param inInfo: LoaderInfo + * @return the data, or null if none was found + */ + private function getDataForLoaderInfo (inInfo:LoaderInfo) : FileData { + var len:int = mLoadingStack.length; + for (var i:int = 0; i < len; i++) { + var fd:FileData = mLoadingStack[i] as FileData; + if (fd.loader.contentLoaderInfo == inInfo) return fd; + } + return null; + } + + override public function toString () : String { + return "org.asapframework.util.loader.AssetLoader"; + } + } +} + +import flash.display.Loader; +import flash.display.LoaderInfo; + +class FileData { + public var loader:Loader; + public var url:String; + public var name:String; + public var isVisible:Boolean; + public var bytesTotal:Number; + public var bytesLoaded:Number; + + public function FileData (inURL:String, inName:String, inIsVisible:Boolean) { + url = inURL; + name = inName; + isVisible = inIsVisible; + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as 2007-06-09 21:06:26 UTC (rev 693) @@ -0,0 +1,50 @@ +/* +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. +*/ + +package org.asapframework.util.loader { + import flash.display.Loader; + import flash.events.Event; + + public class AssetLoaderEvent extends Event { + /** Generic event type */ + public static var _EVENT:String = "onLoaderStackEvent"; + + /** event sent when a single object starts being loaded */ + public static var START:String = "loadStart"; + /** event sent during loading */ + public static var PROGRESS:String = "loadProgress"; + /** event sent when loading is done */ + public static var COMPLETE:String = "loadDone"; + /** event sent when all objects have been loaded */ + public static var ALL_LOADED:String = "allLoadFinished"; + /** event sent when there's an error */ + public static var ERROR:String = "loadError"; + + public var subtype : String; + public var name : String; + public var totalBytesCount : uint; + public var loadedBytesCount : uint; + public var error:String; + public var loader:Loader; + + public function AssetLoaderEvent (inSubtype:String, inName:String = "") { + super(_EVENT); + + subtype = inSubtype; + name = inName; + } +} +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.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-06-09 21:06:25
|
Revision: 693 http://svn.sourceforge.net/asapframework/?rev=693&view=rev Author: acidcats Date: 2007-06-09 14:06:26 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Added AssetLoader & -Event Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as Added: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as 2007-06-09 21:06:26 UTC (rev 693) @@ -0,0 +1,208 @@ +/* +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. +*/ + +package org.asapframework.util.loader { + + import flash.events.EventDispatcher; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.net.URLRequest; + import flash.display.Loader; + import flash.display.LoaderInfo; + import flash.events.ProgressEvent; + + import org.asapframework.util.debug.Log; + + + public class AssetLoader extends EventDispatcher { + /** Default number of loaders before queueing */ + private static var DEFAULT_LOADER_COUNT:Number = 1; + + /** FileData */ + private var mWaitingStack : Array = new Array(); + /** FileData */ + private var mLoadingStack : Array = new Array(); + + private var mLoaderCount : int; + + + /** + * Constructor + * @param inLoaderCount: number of parallel loaders + */ + public function AssetLoader (inLoaderCount:Number = 1) { + mLoaderCount = inLoaderCount; + } + + /** + * Load an asset + * @param inURL: source url of the file + * @param inName: (optional) unique identifying name + * @param inIsVisible: (optional) visibility state of loaded item + */ + public function loadAsset (inUrl:String, inName:String = "", inIsVisible:Boolean = true) : void { + // Check if url is valid + if ((inUrl== null) || (inUrl.length == 0)) { + Log.error("loadXML: url is not valid", toString()); + // dispatch error event + var e:AssetLoaderEvent = new AssetLoaderEvent(AssetLoaderEvent.ERROR, inName); + e.error = "invalid url"; + dispatchEvent(e); + + return; + } + + var fd:FileData = new FileData(inUrl, inName, inIsVisible); + mWaitingStack.push(fd); + + loadNext(); + } + + /** + * Load next asset if the waiting stack isn't empty + */ + private function loadNext () : void { + // quit if all loaders taken + if (mLoadingStack.length == mLoaderCount) return; + + // quit if no waiting data + if (mWaitingStack.length == 0) { + if (mLoadingStack.length == 0) { + dispatchEvent(new AssetLoaderEvent(AssetLoaderEvent.ALL_LOADED)); + } + return; + } + + // get next object to load + var fd:FileData = mWaitingStack.shift() as FileData; + + // create loader object + var loader:Loader = new Loader(); + loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaderEvent); + loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleLoaderProgressEvent); + //ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleLoaderEvent); + + // store loader in data + fd.loader = loader; + + // store object in loading list + mLoadingStack.push(fd); + + // load object + loader.load(new URLRequest(fd.url)); + + // 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); + } + + private function handleLoaderEvent (e:Event) : void { + // 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; + } + var loader:Loader = fd.loader; + + // check if an IOError occurred + var evt:AssetLoaderEvent; + if (e is IOErrorEvent) { + // fill error event + var errorEvent:IOErrorEvent = e as IOErrorEvent; + evt = new AssetLoaderEvent(AssetLoaderEvent.ERROR, fd.name); + evt.error = errorEvent.text; + } else { + // notify we're done loading this file + evt = new AssetLoaderEvent(AssetLoaderEvent.COMPLETE, fd.name); + evt.loader = loader; + } + dispatchEvent(evt); + + // remove data from stack + mLoadingStack.splice(mLoadingStack.indexOf(fd), 1); + + // continue loading + loadNext(); + } + + /** + * Handle ProgressEvent from Loader + * @param e: ProgressEvent sent + */ + private function handleLoaderProgressEvent (e:ProgressEvent) : void { + // get loader + var info:LoaderInfo = e.target as LoaderInfo; + + // get data for loader + var fd:FileData = getDataForLoaderInfo(info); + if (fd == null) { + 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.loadedBytesCount = e.bytesLoaded; + evt.totalBytesCount = e.bytesTotal; + dispatchEvent(evt); + } + + /** + * Get the data block in the loading stack for the specified LoaderInfo + * @param inInfo: LoaderInfo + * @return the data, or null if none was found + */ + private function getDataForLoaderInfo (inInfo:LoaderInfo) : FileData { + var len:int = mLoadingStack.length; + for (var i:int = 0; i < len; i++) { + var fd:FileData = mLoadingStack[i] as FileData; + if (fd.loader.contentLoaderInfo == inInfo) return fd; + } + return null; + } + + override public function toString () : String { + return "org.asapframework.util.loader.AssetLoader"; + } + } +} + +import flash.display.Loader; +import flash.display.LoaderInfo; + +class FileData { + public var loader:Loader; + public var url:String; + public var name:String; + public var isVisible:Boolean; + public var bytesTotal:Number; + public var bytesLoaded:Number; + + public function FileData (inURL:String, inName:String, inIsVisible:Boolean) { + url = inURL; + name = inName; + isVisible = inIsVisible; + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoader.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.as 2007-06-09 21:06:26 UTC (rev 693) @@ -0,0 +1,50 @@ +/* +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. +*/ + +package org.asapframework.util.loader { + import flash.display.Loader; + import flash.events.Event; + + public class AssetLoaderEvent extends Event { + /** Generic event type */ + public static var _EVENT:String = "onLoaderStackEvent"; + + /** event sent when a single object starts being loaded */ + public static var START:String = "loadStart"; + /** event sent during loading */ + public static var PROGRESS:String = "loadProgress"; + /** event sent when loading is done */ + public static var COMPLETE:String = "loadDone"; + /** event sent when all objects have been loaded */ + public static var ALL_LOADED:String = "allLoadFinished"; + /** event sent when there's an error */ + public static var ERROR:String = "loadError"; + + public var subtype : String; + public var name : String; + public var totalBytesCount : uint; + public var loadedBytesCount : uint; + public var error:String; + public var loader:Loader; + + public function AssetLoaderEvent (inSubtype:String, inName:String = "") { + super(_EVENT); + + subtype = inSubtype; + name = inName; + } +} +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/util/loader/AssetLoaderEvent.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-06-09 21:05:47
|
Revision: 692 http://asapframework.svn.sourceforge.net/asapframework/?rev=692&view=rev Author: acidcats Date: 2007-06-09 14:05:49 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Slight changes in interface Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as 2007-06-09 21:05:18 UTC (rev 691) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as 2007-06-09 21:05:49 UTC (rev 692) @@ -20,8 +20,8 @@ package org.asapframework.management.movie { public interface ILocalController { - function start () : void; - function stop () : void; + function startMovie () : void; + function stopMovie () : void; function die () : void; function getName () : String; function setName (inName:String) : void; 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-09 21:05:18 UTC (rev 691) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-09 21:05:49 UTC (rev 692) @@ -1,18 +1,21 @@ package org.asapframework.management.movie { - import flash.display.Sprite; + import flash.display.MovieClip; - public class LocalController extends Sprite implements ILocalController { + + public class LocalController extends MovieClip implements ILocalController { private var mName : String; public function LocalController () { } - public function start () : void { + public function startMovie () : void { + play(); } - public function stop () : void { + public function stopMovie () : void { + stop(); } public function die () : void { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-09 21:05:47
|
Revision: 692 http://svn.sourceforge.net/asapframework/?rev=692&view=rev Author: acidcats Date: 2007-06-09 14:05:49 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Slight changes in interface Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as 2007-06-09 21:05:18 UTC (rev 691) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as 2007-06-09 21:05:49 UTC (rev 692) @@ -20,8 +20,8 @@ package org.asapframework.management.movie { public interface ILocalController { - function start () : void; - function stop () : void; + function startMovie () : void; + function stopMovie () : void; function die () : void; function getName () : String; function setName (inName:String) : void; 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-09 21:05:18 UTC (rev 691) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-09 21:05:49 UTC (rev 692) @@ -1,18 +1,21 @@ package org.asapframework.management.movie { - import flash.display.Sprite; + import flash.display.MovieClip; - public class LocalController extends Sprite implements ILocalController { + + public class LocalController extends MovieClip implements ILocalController { private var mName : String; public function LocalController () { } - public function start () : void { + public function startMovie () : void { + play(); } - public function stop () : void { + public function stopMovie () : void { + stop(); } public function die () : void { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-09 21:05:23
|
Revision: 691 http://asapframework.svn.sourceforge.net/asapframework/?rev=691&view=rev Author: acidcats Date: 2007-06-09 14:05:18 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Slight changes in interface Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.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-06-09 16:03:48 UTC (rev 690) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as 2007-06-09 21:05:18 UTC (rev 691) @@ -3,10 +3,10 @@ import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.ProgressEvent; + import flash.events.EventDispatcher; import flash.net.URLRequest; import flash.net.URLVariables; import flash.net.URLLoader; - import flash.events.EventDispatcher; import org.asapframework.util.debug.Log; @@ -16,7 +16,7 @@ private var mWaitingStack : Array = new Array(); private var mLoadingStack : Array = new Array(); - private var mLoaderCount : Number; + private var mLoaderCount : int; /** * Constructor @@ -33,8 +33,18 @@ * @param inVariables: (optional) URLVariables object to be sent to the server */ public function loadXML (inURL:String, inName:String = "", inVariables:URLVariables = null) : void { + // Check if url is valid + if ((inURL== null) || (inURL.length == 0)) { + Log.error("loadXML: url is not valid", toString()); + // dispatch error event + var e:XMLLoaderEvent = new XMLLoaderEvent(XMLLoaderEvent.ERROR, inName, null, this); + e.error = "invalid url"; + dispatchEvent(e); + + return; + } + var xld:XMLLoaderData = new XMLLoaderData(inURL, inName, inVariables); - mWaitingStack.push(xld); loadNext(); @@ -63,18 +73,18 @@ var request:URLRequest = new URLRequest(xld.url); if (xld.variables != null) request.data = xld.variables; - // start loading - loader.load(request); - // store loader in data xld.loader = loader; // store data in loading stack mLoadingStack.push(xld); + + // start loading + loader.load(request); } /** - * Handle COMPLETE event from URLLoader + * Handle events from URLLoader * @param e: Event sent */ private function handleURLLoaderEvent (e:Event) : void { @@ -97,7 +107,7 @@ evt.error = errorEvent.text; } else { // notify we're done loading this xml - evt = new XMLLoaderEvent(XMLLoaderEvent.LOADED, xld.name, new XML(loader.data), this); + evt = new XMLLoaderEvent(XMLLoaderEvent.COMPLETE, xld.name, new XML(loader.data), this); } dispatchEvent(evt); @@ -119,7 +129,7 @@ // get data for loader var xld:XMLLoaderData = getDataForLoader(loader); if (xld == null) { - Log.error("handleURLLoaderEvent: data for loader not found", toString()); + Log.error("handleURLLoaderProgressEvent: data for loader not found", toString()); return; } Modified: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-09 16:03:48 UTC (rev 690) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-09 21:05:18 UTC (rev 691) @@ -5,7 +5,7 @@ public class XMLLoaderEvent extends Event { public static const _EVENT:String = "onXMLLoaderEvent"; - public static const LOADED:String = "loaded"; + public static const COMPLETE:String = "loaded"; public static const ERROR:String = "error"; public static const PROGRESS:String = "progress"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-09 21:05:22
|
Revision: 691 http://svn.sourceforge.net/asapframework/?rev=691&view=rev Author: acidcats Date: 2007-06-09 14:05:18 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Slight changes in interface Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.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-06-09 16:03:48 UTC (rev 690) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as 2007-06-09 21:05:18 UTC (rev 691) @@ -3,10 +3,10 @@ import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.ProgressEvent; + import flash.events.EventDispatcher; import flash.net.URLRequest; import flash.net.URLVariables; import flash.net.URLLoader; - import flash.events.EventDispatcher; import org.asapframework.util.debug.Log; @@ -16,7 +16,7 @@ private var mWaitingStack : Array = new Array(); private var mLoadingStack : Array = new Array(); - private var mLoaderCount : Number; + private var mLoaderCount : int; /** * Constructor @@ -33,8 +33,18 @@ * @param inVariables: (optional) URLVariables object to be sent to the server */ public function loadXML (inURL:String, inName:String = "", inVariables:URLVariables = null) : void { + // Check if url is valid + if ((inURL== null) || (inURL.length == 0)) { + Log.error("loadXML: url is not valid", toString()); + // dispatch error event + var e:XMLLoaderEvent = new XMLLoaderEvent(XMLLoaderEvent.ERROR, inName, null, this); + e.error = "invalid url"; + dispatchEvent(e); + + return; + } + var xld:XMLLoaderData = new XMLLoaderData(inURL, inName, inVariables); - mWaitingStack.push(xld); loadNext(); @@ -63,18 +73,18 @@ var request:URLRequest = new URLRequest(xld.url); if (xld.variables != null) request.data = xld.variables; - // start loading - loader.load(request); - // store loader in data xld.loader = loader; // store data in loading stack mLoadingStack.push(xld); + + // start loading + loader.load(request); } /** - * Handle COMPLETE event from URLLoader + * Handle events from URLLoader * @param e: Event sent */ private function handleURLLoaderEvent (e:Event) : void { @@ -97,7 +107,7 @@ evt.error = errorEvent.text; } else { // notify we're done loading this xml - evt = new XMLLoaderEvent(XMLLoaderEvent.LOADED, xld.name, new XML(loader.data), this); + evt = new XMLLoaderEvent(XMLLoaderEvent.COMPLETE, xld.name, new XML(loader.data), this); } dispatchEvent(evt); @@ -119,7 +129,7 @@ // get data for loader var xld:XMLLoaderData = getDataForLoader(loader); if (xld == null) { - Log.error("handleURLLoaderEvent: data for loader not found", toString()); + Log.error("handleURLLoaderProgressEvent: data for loader not found", toString()); return; } Modified: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-09 16:03:48 UTC (rev 690) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-09 21:05:18 UTC (rev 691) @@ -5,7 +5,7 @@ public class XMLLoaderEvent extends Event { public static const _EVENT:String = "onXMLLoaderEvent"; - public static const LOADED:String = "loaded"; + public static const COMPLETE:String = "loaded"; public static const ERROR:String = "error"; public static const PROGRESS:String = "progress"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-09 16:03:54
|
Revision: 690 http://svn.sourceforge.net/asapframework/?rev=690&view=rev Author: acidcats Date: 2007-06-09 09:03:48 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Initial new version of LocalController added Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/management/ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as Added: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as 2007-06-09 16:03:48 UTC (rev 690) @@ -0,0 +1,30 @@ +/* +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 for the LocalController class. See {@link LocalController} for details. +*/ + +package org.asapframework.management.movie { + public interface ILocalController { + function start () : void; + function stop () : void; + function die () : void; + function getName () : String; + function setName (inName:String) : void; + function isStandalone () : Boolean; + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-09 16:03:48 UTC (rev 690) @@ -0,0 +1,33 @@ +package org.asapframework.management.movie { + + import flash.display.Sprite; + + public class LocalController extends Sprite implements ILocalController { + private var mName : String; + + + public function LocalController () { + } + + public function start () : void { + } + + public function stop () : void { + } + + public function die () : void { + } + + public function getName () : String { + return mName; + } + + public function setName (inName:String) : void { + mName = inName; + } + + public function isStandalone () : Boolean { + return (parent == stage); + } + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.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-06-09 16:03:50
|
Revision: 690 http://asapframework.svn.sourceforge.net/asapframework/?rev=690&view=rev Author: acidcats Date: 2007-06-09 09:03:48 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Initial new version of LocalController added Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/management/ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as Added: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as 2007-06-09 16:03:48 UTC (rev 690) @@ -0,0 +1,30 @@ +/* +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 for the LocalController class. See {@link LocalController} for details. +*/ + +package org.asapframework.management.movie { + public interface ILocalController { + function start () : void; + function stop () : void; + function die () : void; + function getName () : String; + function setName (inName:String) : void; + function isStandalone () : Boolean; + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/ILocalController.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.as 2007-06-09 16:03:48 UTC (rev 690) @@ -0,0 +1,33 @@ +package org.asapframework.management.movie { + + import flash.display.Sprite; + + public class LocalController extends Sprite implements ILocalController { + private var mName : String; + + + public function LocalController () { + } + + public function start () : void { + } + + public function stop () : void { + } + + public function die () : void { + } + + public function getName () : String { + return mName; + } + + public function setName (inName:String) : void { + mName = inName; + } + + public function isStandalone () : Boolean { + return (parent == stage); + } + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/management/movie/LocalController.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-06-02 21:22:41
|
Revision: 689 http://asapframework.svn.sourceforge.net/asapframework/?rev=689&view=rev Author: acidcats Date: 2007-06-02 14:22:43 -0700 (Sat, 02 Jun 2007) Log Message: ----------- Added error handling & progress handling Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.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-06-01 21:28:58 UTC (rev 688) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as 2007-06-02 21:22:43 UTC (rev 689) @@ -1,6 +1,8 @@ package org.asapframework.data.xml { import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.ProgressEvent; import flash.net.URLRequest; import flash.net.URLVariables; import flash.net.URLLoader; @@ -51,13 +53,17 @@ // get the data var xld:XMLLoaderData = mWaitingStack.shift() as XMLLoaderData; - // start loading + // create loader var loader:URLLoader = new URLLoader(); - loader.addEventListener(Event.COMPLETE, handleXMLLoaded); + loader.addEventListener(Event.COMPLETE, handleURLLoaderEvent); + loader.addEventListener(IOErrorEvent.IO_ERROR, handleURLLoaderEvent); + loader.addEventListener(ProgressEvent.PROGRESS, handleURLLoaderProgressEvent); + // create request var request:URLRequest = new URLRequest(xld.url); if (xld.variables != null) request.data = xld.variables; + // start loading loader.load(request); // store loader in data @@ -71,38 +77,71 @@ * Handle COMPLETE event from URLLoader * @param e: Event sent */ - private function handleXMLLoaded (e:Event) : void { + private function handleURLLoaderEvent (e:Event) : void { + // get loader var loader:URLLoader = e.target as URLLoader; - var index:int = getDataIndexForLoader(loader); - if (index == -1) { - Log.error("handleXMLLoaded: data for loader not found", toString()); + // get data for loader + var xld:XMLLoaderData = getDataForLoader(loader); + if (xld == null) { + Log.error("handleURLLoaderEvent: data for loader not found", toString()); return; } - var xld:XMLLoaderData = mLoadingStack[index] as XMLLoaderData; + // check if an IOError occurred + var evt:XMLLoaderEvent; + if (e is IOErrorEvent) { + // fill error event + var errorEvent:IOErrorEvent = e as IOErrorEvent; + evt = new XMLLoaderEvent(XMLLoaderEvent.ERROR, xld.name, null, this); + evt.error = errorEvent.text; + } else { + // notify we're done loading this xml + evt = new XMLLoaderEvent(XMLLoaderEvent.LOADED, xld.name, new XML(loader.data), this); + } + dispatchEvent(evt); - // notify we're done loading this xml - dispatchEvent(new XMLLoaderEvent(XMLLoaderEvent.LOADED, xld.name, new XML(loader.data), this)); - // remove data from stack - mLoadingStack.splice(index, 1); + mLoadingStack.splice(mLoadingStack.indexOf(xld), 1); // continue loading loadNext(); } + + /** + * Handle ProgressEvent from URLLoader + * @param e: ProgressEvent sent + */ + private function handleURLLoaderProgressEvent (e:ProgressEvent) { + // get loader + var loader:URLLoader = e.target as URLLoader; + + // get data for loader + var xld:XMLLoaderData = getDataForLoader(loader); + if (xld == null) { + Log.error("handleURLLoaderEvent: data for loader not found", toString()); + return; + } + // create & dispatch event with relevant data + var evt:XMLLoaderEvent = new XMLLoaderEvent(XMLLoaderEvent.PROGRESS, xld.name, null, this); + evt.bytesLoaded = e.bytesLoaded; + evt.bytesTotal = e.bytesTotal; + dispatchEvent(evt); + } + /** - * Get the index for the data block in the loading stack for the specified URLLoader + * Get the data block in the loading stack for the specified URLLoader * @param inLoader: URLLoader - * @return the index, or -1 if none was found + * @return the data, or null if none was found */ - private function getDataIndexForLoader (inLoader:URLLoader) : int { + private function getDataForLoader (inLoader:URLLoader) : XMLLoaderData { var len:int = mLoadingStack.length; for (var i:int = 0; i < len; i++) { - if ((mLoadingStack[i] as XMLLoaderData).loader == inLoader) return i; + var xld:XMLLoaderData = mLoadingStack[i] as XMLLoaderData; + if (xld.loader == inLoader) return xld; } - return -1; + return null; } public override function toString () : String { Modified: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-01 21:28:58 UTC (rev 688) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-02 21:22:43 UTC (rev 689) @@ -7,11 +7,15 @@ public static const LOADED:String = "loaded"; public static const ERROR:String = "error"; + public static const PROGRESS:String = "progress"; public var source : XMLLoader; public var name : String; public var subtype : String; public var data : XML; + public var error : String; + public var bytesLoaded : uint; + public var bytesTotal : uint; public function XMLLoaderEvent (inSubtype:String, inName:String, inData:XML, inSource:XMLLoader) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-02 21:22:41
|
Revision: 689 http://svn.sourceforge.net/asapframework/?rev=689&view=rev Author: acidcats Date: 2007-06-02 14:22:43 -0700 (Sat, 02 Jun 2007) Log Message: ----------- Added error handling & progress handling Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.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-06-01 21:28:58 UTC (rev 688) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as 2007-06-02 21:22:43 UTC (rev 689) @@ -1,6 +1,8 @@ package org.asapframework.data.xml { import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.ProgressEvent; import flash.net.URLRequest; import flash.net.URLVariables; import flash.net.URLLoader; @@ -51,13 +53,17 @@ // get the data var xld:XMLLoaderData = mWaitingStack.shift() as XMLLoaderData; - // start loading + // create loader var loader:URLLoader = new URLLoader(); - loader.addEventListener(Event.COMPLETE, handleXMLLoaded); + loader.addEventListener(Event.COMPLETE, handleURLLoaderEvent); + loader.addEventListener(IOErrorEvent.IO_ERROR, handleURLLoaderEvent); + loader.addEventListener(ProgressEvent.PROGRESS, handleURLLoaderProgressEvent); + // create request var request:URLRequest = new URLRequest(xld.url); if (xld.variables != null) request.data = xld.variables; + // start loading loader.load(request); // store loader in data @@ -71,38 +77,71 @@ * Handle COMPLETE event from URLLoader * @param e: Event sent */ - private function handleXMLLoaded (e:Event) : void { + private function handleURLLoaderEvent (e:Event) : void { + // get loader var loader:URLLoader = e.target as URLLoader; - var index:int = getDataIndexForLoader(loader); - if (index == -1) { - Log.error("handleXMLLoaded: data for loader not found", toString()); + // get data for loader + var xld:XMLLoaderData = getDataForLoader(loader); + if (xld == null) { + Log.error("handleURLLoaderEvent: data for loader not found", toString()); return; } - var xld:XMLLoaderData = mLoadingStack[index] as XMLLoaderData; + // check if an IOError occurred + var evt:XMLLoaderEvent; + if (e is IOErrorEvent) { + // fill error event + var errorEvent:IOErrorEvent = e as IOErrorEvent; + evt = new XMLLoaderEvent(XMLLoaderEvent.ERROR, xld.name, null, this); + evt.error = errorEvent.text; + } else { + // notify we're done loading this xml + evt = new XMLLoaderEvent(XMLLoaderEvent.LOADED, xld.name, new XML(loader.data), this); + } + dispatchEvent(evt); - // notify we're done loading this xml - dispatchEvent(new XMLLoaderEvent(XMLLoaderEvent.LOADED, xld.name, new XML(loader.data), this)); - // remove data from stack - mLoadingStack.splice(index, 1); + mLoadingStack.splice(mLoadingStack.indexOf(xld), 1); // continue loading loadNext(); } + + /** + * Handle ProgressEvent from URLLoader + * @param e: ProgressEvent sent + */ + private function handleURLLoaderProgressEvent (e:ProgressEvent) { + // get loader + var loader:URLLoader = e.target as URLLoader; + + // get data for loader + var xld:XMLLoaderData = getDataForLoader(loader); + if (xld == null) { + Log.error("handleURLLoaderEvent: data for loader not found", toString()); + return; + } + // create & dispatch event with relevant data + var evt:XMLLoaderEvent = new XMLLoaderEvent(XMLLoaderEvent.PROGRESS, xld.name, null, this); + evt.bytesLoaded = e.bytesLoaded; + evt.bytesTotal = e.bytesTotal; + dispatchEvent(evt); + } + /** - * Get the index for the data block in the loading stack for the specified URLLoader + * Get the data block in the loading stack for the specified URLLoader * @param inLoader: URLLoader - * @return the index, or -1 if none was found + * @return the data, or null if none was found */ - private function getDataIndexForLoader (inLoader:URLLoader) : int { + private function getDataForLoader (inLoader:URLLoader) : XMLLoaderData { var len:int = mLoadingStack.length; for (var i:int = 0; i < len; i++) { - if ((mLoadingStack[i] as XMLLoaderData).loader == inLoader) return i; + var xld:XMLLoaderData = mLoadingStack[i] as XMLLoaderData; + if (xld.loader == inLoader) return xld; } - return -1; + return null; } public override function toString () : String { Modified: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-01 21:28:58 UTC (rev 688) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-02 21:22:43 UTC (rev 689) @@ -7,11 +7,15 @@ public static const LOADED:String = "loaded"; public static const ERROR:String = "error"; + public static const PROGRESS:String = "progress"; public var source : XMLLoader; public var name : String; public var subtype : String; public var data : XML; + public var error : String; + public var bytesLoaded : uint; + public var bytesTotal : uint; public function XMLLoaderEvent (inSubtype:String, inName:String, inData:XML, inSource:XMLLoader) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-06-01 21:28:58
|
Revision: 688 http://asapframework.svn.sourceforge.net/asapframework/?rev=688&view=rev Author: acidcats Date: 2007-06-01 14:28:58 -0700 (Fri, 01 Jun 2007) Log Message: ----------- Added XMLLoader & XMLLoaderEvent Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as Added: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as 2007-06-01 21:28:58 UTC (rev 688) @@ -0,0 +1,129 @@ + +package org.asapframework.data.xml { + import flash.events.Event; + import flash.net.URLRequest; + import flash.net.URLVariables; + import flash.net.URLLoader; + import flash.events.EventDispatcher; + + import org.asapframework.util.debug.Log; + + + public class XMLLoader extends EventDispatcher { + + private var mWaitingStack : Array = new Array(); + private var mLoadingStack : Array = new Array(); + + private var mLoaderCount : Number; + + /** + * Constructor + * @param inLoaderCount: number of parallel loaders + */ + public function XMLLoader (inLoaderCount:int = 1) { + mLoaderCount = inLoaderCount; + } + + /** + * Load XML + * @param inURL: source url of the xml + * @param inName: unique identifying name + * @param inVariables: (optional) URLVariables object to be sent to the server + */ + public function loadXML (inURL:String, inName:String = "", inVariables:URLVariables = null) : void { + var xld:XMLLoaderData = new XMLLoaderData(inURL, inName, inVariables); + + mWaitingStack.push(xld); + + loadNext(); + } + + /** + * Load next xml if the waiting stack isn't empty + */ + private function loadNext () : void { + // quit if all loaders taken + if (mLoadingStack.length == mLoaderCount) return; + + // quit if no waiting data + if (mWaitingStack.length == 0) return; + + // get the data + var xld:XMLLoaderData = mWaitingStack.shift() as XMLLoaderData; + + // start loading + var loader:URLLoader = new URLLoader(); + loader.addEventListener(Event.COMPLETE, handleXMLLoaded); + + var request:URLRequest = new URLRequest(xld.url); + if (xld.variables != null) request.data = xld.variables; + + loader.load(request); + + // store loader in data + xld.loader = loader; + + // store data in loading stack + mLoadingStack.push(xld); + } + + /** + * Handle COMPLETE event from URLLoader + * @param e: Event sent + */ + private function handleXMLLoaded (e:Event) : void { + var loader:URLLoader = e.target as URLLoader; + + var index:int = getDataIndexForLoader(loader); + if (index == -1) { + Log.error("handleXMLLoaded: data for loader not found", toString()); + return; + } + + var xld:XMLLoaderData = mLoadingStack[index] as XMLLoaderData; + + // notify we're done loading this xml + dispatchEvent(new XMLLoaderEvent(XMLLoaderEvent.LOADED, xld.name, new XML(loader.data), this)); + + // remove data from stack + mLoadingStack.splice(index, 1); + + // continue loading + loadNext(); + } + + /** + * Get the index for the data block in the loading stack for the specified URLLoader + * @param inLoader: URLLoader + * @return the index, or -1 if none was found + */ + private function getDataIndexForLoader (inLoader:URLLoader) : int { + var len:int = mLoadingStack.length; + for (var i:int = 0; i < len; i++) { + if ((mLoadingStack[i] as XMLLoaderData).loader == inLoader) return i; + } + return -1; + } + + public override function toString () : String { + return ";org.asapframework.data.xml.XMLLoader"; + } + } +} + + +import flash.net.URLVariables; +import flash.net.URLLoader; + +class XMLLoaderData { + public var url:String; + public var name:String; + public var variables:URLVariables; + public var loader:URLLoader; + + public function XMLLoaderData (inURL:String, inName:String, inVariables:URLVariables = null) { + url = inURL; + name = inName; + variables = inVariables; + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-01 21:28:58 UTC (rev 688) @@ -0,0 +1,26 @@ + +package org.asapframework.data.xml { + import flash.events.Event; + + public class XMLLoaderEvent extends Event { + public static const _EVENT:String = "onXMLLoaderEvent"; + + public static const LOADED:String = "loaded"; + public static const ERROR:String = "error"; + + public var source : XMLLoader; + public var name : String; + public var subtype : String; + public var data : XML; + + + public function XMLLoaderEvent (inSubtype:String, inName:String, inData:XML, inSource:XMLLoader) { + super(_EVENT); + + subtype = inSubtype; + name = inName; + data = inData; + source = inSource; + } + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.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-06-01 21:28:57
|
Revision: 688 http://svn.sourceforge.net/asapframework/?rev=688&view=rev Author: acidcats Date: 2007-06-01 14:28:58 -0700 (Fri, 01 Jun 2007) Log Message: ----------- Added XMLLoader & XMLLoaderEvent Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as Added: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as 2007-06-01 21:28:58 UTC (rev 688) @@ -0,0 +1,129 @@ + +package org.asapframework.data.xml { + import flash.events.Event; + import flash.net.URLRequest; + import flash.net.URLVariables; + import flash.net.URLLoader; + import flash.events.EventDispatcher; + + import org.asapframework.util.debug.Log; + + + public class XMLLoader extends EventDispatcher { + + private var mWaitingStack : Array = new Array(); + private var mLoadingStack : Array = new Array(); + + private var mLoaderCount : Number; + + /** + * Constructor + * @param inLoaderCount: number of parallel loaders + */ + public function XMLLoader (inLoaderCount:int = 1) { + mLoaderCount = inLoaderCount; + } + + /** + * Load XML + * @param inURL: source url of the xml + * @param inName: unique identifying name + * @param inVariables: (optional) URLVariables object to be sent to the server + */ + public function loadXML (inURL:String, inName:String = "", inVariables:URLVariables = null) : void { + var xld:XMLLoaderData = new XMLLoaderData(inURL, inName, inVariables); + + mWaitingStack.push(xld); + + loadNext(); + } + + /** + * Load next xml if the waiting stack isn't empty + */ + private function loadNext () : void { + // quit if all loaders taken + if (mLoadingStack.length == mLoaderCount) return; + + // quit if no waiting data + if (mWaitingStack.length == 0) return; + + // get the data + var xld:XMLLoaderData = mWaitingStack.shift() as XMLLoaderData; + + // start loading + var loader:URLLoader = new URLLoader(); + loader.addEventListener(Event.COMPLETE, handleXMLLoaded); + + var request:URLRequest = new URLRequest(xld.url); + if (xld.variables != null) request.data = xld.variables; + + loader.load(request); + + // store loader in data + xld.loader = loader; + + // store data in loading stack + mLoadingStack.push(xld); + } + + /** + * Handle COMPLETE event from URLLoader + * @param e: Event sent + */ + private function handleXMLLoaded (e:Event) : void { + var loader:URLLoader = e.target as URLLoader; + + var index:int = getDataIndexForLoader(loader); + if (index == -1) { + Log.error("handleXMLLoaded: data for loader not found", toString()); + return; + } + + var xld:XMLLoaderData = mLoadingStack[index] as XMLLoaderData; + + // notify we're done loading this xml + dispatchEvent(new XMLLoaderEvent(XMLLoaderEvent.LOADED, xld.name, new XML(loader.data), this)); + + // remove data from stack + mLoadingStack.splice(index, 1); + + // continue loading + loadNext(); + } + + /** + * Get the index for the data block in the loading stack for the specified URLLoader + * @param inLoader: URLLoader + * @return the index, or -1 if none was found + */ + private function getDataIndexForLoader (inLoader:URLLoader) : int { + var len:int = mLoadingStack.length; + for (var i:int = 0; i < len; i++) { + if ((mLoadingStack[i] as XMLLoaderData).loader == inLoader) return i; + } + return -1; + } + + public override function toString () : String { + return ";org.asapframework.data.xml.XMLLoader"; + } + } +} + + +import flash.net.URLVariables; +import flash.net.URLLoader; + +class XMLLoaderData { + public var url:String; + public var name:String; + public var variables:URLVariables; + public var loader:URLLoader; + + public function XMLLoaderData (inURL:String, inName:String, inVariables:URLVariables = null) { + url = inURL; + name = inName; + variables = inVariables; + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoader.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.as 2007-06-01 21:28:58 UTC (rev 688) @@ -0,0 +1,26 @@ + +package org.asapframework.data.xml { + import flash.events.Event; + + public class XMLLoaderEvent extends Event { + public static const _EVENT:String = "onXMLLoaderEvent"; + + public static const LOADED:String = "loaded"; + public static const ERROR:String = "error"; + + public var source : XMLLoader; + public var name : String; + public var subtype : String; + public var data : XML; + + + public function XMLLoaderEvent (inSubtype:String, inName:String, inData:XML, inSource:XMLLoader) { + super(_EVENT); + + subtype = inSubtype; + name = inName; + data = inData; + source = inSource; + } + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/XMLLoaderEvent.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-05-23 20:03:56
|
Revision: 687 http://asapframework.svn.sourceforge.net/asapframework/?rev=687&view=rev Author: acidcats Date: 2007-05-23 13:03:16 -0700 (Wed, 23 May 2007) Log Message: ----------- Added classes for XML parsing Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.as Added: branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as 2007-05-23 20:03:16 UTC (rev 687) @@ -0,0 +1,58 @@ +/* +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.data { + + import org.asapframework.data.xml.IParsable; + + /** + DataValueObject class to hold information about urls. + Can get its information through the {@link Parser} since it implements {@link IParsable}. + */ + + public class URLData implements IParsable { + // the names of the urls in the file settings.xml + + /** unique identifying name of url */ + public var name:String; + /** actual url to be opened */ + public var url:String; + /** target of getURL function */ + public var target:String; + + /** + * Constructor + * NB: This will be called without parameters by the Parser + */ + public function URLData (inName:String = null, inURL:String = null, inTarget:String = null) { + if (inName) name = inName; + if (inURL) url = inURL; + if (inTarget) target = inTarget; + } + + /** + * Parse XML + * @return true if parsing went ok, otherwise false: name & url are mandatory for this type of node + */ + public function parseXML (inXML:XML) : Boolean { + name = inXML.@name; + url = inXML.@url; + target = inXML.@target; + + return ((name != null) && (url != null)); + } + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as 2007-05-23 20:03:16 UTC (rev 687) @@ -0,0 +1,32 @@ +/* +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. +*/ + + +/** +Interface to implement in DataValueObject classes that get their data through the {@link Parser} class. +The {@link Parser} class calls the {@link #parseObject} function with data from {@link XML2Object#parseXML}. The implementing class is expected to use this Object to retrieve data from. +*/ + +package org.asapframework.data.xml { + public interface IParsable { + /** + * Parse an object from XML into typed variables. + * @param o: XML containing data + * @return true if parsing went ok, otherwise false + */ + function parseXML(o:XML) : Boolean; + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.as 2007-05-23 20:03:16 UTC (rev 687) @@ -0,0 +1,97 @@ +/* +Copyright 2005-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. +*/ + +package org.asapframework.data.xml { + + /** + Class for parsing XML data into DataValueObject classes. + The class provides static functions for calling {@link IParsable#parseObject} on newly created objects of a specified type, either for single data blocks or for an array of similar data. + The Parser removes the tedious for-loop from the location where the XML data is loaded, and moves the parsing of the XML data to the location where it's used for the first time: the DataValueObject class. Your application can use this data, that contains typed variables, without ever caring about the original source of the data. + When the XML structure is changed, only the parsing function in the DataValueObject class has to be changed, thereby facilitating maintenance and development. + + @use + Consider an XML file with the following content: + <code> + <?xml version="1.0" encoding="UTF-8"?> + <settings> + <urls> + <url name="addressform" url="../xml/address.xml" /> + <url name="entries" url="../xml/entries.xml" /> + </urls> + </settings> + </code> + Once the XML has been loaded, it can be converted into an Array of URLData objects with the following code: + <code> + // objects of type URLData + private var mURLs:Array; + + // parse XML + // @param o: XML + // @return true if parsing went ok, otherwise false + private function handleSettingsLoaded (o:XML) : Boolean { + mURLs = Parser.parseList(o.settings.urls.url, org.asapframework.data.loader.URLData, false); + + return (mURLs != null); + } + </code> + After calling this function, the member variable <code>mURLs</code> contains a list of objects of type URLData, filled with the content of the XML file. + + Notes to this code: + <ul> + <li>The first parameter to {@link #parseList} is a (can be a) repeating node where each node contains similar data to be parsed into </li> + <li>Conversion of nodes to an Array is not necessary. If the {@code <urls>}-node in the aforementioned XML file would contain only one {@code <url>}-node, the parser still returns an Array, with one object of type URLData.</li> + <li>Since the last parameter to the call to {@link #parseList} is false, an error in the xml data will result in mURLs being null. The parsing class determines if the data is valid or not, by returning true or false from parseObject().</li> + </ul> + */ + + public class Parser { + /** + * Parse an XMLList into an array of the specified class instance by calling its parseXML function + * @param inXMLList: list of XML nodes + * @param inClass: classname to be instanced; class must implement IParsable + * @param ignoreError: if true, the return value of {@link #parseXML} is always added to the array, and the array itself is returned. Otherwise, an error in parsing will return null. + * @return Array of new objects of the specified type, cast to IParsable, or null if parsing returned false + */ + public static function parseList (inList:XMLList, inClass:Class, ignoreError:Boolean = false) : Array { + var a:Array = new Array(); + + var len:Number = inList.length(); + for (var i : Number = 0; i < len; i++) { + var ipa:IParsable = parseXML(inList[i], inClass, ignoreError); + if ((ipa == null) && !ignoreError) return null; + else a.push(ipa); + } + + return a; + } + + /** + * Parse XML into the specified class instance by calling its parseXML function + * @param inXML: XML document or node + * @param inClass: classname to be instanced; class must implement IParsable + * @param ignoreError: if true, the return value of {@link IParsable#parseXML} is ignored, and the newly created object is always returned. + * @return a new object of the specified type, cast to IParsable, or null if parsing returned false + */ + public static function parseXML (inXML:XML, inClass:Class, ignoreError:Boolean = false) : IParsable { + var ipa:IParsable = new inClass(); + if (ipa.parseXML(inXML) || ignoreError) { + return ipa; + } else { + return null; + } + } + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.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-05-23 20:03:28
|
Revision: 687 http://svn.sourceforge.net/asapframework/?rev=687&view=rev Author: acidcats Date: 2007-05-23 13:03:16 -0700 (Wed, 23 May 2007) Log Message: ----------- Added classes for XML parsing Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.as Added: branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as 2007-05-23 20:03:16 UTC (rev 687) @@ -0,0 +1,58 @@ +/* +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.data { + + import org.asapframework.data.xml.IParsable; + + /** + DataValueObject class to hold information about urls. + Can get its information through the {@link Parser} since it implements {@link IParsable}. + */ + + public class URLData implements IParsable { + // the names of the urls in the file settings.xml + + /** unique identifying name of url */ + public var name:String; + /** actual url to be opened */ + public var url:String; + /** target of getURL function */ + public var target:String; + + /** + * Constructor + * NB: This will be called without parameters by the Parser + */ + public function URLData (inName:String = null, inURL:String = null, inTarget:String = null) { + if (inName) name = inName; + if (inURL) url = inURL; + if (inTarget) target = inTarget; + } + + /** + * Parse XML + * @return true if parsing went ok, otherwise false: name & url are mandatory for this type of node + */ + public function parseXML (inXML:XML) : Boolean { + name = inXML.@name; + url = inXML.@url; + target = inXML.@target; + + return ((name != null) && (url != null)); + } + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/URLData.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as 2007-05-23 20:03:16 UTC (rev 687) @@ -0,0 +1,32 @@ +/* +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. +*/ + + +/** +Interface to implement in DataValueObject classes that get their data through the {@link Parser} class. +The {@link Parser} class calls the {@link #parseObject} function with data from {@link XML2Object#parseXML}. The implementing class is expected to use this Object to retrieve data from. +*/ + +package org.asapframework.data.xml { + public interface IParsable { + /** + * Parse an object from XML into typed variables. + * @param o: XML containing data + * @return true if parsing went ok, otherwise false + */ + function parseXML(o:XML) : Boolean; + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/IParsable.as ___________________________________________________________________ Name: svn:eol-style + native Added: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.as 2007-05-23 20:03:16 UTC (rev 687) @@ -0,0 +1,97 @@ +/* +Copyright 2005-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. +*/ + +package org.asapframework.data.xml { + + /** + Class for parsing XML data into DataValueObject classes. + The class provides static functions for calling {@link IParsable#parseObject} on newly created objects of a specified type, either for single data blocks or for an array of similar data. + The Parser removes the tedious for-loop from the location where the XML data is loaded, and moves the parsing of the XML data to the location where it's used for the first time: the DataValueObject class. Your application can use this data, that contains typed variables, without ever caring about the original source of the data. + When the XML structure is changed, only the parsing function in the DataValueObject class has to be changed, thereby facilitating maintenance and development. + + @use + Consider an XML file with the following content: + <code> + <?xml version="1.0" encoding="UTF-8"?> + <settings> + <urls> + <url name="addressform" url="../xml/address.xml" /> + <url name="entries" url="../xml/entries.xml" /> + </urls> + </settings> + </code> + Once the XML has been loaded, it can be converted into an Array of URLData objects with the following code: + <code> + // objects of type URLData + private var mURLs:Array; + + // parse XML + // @param o: XML + // @return true if parsing went ok, otherwise false + private function handleSettingsLoaded (o:XML) : Boolean { + mURLs = Parser.parseList(o.settings.urls.url, org.asapframework.data.loader.URLData, false); + + return (mURLs != null); + } + </code> + After calling this function, the member variable <code>mURLs</code> contains a list of objects of type URLData, filled with the content of the XML file. + + Notes to this code: + <ul> + <li>The first parameter to {@link #parseList} is a (can be a) repeating node where each node contains similar data to be parsed into </li> + <li>Conversion of nodes to an Array is not necessary. If the {@code <urls>}-node in the aforementioned XML file would contain only one {@code <url>}-node, the parser still returns an Array, with one object of type URLData.</li> + <li>Since the last parameter to the call to {@link #parseList} is false, an error in the xml data will result in mURLs being null. The parsing class determines if the data is valid or not, by returning true or false from parseObject().</li> + </ul> + */ + + public class Parser { + /** + * Parse an XMLList into an array of the specified class instance by calling its parseXML function + * @param inXMLList: list of XML nodes + * @param inClass: classname to be instanced; class must implement IParsable + * @param ignoreError: if true, the return value of {@link #parseXML} is always added to the array, and the array itself is returned. Otherwise, an error in parsing will return null. + * @return Array of new objects of the specified type, cast to IParsable, or null if parsing returned false + */ + public static function parseList (inList:XMLList, inClass:Class, ignoreError:Boolean = false) : Array { + var a:Array = new Array(); + + var len:Number = inList.length(); + for (var i : Number = 0; i < len; i++) { + var ipa:IParsable = parseXML(inList[i], inClass, ignoreError); + if ((ipa == null) && !ignoreError) return null; + else a.push(ipa); + } + + return a; + } + + /** + * Parse XML into the specified class instance by calling its parseXML function + * @param inXML: XML document or node + * @param inClass: classname to be instanced; class must implement IParsable + * @param ignoreError: if true, the return value of {@link IParsable#parseXML} is ignored, and the newly created object is always returned. + * @return a new object of the specified type, cast to IParsable, or null if parsing returned false + */ + public static function parseXML (inXML:XML, inClass:Class, ignoreError:Boolean = false) : IParsable { + var ipa:IParsable = new inClass(); + if (ipa.parseXML(inXML) || ignoreError) { + return ipa; + } else { + return null; + } + } + } +} Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/data/xml/Parser.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-05-20 19:47:09
|
Revision: 686 http://asapframework.svn.sourceforge.net/asapframework/?rev=686&view=rev Author: acidcats Date: 2007-05-20 12:45:46 -0700 (Sun, 20 May 2007) Log Message: ----------- Adapted FrameDelay internally & interface, no calling object needed anymore. Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as 2007-05-20 19:06:42 UTC (rev 685) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as 2007-05-20 19:45:46 UTC (rev 686) @@ -17,8 +17,7 @@ package org.asapframework.util { import flash.events.Event; - import org.asapframework.events.EventDelegate; - import org.asapframework.util.framepulse.FramePulse; + import org.asapframework.util.FramePulse; /** Class that provides one or more frames delay. @@ -38,7 +37,7 @@ ... do a bunch of inits // wait one enterFrame - mFrameDelay = new FrameDelay(this, initDone); + mFrameDelay = new FrameDelay(initDone); } private function initDone () : void { @@ -51,11 +50,9 @@ </code> When starting a swf: - <code> - var lc:LocalController = new MyLocalController(this); // wait one enterFrame before notifying the MovieManager that this movie is done initializing - var fd:FrameDelay = new FrameDelay(lc, lc.notifyMovieInitialized); + var fd:FrameDelay = new FrameDelay(lc.notifyMovieInitialized); </code> @todo Update docs @@ -65,24 +62,18 @@ private var mIsDone:Boolean = false; private var mCurrentFrame:int; - private var mSender:Object; private var mCallback:Function; private var mParams:Array; - private static var sFramePulse:FramePulse; /** Constructor; starts the waiting immediately. - @param inSender:Object, the class that contains the function to be called when done waiting @param inCallback:Function, the callback function to be called when done waiting @param inFrameCount:Number, the number of frames to wait; when left out, or set to 1 or 0, one frame is waited @param inParams:Array, list of paramters to pass to callback function */ - public function FrameDelay (inSender:Object, inCallback:Function, inFrameCount:Number = undefined, inParams:Array = undefined) { - if (!sFramePulse) { - sFramePulse = new FramePulse(); - } - wait(inSender, inCallback, inFrameCount, inParams); + public function FrameDelay (inCallback:Function, inFrameCount:Number = Number.NaN, inParams:Array = null) { + wait(inCallback, inFrameCount, inParams); } /** @@ -91,7 +82,7 @@ */ public function die () : void { if (!mIsDone) { - sFramePulse.removeEnterFrameListener(onEnterFrame); + FramePulse.removeEnterFrameListener(handleEnterFrame); } } @@ -100,29 +91,29 @@ /** Stores input parameters (see {@link #FrameDelay constructor} parameters), start waiting. */ - private function wait (inSender:Object, inCallback:Function, inFrameCount:Number, inParams:Array) : void { + private function wait (inCallback:Function, inFrameCount:Number, inParams:Array) : void { mCurrentFrame = inFrameCount; - mSender = inSender; mCallback = inCallback; mParams = inParams; - mIsDone = ((inFrameCount == undefined) || (inFrameCount <= 1)); + mIsDone = (isNaN(inFrameCount) || (inFrameCount <= 1)); // listen to framepulse events - sFramePulse.addEnterFrameListener(onEnterFrame); + FramePulse.addEnterFrameListener(handleEnterFrame); } /** Handle the onEnterFrame event. Checks if still waiting - when true: calls callback function. */ - private function onEnterFrame (e:Event) : void { - + private function handleEnterFrame (e:Event) : void { if (mIsDone) { - sFramePulse.removeEnterFrameListener(onEnterFrame); - sFramePulse.die(); - delete sFramePulse; - mCallback.apply(mSender,mParams); + FramePulse.removeEnterFrameListener(handleEnterFrame); + if (mParams == null) { + mCallback(); + } else { + mCallback(mParams); + } } else { mCurrentFrame--; mIsDone = (mCurrentFrame <= 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-05-20 19:46:41
|
Revision: 686 http://svn.sourceforge.net/asapframework/?rev=686&view=rev Author: acidcats Date: 2007-05-20 12:45:46 -0700 (Sun, 20 May 2007) Log Message: ----------- Adapted FrameDelay internally & interface, no calling object needed anymore. Modified Paths: -------------- branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as Modified: branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as 2007-05-20 19:06:42 UTC (rev 685) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FrameDelay.as 2007-05-20 19:45:46 UTC (rev 686) @@ -17,8 +17,7 @@ package org.asapframework.util { import flash.events.Event; - import org.asapframework.events.EventDelegate; - import org.asapframework.util.framepulse.FramePulse; + import org.asapframework.util.FramePulse; /** Class that provides one or more frames delay. @@ -38,7 +37,7 @@ ... do a bunch of inits // wait one enterFrame - mFrameDelay = new FrameDelay(this, initDone); + mFrameDelay = new FrameDelay(initDone); } private function initDone () : void { @@ -51,11 +50,9 @@ </code> When starting a swf: - <code> - var lc:LocalController = new MyLocalController(this); // wait one enterFrame before notifying the MovieManager that this movie is done initializing - var fd:FrameDelay = new FrameDelay(lc, lc.notifyMovieInitialized); + var fd:FrameDelay = new FrameDelay(lc.notifyMovieInitialized); </code> @todo Update docs @@ -65,24 +62,18 @@ private var mIsDone:Boolean = false; private var mCurrentFrame:int; - private var mSender:Object; private var mCallback:Function; private var mParams:Array; - private static var sFramePulse:FramePulse; /** Constructor; starts the waiting immediately. - @param inSender:Object, the class that contains the function to be called when done waiting @param inCallback:Function, the callback function to be called when done waiting @param inFrameCount:Number, the number of frames to wait; when left out, or set to 1 or 0, one frame is waited @param inParams:Array, list of paramters to pass to callback function */ - public function FrameDelay (inSender:Object, inCallback:Function, inFrameCount:Number = undefined, inParams:Array = undefined) { - if (!sFramePulse) { - sFramePulse = new FramePulse(); - } - wait(inSender, inCallback, inFrameCount, inParams); + public function FrameDelay (inCallback:Function, inFrameCount:Number = Number.NaN, inParams:Array = null) { + wait(inCallback, inFrameCount, inParams); } /** @@ -91,7 +82,7 @@ */ public function die () : void { if (!mIsDone) { - sFramePulse.removeEnterFrameListener(onEnterFrame); + FramePulse.removeEnterFrameListener(handleEnterFrame); } } @@ -100,29 +91,29 @@ /** Stores input parameters (see {@link #FrameDelay constructor} parameters), start waiting. */ - private function wait (inSender:Object, inCallback:Function, inFrameCount:Number, inParams:Array) : void { + private function wait (inCallback:Function, inFrameCount:Number, inParams:Array) : void { mCurrentFrame = inFrameCount; - mSender = inSender; mCallback = inCallback; mParams = inParams; - mIsDone = ((inFrameCount == undefined) || (inFrameCount <= 1)); + mIsDone = (isNaN(inFrameCount) || (inFrameCount <= 1)); // listen to framepulse events - sFramePulse.addEnterFrameListener(onEnterFrame); + FramePulse.addEnterFrameListener(handleEnterFrame); } /** Handle the onEnterFrame event. Checks if still waiting - when true: calls callback function. */ - private function onEnterFrame (e:Event) : void { - + private function handleEnterFrame (e:Event) : void { if (mIsDone) { - sFramePulse.removeEnterFrameListener(onEnterFrame); - sFramePulse.die(); - delete sFramePulse; - mCallback.apply(mSender,mParams); + FramePulse.removeEnterFrameListener(handleEnterFrame); + if (mParams == null) { + mCallback(); + } else { + mCallback(mParams); + } } else { mCurrentFrame--; mIsDone = (mCurrentFrame <= 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aci...@us...> - 2007-05-20 19:07:33
|
Revision: 685 http://asapframework.svn.sourceforge.net/asapframework/?rev=685&view=rev Author: acidcats Date: 2007-05-20 12:06:42 -0700 (Sun, 20 May 2007) Log Message: ----------- Changed internal workings & interface of FramePulse. FramePulse moved to package util. Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as Added: branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as 2007-05-20 19:06:42 UTC (rev 685) @@ -0,0 +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. +*/ + +/** +TODO: update docs +*/ + +package org.asapframework.util { + + import flash.display.Sprite; + import flash.events.Event; + import flash.events.EventDispatcher; + + /** + Class to generate onEnterFrame events. + @usage + <code> + FramePulse.addEventListener(handleEnterFrame); + + // function that handles onEnterFrame events + public function handleEnterFrame (e:Event) : void { + + // code goes here... + } + </code> + To stop receiving the onEnterFrame event: + <code> + FramePulse.removeEventListener(handleEnterFrame); + </code> + */ + + public class FramePulse extends EventDispatcher { + + private static var mSprite : Sprite = null; + + /** + Add a listener to the FramePulse + @param inHandler: function to be called on enterframe, with parameter FramePulseEvent + */ + public static function addEnterFrameListener (inHandler:Function) : void { + if (mSprite == null) { + mSprite = new Sprite(); + } + mSprite.addEventListener(Event.ENTER_FRAME, inHandler); + } + + /** + Remove a listener from the FramePulse + @param inHandler: function that was previously added + */ + public static function removeEnterFrameListener (inHandler:Function) : void { + if (mSprite != null) { + mSprite.removeEventListener(Event.ENTER_FRAME, inHandler); + } + } + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.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-05-20 19:07:22
|
Revision: 685 http://svn.sourceforge.net/asapframework/?rev=685&view=rev Author: acidcats Date: 2007-05-20 12:06:42 -0700 (Sun, 20 May 2007) Log Message: ----------- Changed internal workings & interface of FramePulse. FramePulse moved to package util. Added Paths: ----------- branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as Added: branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as (rev 0) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as 2007-05-20 19:06:42 UTC (rev 685) @@ -0,0 +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. +*/ + +/** +TODO: update docs +*/ + +package org.asapframework.util { + + import flash.display.Sprite; + import flash.events.Event; + import flash.events.EventDispatcher; + + /** + Class to generate onEnterFrame events. + @usage + <code> + FramePulse.addEventListener(handleEnterFrame); + + // function that handles onEnterFrame events + public function handleEnterFrame (e:Event) : void { + + // code goes here... + } + </code> + To stop receiving the onEnterFrame event: + <code> + FramePulse.removeEventListener(handleEnterFrame); + </code> + */ + + public class FramePulse extends EventDispatcher { + + private static var mSprite : Sprite = null; + + /** + Add a listener to the FramePulse + @param inHandler: function to be called on enterframe, with parameter FramePulseEvent + */ + public static function addEnterFrameListener (inHandler:Function) : void { + if (mSprite == null) { + mSprite = new Sprite(); + } + mSprite.addEventListener(Event.ENTER_FRAME, inHandler); + } + + /** + Remove a listener from the FramePulse + @param inHandler: function that was previously added + */ + public static function removeEnterFrameListener (inHandler:Function) : void { + if (mSprite != null) { + mSprite.removeEventListener(Event.ENTER_FRAME, inHandler); + } + } + } +} \ No newline at end of file Property changes on: branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.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-05-20 19:05:53
|
Revision: 684 http://asapframework.svn.sourceforge.net/asapframework/?rev=684&view=rev Author: acidcats Date: 2007-05-20 12:05:29 -0700 (Sun, 20 May 2007) Log Message: ----------- Changed internal workings & interface of FramePulse. FramePulse moved to package util. Removed Paths: ------------- branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as Deleted: branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as =================================================================== --- branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as 2007-05-20 19:01:07 UTC (rev 683) +++ branches/dev_as3/asapframework/lib/org/asapframework/util/FramePulse.as 2007-05-20 19:05:29 UTC (rev 684) @@ -1,70 +0,0 @@ -/* -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. -*/ - -/** -TODO: update docs -*/ - -package org.asapframework.util { - - import flash.display.Sprite; - import flash.events.Event; - import flash.events.EventDispatcher; - - /** - Class to generate onEnterFrame events. - @usage - <code> - FramePulse.addEventListener(handleEnterFrame); - - // function that handles onEnterFrame events - public function handleEnterFrame (e:Event) : void { - - // code goes here... - } - </code> - To stop receiving the onEnterFrame event: - <code> - FramePulse.removeEventListener(handleEnterFrame); - </code> - */ - - public class FramePulse extends EventDispatcher { - - private static var mSprite : Sprite = null; - - /** - Add a listener to the FramePulse - @param inHandler: function to be called on enterframe, with parameter FramePulseEvent - */ - public static function addEnterFrameListener (inHandler:Function) : void { - if (mSprite == null) { - mSprite = new Sprite(); - } - mSprite.addEventListener(Event.ENTER_FRAME, inHandler); - } - - /** - Remove a listener from the FramePulse - @param inHandler: function that was previously added - */ - public static function removeEnterFrameListener (inHandler:Function) : void { - if (mSprite != null) { - mSprite.removeEventListener(Event.ENTER_FRAME, inHandler); - } - } - } -} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |