<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Converted Flex to Flash Tutorial Example Files"]]></title>
		<link>http://forum.alternativaplatform.com/posts/list/40.page</link>
		<description><![CDATA[Latest messages posted in the topic "Converted Flex to Flash Tutorial Example Files"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Converted Flex to Flash Tutorial Example Files</title>
				<description><![CDATA[ Heya<br /> <br /> I dont use Flex so I ran into problems with the tutorials from [url=http://www.thetechlabs.com/author/mcasperson/]Matthew Casperson[/url].  Im sure you are all aware of them by now.  Thanks go out to him for his work.<br /> <br /> Main problems to overcome where the mx.core.Application methods. ArrayCollection gave me instant problems so I found a class written for just such a thing. Thanks go to [url=http://www.michaeljameswilliams.com]Michael James Williams[/url]. This was a real lifesaver.<br /> <br /> Next it was a case of adding the mesh to the scene.  This meant making sure the Document Class was used a static var for all classes to access.<br /> <br /> I commented out the flex code just to show where the changes were.<br /> <br /> <br /> <br /> [b]Instructions[/b]<br /> <br /> 1. Create a new flash file, add the source files in the src directory (File-&gt;Publish Settings-&gt;Flash Tab-&gt;Settings) and set the Document Root as EngineManager.  <br /> 2. Uncheck "declare all stage instances" (File-&gt;Publish Settings-&gt;Flash Tab-&gt;Settings).<br /> <br /> <br /> [b]EngineManager.as[/b]<br /> [code]<br /> package<br /> {<br /> 	import alternativa.engine3d.controllers.WalkController;<br /> 	import alternativa.engine3d.core.Camera3D;<br /> 	import alternativa.engine3d.core.Object3D;<br /> 	import alternativa.engine3d.core.Scene3D;<br /> 	import alternativa.engine3d.display.View;<br /> 	import alternativa.types.Point3D;<br /> 	import alternativa.utils.FPS;<br /> 	<br /> 	import flash.display.StageAlign;<br /> 	import flash.display.StageScaleMode;<br /> 	import flash.events.Event;<br /> 	import flash.display.MovieClip;<br /> 	import flash.display.Sprite;<br /> 	import flash.utils.*;<br /> 	<br /> 	<br /> 	/**<br /> 	 * 	The EngineManager holds all of the code related to maintaining the Alternativa 3D engine.<br /> 	 */<br /> 	public class EngineManager extends Sprite<br /> 	{<br /> 		<br /> 		public var scene:Scene3D;<br /> 		public var view:View;<br /> 		public var camera:Camera3D;<br /> 		public var cameraController:WalkController;<br /> 		<br /> 		//*** set the static var so other classes can reference the scene ***//<br /> 		private static var eman:EngineManager = null;<br /> 				<br /> 		// a collection of the BaseObjects<br /> 		//*** this is using Collection.as as opposed to a Flex ArrayCollection **//<br /> 		protected var baseObjects:Collection = new Collection();<br /> 		// a collection where new BaseObjects are placed, to avoid adding items <br /> 		// to baseObjects while in the baseObjects collection while it is in a loop<br /> 		protected var newBaseObjects:Collection = new Collection();<br /> 		// a collection where removed BaseObjects are placed, to avoid removing items <br /> 		// to baseObjects while in the baseObjects collection while it is in a loop<br /> 		protected var removedBaseObjects:Collection = new Collection();<br /> 		// the last frame time <br /> 		protected var lastFrame:Date;<br /> 		<br /> 		protected var applicationManagerStarted:Boolean = false;<br /> 		<br /> <br /> 		<br /> 		public function EngineManager()<br /> 		{<br /> 			//** create an instance of EngineManager for referernce in other classes **//<br /> 			eman = this;<br /> 			super();<br /> 			addEventListener(Event.ADDED_TO_STAGE, init);<br /> 			<br /> 		}<br /> 		//** Access the Document Class from another class.<br /> 		//** :Example: Tell cameraController to lookAt scene.root.coords<br /> 		//** EngineManager.Instance.cameraController.lookAt(mesh.model.coords);<br /> 		public static function get Instance():EngineManager { return eman; }<br /> <br /> 		<br /> 		public function init(e:Event): void<br /> 		{<br /> 			stage.scaleMode = StageScaleMode.NO_SCALE;<br /> 			stage.align = StageAlign.TOP_LEFT;<br /> 			<br /> 			// Creating scene<br /> 			scene = new Scene3D();<br /> 			scene.root = new Object3D();<br /> 			scene.splitAnalysis = false;<br /> <br /> 			// Adding camera and view<br /> 			camera = new Camera3D();<br /> 			camera.x = 10;<br /> 			camera.y = 10;<br /> 			camera.z = 10;<br /> 			camera.farClipping = true;<br /> 			camera.farClippingDistance = 250;<br /> 			scene.root.addChild(camera);<br /> 			<br /> 			view = new View();<br /> 			view.interactive = true;<br /> 			addChild(view);<br /> 			view.camera = camera;<br /> <br /> 			// Connecting camera controller<br /> 			cameraController = new WalkController(stage);   <br /> 			cameraController.object = camera; <br /> 			cameraController.flyMode = false;<br /> 			cameraController.speed = 100;<br /> 			cameraController.pitchSpeed = 1;<br /> 			cameraController.yawSpeed = 1;<br /> 			cameraController.gravity = 0;   <br /> 			cameraController.jumpSpeed = 60;<br /> 			cameraController.setDefaultBindings();<br /> 			<br /> 			cameraController.checkCollisions = true;   <br /> 			cameraController.collider.radiusX = 5;   <br /> 			cameraController.collider.radiusY = 5;   <br /> 			cameraController.collider.radiusZ = 5;   <br /> 			cameraController.coords = new Point3D(75, 75, 25);   <br /> 			//cameraController.lookAt(scene.root.coords);<br /> <br /> 			// FPS display launch<br /> 			FPS.init(stage);<br /> <br /> 			stage.addEventListener(Event.RESIZE, onResize);<br /> 			stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);<br /> 			onResize(null);<br /> <br /> 			// set the initial frame time<br /> 			lastFrame = new Date();<br /> 			<br /> 						<br /> 			// load the resources<br /> 			ResourceManager.loadResources();			<br /> 		}<br /> 		<br /> 		private function onResize(e:Event):void <br /> 		{<br /> 			view.width = stage.stageWidth;<br /> 			view.height = stage.stageHeight;<br /> 		}<br /> <br /> 		protected function onEnterFrame(event:Event):void <br /> 		{<br /> 			if (ResourceManager.allResourcesLoaded)<br /> 			{	<br /> 				if (!applicationManagerStarted)<br /> 				{<br /> 					applicationManagerStarted = true;<br /> 					// start the application<br /> 					ApplicationManager.Instance.startupApplicationManager();<br /> 				}<br /> <br /> 				<br /> 				// Calculate the time since the last frame<br /> 				var thisFrame:Date = new Date();<br /> 				var seconds:Number = (thisFrame.getTime() - lastFrame.getTime())/1000.0;<br /> 		    	lastFrame = thisFrame;<br /> 		    	<br /> 		    	// sync the baseObjects collection with any BaseObjects created or removed during the <br /> 		    	// render loop<br /> 		    	removeDeletedBaseObjects();<br /> 		    	insertNewBaseObjects();<br /> 		    	<br /> 		    	// allow each BaseObject to update itself<br /> 		    	for each (var baseObject:BaseObject in baseObjects)<br /> 		    		baseObject.enterFrame(seconds);<br /> 		    	<br /> 		    	<br /> 				//cam controller always pointing at scene<br /> 				cameraController.lookAt(scene.root.coords);<br /> 				// User input processing<br /> 				cameraController.processInput();<br /> 				// Scene calculating<br /> 				scene.calculate();<br /> 			}<br /> 		}<br /> 		<br /> 		public function addBaseObject(baseObject:BaseObject):void<br /> 		{<br /> 			newBaseObjects.addItem(baseObject);<br /> 		}<br /> 		<br /> 		public function removeBaseObject(baseObject:BaseObject):void<br /> 		{<br /> 			removedBaseObjects.addItem(baseObject);<br /> 		}<br /> 		<br /> 		protected function shutdownAll():void<br /> 		{<br /> 			// don't dispose objects twice<br /> 			for each (var baseObject:BaseObject in baseObjects)<br /> 			{<br /> 				var found:Boolean = false;<br /> 				for each (var removedObject:BaseObject in removedBaseObjects)<br /> 				{<br /> 					if (removedObject == baseObject)<br /> 					{<br /> 						found = true;<br /> 						break;<br /> 					}<br /> 				}<br /> 				<br /> 				if (!found)<br /> 					baseObject.shutdown();<br /> 			}<br /> 		}<br /> 		<br /> 		protected function insertNewBaseObjects():void<br /> 		{<br /> 			for each (var baseObject:BaseObject in newBaseObjects)<br /> 				baseObjects.addItem(baseObject);<br /> 			<br /> 			newBaseObjects.removeAll();<br /> 		}<br /> 		<br /> 		protected function removeDeletedBaseObjects():void<br /> 		{<br /> 			for each (var removedObject:BaseObject in removedBaseObjects)<br /> 			{<br /> 				var i:int = 0;<br /> 				for (i = 0; i &lt; baseObjects._collection.length; ++i)<br /> 				{<br /> 					if (baseObjects.getItemAt(i) == removedObject)<br /> 					{<br /> 						baseObjects.removeItemAt(i);<br /> 						break;<br /> 					}<br /> 				}<br /> 				<br /> 			}<br /> 			<br /> 			removedBaseObjects.removeAll();<br /> 		}<br /> 	}<br /> }<br /> [/code]<br /> <br /> The changes here reflect :<br /> <br /> [list]setting a private static var to reference the DocumentClass[/list]<br /> [list]using a custom Collection.as class to substitute ArrayCollection[/list]<br /> [list]creating a function to instantiate the class for reference using the private static var as a return value[/list]<br /> <br /> <br /> <br /> [b]BaseObject.as[/b]<br /> <br /> [code]<br /> package<br /> {<br /> 		<br /> 	/**<br /> 	 *	The BaseObject class allows extending classes to update themselves during the render loop. <br /> 	 */<br /> 	public class BaseObject<br /> 	{<br /> 		<br /> 	<br /> 		public function BaseObject()<br /> 		{<br /> 			<br /> 		}<br /> 		<br /> 		/**<br /> 		 * 	Must be called by all extending classes when being created. Adds this object to the list of BaseObjects maintained<br /> 		 * 	by the EngineManager.<br /> 		 */<br /> 		public function startupBaseObject():void<br /> 		{<br /> 			//** Flex code commented out<br /> 			//Application.application.engineManager.addBaseObject(this);<br /> 			EngineManager.Instance.addBaseObject(this);<br /> 			<br /> <br /> 		}<br /> 		<br /> 		/**<br /> 		 * 	Must be called by all extending classes when being destroyed. Removes this object to the list of BaseObjects maintained<br /> 		 * 	by the EngineManager.<br /> 		 */<br /> 		public function shutdown():void<br /> 		{<br /> 			//** Flex code commented out<br /> 			//Application.application.engineManager.removeBaseObject(this);<br /> 			EngineManager.Instance.removeBaseObject(this);<br /> <br /> 		} <br /> 		<br /> 		/**<br /> 		 * 	This function is called once per frame before the scene is rendered.<br /> 		 * <br /> 		 * 	@param dt The time in seconds since the last frame was rendered.<br /> 		 */<br /> 		public function enterFrame(dt:Number):void<br /> 		{<br /> 			<br /> 		}<br /> 	}<br /> }<br /> [/code]<br /> <br /> Changes here reflect usage of an instance of EngineManager to reference objects, properties and functions.<br /> <br /> <br /> [b]ApplicationManager.as[/b]<br /> <br /> [code]<br /> package<br /> {<br /> 	import alternativa.types.Point3D;<br /> 	<br /> <br /> 	/**<br /> 	 * 	The ApplicationManager holds all program related logic.<br /> 	 */<br /> 	public class ApplicationManager extends BaseObject<br /> 	{<br /> 		protected static var instance:ApplicationManager = null;<br /> 		protected var mesh:MeshObject = null;<br /> 		<br /> <br /> 		public static function get Instance():ApplicationManager<br /> 		{<br /> 			if (instance == null)<br /> 				instance = new ApplicationManager();<br /> 			return instance;<br /> 		}<br /> 		<br /> 		public function ApplicationManager()<br /> 		{<br /> 			super();<br /> 		}<br /> 		<br /> 		public function startupApplicationManager():ApplicationManager<br /> 		{<br /> 			mesh = new MeshObject().startupModelObject(ResourceManager.fighter);<br /> 			super.startupBaseObject();<br /> 			return this;<br /> 		}<br /> 		<br /> 		public override function enterFrame(dt:Number):void<br /> 		{<br /> 			//EngineManager.Instance.cameraController.lookAt(mesh.model.coords);<br /> 		}<br /> 	}<br /> }<br /> [/code]<br /> <br /> No changes here except removal of a tutorial camera example to give it a simpler look<br /> <br /> <br /> <br /> [b]MeshObject.as[/b]<br /> <br /> [code]<br /> package<br /> {<br /> 	import alternativa.engine3d.core.Mesh;<br /> 	<br /> <br /> 	public class MeshObject extends BaseObject<br /> 	{<br /> 		<br /> 		public var model:Mesh = null;<br /> 		<br /> 		public function MeshObject()<br /> 		{<br /> 			super();<br /> 		}<br /> 		<br /> 		override public function shutdown():void<br /> 		{<br /> 			super.shutdown();<br /> 			//** flex code commented out<br /> 			//Application.application.engineManager.scene.root.removeChild(model);<br /> 			EngineManager.Instance.scene.root.removeChild(model);<br /> <br /> 			<br /> 			model = null;<br /> 		}<br /> 		<br /> 		public function startupModelObject(object:Mesh):MeshObject<br /> 		{<br /> 			model = object;<br /> 			//** flex code commented out<br /> 			//Application.application.engineManager.scene.root.addChild(model);<br /> 			EngineManager.Instance.scene.root.addChild(model);<br /> <br /> 			<br /> 			super.startupBaseObject();<br /> 			return this;<br /> 		}<br /> 	}<br /> }<br /> [/code]<br /> <br /> Changes here reflect usage of an instance of EngineManager to reference objects, properties and functions.<br /> <br /> <br /> <br /> [b]ResourceManager.as[/b]<br /> <br /> [code]<br /> package<br /> {<br /> 	import alternativa.engine3d.core.Mesh;<br /> 	import alternativa.engine3d.core.Object3D;<br /> 	import alternativa.engine3d.loaders.LoaderOBJ;<br /> 	import alternativa.engine3d.materials.TextureMaterialPrecision;<br /> 	import alternativa.utils.MeshUtils;<br /> 	<br /> 	import flash.events.Event;<br /> 	import flash.events.IOErrorEvent;<br /> 	import flash.events.SecurityErrorEvent;<br /> 	<br /> 	<br /> 	/**<br /> 	 * 	ResourceManager is where we embed and create the resources needed by our application<br /> 	 */ <br /> 	public class ResourceManager<br /> 	{<br /> 		protected static const SERVER_URL:String = "";<br /> 		<br /> 		public static var fighter:Mesh = null;<br /> 		protected static var fighterLoader:LoaderOBJ = null;<br /> 		protected static var fighterLoaded:Boolean = false;<br /> 		<br /> 		public static function get allResourcesLoaded():Boolean<br /> 		{<br /> 			return fighterLoaded;<br /> 		}<br /> 		<br /> 		public static function loadResources():void<br /> 		{<br /> 			fighterLoader = new LoaderOBJ();<br /> 			fighterLoader.smooth = true;<br /> 			fighterLoader.precision = TextureMaterialPrecision.HIGH;<br /> 			<br /> 			// watch out - case counts on some web servers, but not in windows<br /> 			fighterLoader.load(SERVER_URL + "models/fighter/fighter.obj");<br /> 			fighterLoader.addEventListener(Event.COMPLETE, onLoadFighterComplete);<br /> 			fighterLoader.addEventListener(IOErrorEvent.IO_ERROR, ioError);<br /> 			fighterLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityError);<br /> 		}<br /> 		<br /> 		protected static function ioError(e:Event):void<br /> 		{<br /> 			//Application.application.lblLoading.text = "Error Loading";<br /> 			trace("Error Loading:IO Error");<br /> 		}<br /> 		<br /> 		protected static function securityError(e:Event):void<br /> 		{<br /> 			//Application.application.lblLoading.text = "Error Loading";<br /> 			trace("Error Loading:Security Error");<br /> 		}<br /> 		<br /> 		protected static function weldVerticesAndFaces(object:Object3D):void <br /> 		{<br /> 			if (object != null)<br /> 			{<br /> 				if (object is Mesh) <br /> 				{<br /> 					MeshUtils.autoWeldVertices(Mesh(object), 0.01);<br /> 					MeshUtils.autoWeldFaces(Mesh(object), 0.01, 0.001);<br /> 				}<br /> 				<br /> 				// Launching procedure for object's children<br /> 				for (var key:* in object.children) <br /> 				{<br /> 					weldVerticesAndFaces(key);<br /> 				}<br /> 			}<br /> 		}<br /> <br /> 		protected static function onLoadFighterComplete(e:Event):void<br /> 		{<br /> 			for (var o:* in fighterLoader.content.children)<br /> 			{<br /> 				fighter = o;<br /> 				weldVerticesAndFaces(fighter);<br /> 				break;<br /> 			}<br /> 			<br /> 			fighterLoaded = true;<br /> 			<br /> 		}<br /> 	}<br /> }<br /> [/code]<br /> <br /> I changed this to load OBJ files as I find them more compatible than loading 3DS files.<br /> <br /> <br /> <br /> [b]Collection.as[/b]<br /> <br /> [code]<br /> package {<br /> 	/**<br /> 	 * Collection Class<br /> 	 * Version 1.0, 2008-09-20<br /> 	 * Created by Michael James Williams<br /> 	 * http://www.michaeljameswilliams.com<br /> 	 */<br /> 	public class Collection extends BaseObject {<br /> 		<br /> 		public var _collection:Array;<br /> <br /> 		/**<br /> 		 * Creates a new collection populated with the specified values<br /> 		 * @param	... values<br /> 		 */<br /> 		public function Collection(... values) {<br /> 			_collection = new Array();	<br /> 			addItem(values);<br /> 		}<br /> 		//remove all items<br /> 		public function removeAll():void {<br /> 			_collection = new Array();<br /> 		}<br /> 		//get the item specified<br /> 		public function getItemAt(index:int, prefetch:int = 0):Object {<br /> 			return(_collection[Object]);<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Adds the specified items to the collection<br /> 		 * @param	... items<br /> 		 */<br /> 		public function addItem(... items):void {<br /> 			for each (var item in items) {<br /> 				if (item is Array) {<br /> 					for each (var subItem in item) {<br /> 						addItem(subItem);<br /> 					}<br /> 				} else if (item is Collection) {<br /> 					for each (subItem in item.itemList) {<br /> 						addItem(subItem);<br /> 					}<br /> 				} else {<br /> 					if (!contains(item)) {<br /> 						_collection.push(item);<br /> 					}<br /> 				}<br /> 			}<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Removes all of the specified items from the collection<br /> 		 * @param	... items<br /> 		 */<br /> 		public function removeItemAt(... items):void {<br /> 			for each (var item in items) {<br /> 				if (item is Array) {<br /> 					for each (var subItem in item) {<br /> 						removeItemAt(subItem);<br /> 					}<br /> 				} else if (item is Collection) {<br /> 					for each (subItem in item.itemList) {<br /> 						removeItemAt(subItem);<br /> 					}<br /> 				} else if (contains(item)) {<br /> 					_collection.splice(_collection.indexOf(item), 1);<br /> 				}<br /> 			}<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns true iff collection contains (or is) specified item<br /> 		 * @param	item<br /> 		 * @return<br /> 		 */<br /> 		public function contains(item):Boolean {	<br /> 			if ((item is Array) || (item is Collection)) {<br /> 				return containsAll(item);<br /> 			} else {<br /> 				if ((_collection.indexOf(item) &gt; -1) || (this === item)) {<br /> 					return true;<br /> 				} else {<br /> 					return false;<br /> 				}<br /> 			}<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns true iff collection contains all specified items (including subitems of an array or collection)<br /> 		 * @param	... items<br /> 		 * @return<br /> 		 */<br /> 		public function containsAll(... items):Boolean {	<br /> 			var all:Boolean = true;<br /> 			for each (var item in items) {<br /> 				if (item is Array) {<br /> 					for each (var subItem in item) {<br /> 						if (!_collection.containsAll(subItem)) { all = false; }<br /> 					}<br /> 				} else if (item is Collection) {<br /> 					for each (subItem in item.itemList) {<br /> 						if (!_collection.containsAll(subItem)) { all = false; }<br /> 					}<br /> 				} else {	<br /> 					if (!_collection.contains(item)) { all = false; }<br /> 				}<br /> 			}<br /> 			return all;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns true iff collection contains any of the specified items (including subitems of an array or collection)<br /> 		 * @param	... items<br /> 		 * @return<br /> 		 */<br /> 		public function containsAny(... items):Boolean {	<br /> 			var any:Boolean = false;<br /> 			for each (var item in items) {<br /> 				if (item is Array) {<br /> 					for each (var subItem in item) {<br /> 						if (!_collection.containsAny(subItem)) { <br /> 							any = true;<br /> 							break;<br /> 						}<br /> 					}<br /> 				} else if (item is Collection) {<br /> 					for each (subItem in item.itemList) {<br /> 						if (!_collection.containsAny(subItem)) { <br /> 							any = true; <br /> 							break;<br /> 						}<br /> 					}<br /> 				} else {	<br /> 					if (!_collection.contains(item)) { <br /> 						any = true;<br /> 						break;<br /> 					}<br /> 				}<br /> 			}<br /> 			return any;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Executes a test function on each item in the collection and constructs a new collection of all items that return true.<br /> 		 * @param	callback<br /> 		 * @param	thisObject<br /> 		 * @return<br /> 		 */<br /> 		public function filter(callback:Function, thisObject:* = null):Collection {<br /> 			var filtered:Collection = new Collection();<br /> 			filtered.addItem(_collection.filter(callback, thisObject));<br /> 			return filtered;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Executes a function on each item in the collection.<br /> 		 * @param	callback<br /> 		 * @param	thisObject<br /> 		 */<br /> 		public function forEach(callback:Function, thisObject:* = null):void {<br /> 			_collection.forEach(callback, thisObject);<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Converts the elements in a collection to strings, inserts the specified separator between the elements, concatenates them, and returns the resulting string.<br /> 		 * @param	sep<br /> 		 * @return<br /> 		 */<br /> 		public function join(sep:*):String { <br /> 			return _collection.join(sep);<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Executes a function on each item in an collection, and constructs a new collection of items corresponding to the results of the function on each item in the original collection.<br /> 		 * @param	callback<br /> 		 * @param	thisObject<br /> 		 * @return<br /> 		 */<br /> 		public function map(callback:Function, thisObject:* = null):Collection {<br /> 			var mappedArray:Array = _collection.map(callback, thisObject);<br /> 			var mappedCollection:Collection = new Collection();<br /> 			for each (var item in mappedArray) {<br /> 				mappedCollection.addItem(item);<br /> 			}<br /> 			return mappedCollection;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Executes a test function on each item in the collection until an item is reached that returns true. Use this method to determine whether any items in a collection meet a criterion, such as having a value less than a particular number.<br /> 		 * @param	callback<br /> 		 * @param	thisObject<br /> 		 * @return<br /> 		 */<br /> 		public function some(callback:Function, thisObject:* = null):Boolean {<br /> 			return _collection.some(callback, thisObject);<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Executes a test function on each item in the collection until an item is reached that returns false for the specified function. You use this method to determine whether all items in a collection meet a criterion, such as having values less than a particular number. <br /> 		 * @param	callback<br /> 		 * @param	thisObject<br /> 		 * @return<br /> 		 */<br /> 		public function every(callback:Function, thisObject:* = null):Boolean {<br /> 			return _collection.every(callback, thisObject);<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns a collection made up of items in this collection for which item.property==value<br /> 		 * @param	property<br /> 		 * @param	value<br /> 		 * @return<br /> 		 */<br /> 		public function subCollection(property:String, value:*):Collection { <br /> 			///Ideally this would accept a method name and a ...params and check to see if item.method(...params)==true<br /> 			var subCollection:Collection = new Collection();<br /> 			for each (var item in _collection) {<br /> 				try {<br /> 					if (item[property]==value) {<br /> 						subCollection.addItem(item);<br /> 					}	<br /> 				} catch (err) {<br /> 					//this is likely to be very very error prone if the programmer isn't careful so we'll just break out of the loop<br /> 					break;<br /> 				}<br /> 			}<br /> 			return subCollection;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns a collection made up of all items that are in both this collection and the specified collection<br /> 		 * @param	coll<br /> 		 * @return<br /> 		 */<br /> 		public function intersection(coll:Collection):Collection {<br /> 			var intersectColl:Collection=new Collection();<br /> 			for each (var item in coll.itemList) {<br /> 				if (this.contains(item)) { <br /> 					intersectColl.addItem(item);<br /> 				}<br /> 			}<br /> 			return intersectColl;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns the intersection of this collection with an arbitrary number of other collections<br /> 		 * @param	... colls<br /> 		 * @return<br /> 		 */<br /> 		public function intersectMany(... colls):Collection {<br /> 			var intersectColl:Collection = new Collection();<br /> 			intersectColl.addItem(_collection);<br /> 			for each (var subItem in colls) {<br /> 				if (subItem is Collection) {<br /> 					intersectColl = intersectColl.intersection(subItem);<br /> 				}<br /> 			}<br /> 			return intersectColl;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns a collection made up of all items that are in either this collection or the specified collection (or both)<br /> 		 * @param	coll<br /> 		 * @return<br /> 		 */<br /> 		public function union(coll:Collection):Collection {<br /> 			var unionColl:Collection = new Collection();<br /> 			unionColl.addItem(itemList, coll);<br /> 			return unionColl;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns the union of this collection with an arbitrary number of other collections<br /> 		 * @param	... colls<br /> 		 * @return<br /> 		 */<br /> 		public function unionMany(... colls):Collection {<br /> 			var unionColl:Collection = new Collection();<br /> 			unionColl.addItem(_collection);<br /> 			for each (var subItem in colls) {<br /> 				if (subItem is Collection) {<br /> 					unionColl = unionColl.union(subItem);<br /> 				}<br /> 			}<br /> 			return unionColl;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns the relative complement of the specified collection in this collection<br /> 		 * A.relComp(B) := A\B<br /> 		 * @param	coll<br /> 		 * @return<br /> 		 */<br /> 		public function relComp(coll):Collection {<br /> 			///Returns the relative complement of the specified collection in this collection<br /> 			///A.relComp(B) := A\B<br /> 			///i.e. returns a collection containing items that are in this collection but not in the specified collection<br /> 			var rcColl:Collection = new Collection();<br /> 			rcColl.addItem(_collection);<br /> 			rcColl.removeItemAt(coll);<br /> 			return rcColl;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Returns the relative complement of the union of the specified collections in this collection<br /> 		 * @param	... colls<br /> 		 * @return<br /> 		 */<br /> 		public function relCompMany(... colls):Collection {<br /> 			var rcColl:Collection = new Collection();<br /> 			rcColl.addItem(_collection);<br /> 			for each (var subItem in colls) {<br /> 				if (subItem is Collection) {<br /> 					rcColl.removeItemAt(subItem);<br /> 				}<br /> 			}<br /> 			return rcColl;<br /> 		}<br /> <br /> 		/**<br /> 		 * Returns the number of items in the collection<br /> 		 */<br /> 		public function get numItems():uint {<br /> 			return _collection.length;<br /> 		}<br /> 		<br /> 		/**<br /> 		 * Exposes the underlying array; use this only for e.g. for-each loops<br /> 		 */<br /> 		public function get itemList():Array {<br /> 			return _collection;<br /> 		}<br /> 	}<br /> }<br /> [/code]<br /> <br /> This class is used instead of the Flex method Application.application.engineManager to reference the DocumentClass.<br /> <br /> <br /> ]]></description>
				<guid isPermaLink="true">http://forum.alternativaplatform.com/posts/preList/593/3082.page</guid>
				<link>http://forum.alternativaplatform.com/posts/preList/593/3082.page</link>
				<pubDate><![CDATA[Sat, 9 May 2009 08:14:03]]> GMT</pubDate>
				<author><![CDATA[ Doublezer0]]></author>
			</item>
	</channel>
</rss>
