Posts Tagged ‘ACTIONSCRIPT’

Wednesday, September 9th, 2009

Claus Wahlers has a great post on some lower level Flash handling for shapes.  He posts about a tool called as3swf which helps to look into the raw shapes and vector drawing calls in the flash engine.

The output of this tool gives the raw machine code/assembly like procedural output that is very similar to other rendering engines. It actually makes me think of OpenGL a bit in the output switch based, procedural flow except this if for vector drawing rather than raster.

Sample output

[83:DefineShape4] ID: 1
  FillStyles:
    [1] [SWFFillStyle] Type: 0 (solid), Color: 666666
  LineStyles:
    [1] [SWFLineStyle2] Width: 200, Color: ff0000
  ShapeRecords:
    [SWFShapeRecordStyleChange] MoveTo: 400,400, FillStyle1: 1, LineStyle: 1
    [SWFShapeRecordStraightEdge] Horizontal: 2000
    [SWFShapeRecordStraightEdge] Vertical: 2000
    [SWFShapeRecordStraightEdge] Horizontal: -2000
    [SWFShapeRecordStraightEdge] Vertical: -2000
    [SWFShapeRecordEnd]

It is always good to know what is going on in lower levels to better code for projects that perform well.  Another great post on this is the Elastic Racetrack of the AS3 and AVM2 virtual machine which describes how the AVM2 handles drawing those low level shape calls in addition to handling script.

Wednesday, July 8th, 2009

AIR is very popular for creating twitter clients, Sönke Rohde just made it much easier to make AIR apps for twitter with an AS3 library for Twitter. This library is built on top of core oauth as3 library by iotashin.  Core OAuth as3 library is a standard OAuth library this can be used for your own OAuth backends or connecting to other OAuth services as well.

A very nice feature of this library, in addition to being coded cleanly and as3 style, is the ability to have the Twitter OAuth page render inside of Flash.

Instead of opening the Twitter authorization page in the browser the library also contains OAuthLoader which is a wrapper around HTMLLoader which enables to directly show the authorization page within an AIR window:

// use this in the requestTokenHandler instead of navigateToURL
var loader:OAuthLoader = new OAuthLoader();
loader.load(request);
loader.percentWidth = 100;
loader.percentHeight = 100;
var w:Window = new Window();
w.width = 800;
w.height = 400;
w.title = req.url;
w.addChild(loader);
w.open();
Sunday, June 14th, 2009

Rozengain or Dennis Ippel of AKQA updated probably one of the tools I use the most for flash 3d and that is the blender to as3 exporter.  This simplifies loading in the meshes you have and lessens the bulk of the COLLADA format.  COLLADA is great but flash is still client side and fairly memory intensive for 3d so loading in models directly to as3 is nice if flash is your presentation tool.

AS3 Blender exporter has been updated to allow multiple object export. Also in April is was updated to export quads and modifiers.

One concern you might have is statically binding the code within a main swf fileon compile and resulting file size compared to loading in the DAE dynamically.  But you can just load these in as you would external DAE COLLADA files as compiled swfs and since it is just code it is very compact.   This adds some duplication of code (such as tweening libraries or the 3d engine source as needed) but allows a more horizontal loading or lazy loading of meshes when needed.

This is just another option to get 3D models into the flash 3d engine of your choice in addition to COLLADA, some MD2 support and limited ASE support.

This is an awesome project that keeps getting better, thanks Rozengain.

Friday, May 22nd, 2009

Flash 10 will be ready for mainstream hopefully by the end of this year, or early ’10 when the penetration numbers will be up in or around the 90% range via zeh fernando based on previous trajectories.  

With that, Flash 10 has many great new things such as the Vector structure that allows a collection of a certain type, which results in a faster collection because of the known type.  So anywhere where Arrays are used, that is a possible candidate for a performance increase within some code because you are asking the virtual machine to do less work on each loop (not having to dynamically find out the type).

ByteArray (Thibault Imbert) has demonstrated that for the JPEG encoding in corelib it is up to 2.5 times faster using Vectors than Arrays.  Your mileage may vary heavily but it is almost a guaranteed speed boost due to less work.  This obviously has great possibilities for speeding up code that uses lots of arrays.  

Due to the performance boost the Vector does have some constraints in the typical give and take of coder flexibility with compiler and virtual machine overhead.  Vectors are more explicit and strongly typed which is why they are fast, but this is also limiting.

In addition to the data type restriction, the Vector class has other restrictions that distinguish it from the Array class:

  • A Vector is a dense array. Unlike an Array, which may have values in indices 0 and 7 even if there are no values in positions 1 through 6, a Vector must have a value (or null) in each index.
  • A Vector can optionally be fixed-length, meaning the number of elements it contains can’t change.
  • Access to a Vector’s elements is bounds-checked. You can never read a value from an index greater than the final element (length - 1). You can never set a value with an index more than one beyond the current final index (in other words, you can only set a value at an existing index or at index [length]).

 [ Vector docs  ]

ByteArray not only used Vectors heavily but did other optimizations that are always good to do, even though optimization is evil when you are working with precious client side resources ensuring an optimized base starting point can be a good thing.

So what did I do ?

  • I used bitwise operators as much as possible.
  • I replaced all Arrays with fixed length Vectors.
  • I used pre-incrementation rather than post-incrementation (thanks Joa for this one ;)).
  • I casted to int all my Vector indices access.
  • Other minor stuff you always do to optimize your code 

Other sources as well for even more optimization or shall I say efficient AS3:

Monday, May 18th, 2009

pyamf is pretty sweet for Flash remoting with Pythonic server side, but now we have two nicely done and integrated remoting kits for python on the server side.

amfast is a new remoting library  that looks to be as sweet as pyamf (where sweet == fast and useful).  I am checking out amfast now but the speed boost alone might be worth it.  For instance, working with real-time games, when you need static content you need to grab that quickly sometimes via a content service.  The faster that link the better. It also has Twisted integration which is great for networking and SQLAlchemy integration which is in my opinion the best ORM for python (pyamf has twisted, django, pylons, sqlalchemy as well)

amfast is well documented and has some great examples.  If you have the Python addiction, check it.

Description

  • AmFast is a Flash remoting framework for Python.
  • AmFast can use AMF to communicate between Python and Flash, Flex, and any other system that supports AMF.
  • AMF is a binary object serialization protocol used by Actionscript based applications.

Server Features

  • Support for NetConnection and RemoteObject RPC.
  • Support for Producer/Consumer ‘push’ messaging with HTTP polling, HTTP long-polling, and real-time HTTP streaming channels.
  • Support for authentication with NetConnection and RemoteObject.
  • Flexible Target mapping system to map message destinations to invokable Target objects.
  • Support for ChannelSets with multiple Channels to expose resources in different ways.
  • Built in Channels for CherryPy, Twisted Web, and plain WSGI.
  • Support for configurable Endpoints. Use AmFast’s built-in AMF encoder/decoder C-extension, or use an external AMF encoder/decoder, such as PyAmf for a pure-Python implementation.

AMF Encoder/Decoder Features

  • AMF0/AMF3 encoder/decoder written in C as a Python extension for speed.
  • More than 10x faster than the PyAmf encoder/decoder (even when using PyAmf’s optional C-extension).
  • Map custom classes with ClassDef objects for complete control over serialization/de-serialization.
  • Full support for IExternalizable objects.
  • Data persistence with SqlAlchemy including remotely-loadable lazy-loaded attributes.
  • Actionscript code generation from ClassDef objects.
Tuesday, April 14th, 2009

JiglibFlash has been updated on a few fronts

Recently added include, you can now use RADIANS or DEGREES to manipulate objects in the engine, also adding standard yaw, pitch and roll methods.  

There is a mouse interaction now available with a MouseConstraint class to allow the user to drag a 3d element with the mouse which is great for gaming and interactive 3d physics scenes.

New class: MouseConstraint

There has been a new class to the Papervision3D plug-in called MouseConstraint and a new example to the Papervision3D examples folder. The class basically allows you to attach a world constraint to an object and simulate dragging.

The best update though is you can now use any of the major open source flash 3d engines as the renderer: Papervision 3D, Away3D or Sandy.

AS3 Flash 3D Physics Engines

Monday, March 16th, 2009

Libspark from Japan is a treasure trove of great flash advancements, they seem to realize the great things that can come from porting in existing solid libraries from C/C++ etc into flash and have been scoring lately including augmented reality in flash porting the ARToolkit to FLARToolkit.  Recently a port of openCV for as3 called Marilena was found and it is for object detection and decent facial recognition (it is a computer vision library from intel) considering the processing power needed to do this.

Face Detection: Here is the sample included with Marilena showing facial detection on an image.

marilena1

Lots of recent action has blown up on this front from Mr doob, quasimondo (optimizing the Marilena classes for better performance) and Boffwswana. Also there is a kit called deface by sshipman that is the first foray into this a year ago doing similar things but it was just a bit before it’s time and a bit slow in previous versions of flash, it performs decent now in this sample. Flash 10 performance of the AVM2 and future directions with Alchemy will lead to more interesting stuff just like this.

Mr. doob head tracking sample, be sure to check lots of other examples there

mrdoob_facedriven3d

Boffswana example of head tracking Johnny Lee Wii style with only a webcam and flash, no wiimote needed since it uses facial detection to check where you are and how close you are in the screen and then moves accordingly.

bofswana

This is stemming from the recent explosion of the FLARToolkit and augmented reality in flash as well as the gimmicks used by Nintendo with the wii and Johnny Lee’s great head tracking advancements. Porting great libraries to flash seems to be the phase we are entering now judging by the recent excitement around Adobe Alchemy and the LLVM along with the lead from the libspark.org contributors. We have also seen this heavily last year in ports of Box2D for 2d physics and other toolkits using established working code and porting that to flash now that is is mostly capable of handling the performance.

OpenCV (Open Computer Vision Library by Intel) is quite a powerful platform that allows you to do all this and now it is available in flash. There are other great libraries for nearly all platforms now. I have done some previous work with Aforge which is also a port of OpenCV mainly for motion detection. This was always around but not until the recent performance updates and the innovation that has come with Alchemy and the thinking that goes along with that (porting in libraries to flash from C/C++ etc), has allowed this to flourish in flash and thus the web.

The amazing new things we can do with flash by porting in existing libraries is only going to get more intense as alchemy and flash 10 are even more mainstream.  It is almost as if Flash will eventually just become a web renderer and simplified front end to many great toolkits that exist in more native environments like C/C++ but with the speed and distribution access of the web with Flash.  Exciting times ahead.

Friday, March 13th, 2009

Polygonal labs, maker of some of the best demos, information and tools for AS3 since inception updated the killer AS3 Data Structures for Game Developers and ported it to haXe.

Of course along the way making many improvements and showing great information on how and why the haXe version is faster which mainly boils down to a more strict virtual machine but flexible still with generics.

haXe is fast because it is a very highly optimized virtual machine language with compiler (and could be called a virtual machine to target other VMs similar to LLVM with the ability to target the Neko VM, AVM2 or Javascript, it is more than just a language) by Nicolas Cannasse that may one day overtake directly coding for the AVM2 or maybe we will even see haXe have more influence on flash soon for performance gains.  Some of the Alchemy LLVM virtual machine work is similar in nature to what haXe does and helps the language become an abstraction and translates into highly optimized code from very powerful and productive language syntax.

Anyways, I ramble, be sure to check out Data Structures for Game Developers by Polygonal Labs now ported for haXe as hx3ds if you are doing any sort of work in AS3 or haXe for AS3 it will be worth your while and provide a very common and useful data structures capabilities into your production that is highly optimized from one of the best AS3 developers.

As the name suggests, hx3ds is a port of as3ds for haXe and is now available at lib.haxe.org. hx3ds only supports the flash player 10 target, as it makes extensive use of the Vector class. If you need data structures that compile across all platforms, take a look at colhx instead.

Here’s a list of new features:

  • orders of magnitude faster
  • collections now support clone() and shuffle() operations
  • object pooling framework
  • revised graph, tree and linked list classes
  • memory manager for the virtual memory API (more on this soon)

The Structures Included

Multi-Dimensional Arrays

The library contains a two-dimensional and three-dimensional array. They are both implemented by a single linear array rather than nested arrays. This is the fastest method in flash to simulate multi-dimensional arrays and outperforms the nested array method because multiple array lookups are slower compared to one lookup combined with a simple arithmetic expression (which you can also often precompute in the outer loop). The most obvious application would be a tilemap in 2d or a layered tilemap in 3d.

Queue

This is also called a FIFO structure (First In – First Out). The queue comes in two variations, which have the same methods, but differ in their implementations: There is the arrayed queue, which obviously uses an array internally, and the linked queue, which is build upon a linked list. They are both very similar, except that the arrayed version has a fixed size and is faster.
A common application would be a command queue – imagine you have a unit in a strategy game and apply many commands which the unit should follow. All commands are enqueued and afterwards dequeued and processed in order.

Stack

Also commonly know as a FILO structure (First In – Last Out). Like the queue, this comes in two flavors: arrayed and linked. A stack is often not used directly, but a very important concept in programming. Please note, that a queue and a stack are not real structures, because they just define how data is accessed rather then stored.

Tree

A node-based structure. Every tree starts from a single node, called the root node. The root node can contain any number of child nodes, and every child node can again contain children. A tree node with no children is called a leaf node. In fact if you draw the nodes of a tree it looking like a real tree with branches. The AS3 display architecture is also a tree structure, so you could use this to manage your display objects and update them by traversing through the tree. Also, this is useful for decision trees, BVHs, storing a plot line or storing data recursively by applying the composite pattern.

Binary Tree

This is just a specialized kind of tree where each node is only allowed to have up to two children, called the left and right node. Binary trees are very often used for parsing input data, for example arithmetic expressions or when building a scripting system.

Binary Search Tree (BST) and Hash Table

Both structures store data that can be retrieved quickly by using a key. The method however differers greatly: The BST uses a recursive approach to split up large amounts of data into smaller sets. A hash table stores sparse key-based data using a hash-key in a small amount of space.

Linked Lists

A linked list is similar to an array. The main difference is that in an array, each cell contains just the data and is accessed by an index. A linked list consists of several node objects, which in addition to storing the data, manage a reference to the next node (singly linked) or to the next and previous node (doubly linked) in the list. Think of it as a more natural approach to work with sequential data.
Other benefits are that you can insert and remove data quickly by just calling the appropriate method on the node itself – you don’t have to manage array indexes. Also in AS3 object access is faster than array access, so it competes very well in terms of performance when iterating over the list.

Heap and Priority Queue

A Heap is a special kind of binary tree in which every node is bigger than its child nodes. Whatever you throw into a heap, it’s automatically sorted so the item with the ‘most significant’ value (depending on the comparison function) is always the front item. A priority queue is build upon the heap structure, and can manage prioritized data – which can be used in limitless ways.

Graph

A graph is a loose node-based structure. Nodes are connected with arcs, and every node can point to any other node. They can also point to each other creating a bi-directional connection. It is essential for path finding, AI, soft-body dynamics with mass-springs systems and a lot more.

Bit Vector

A bit vector is some kind of array in which you can store boolean values (true/false – 1/0) as close as possible without wasting memory. I currently can’t think of a reasonable application, because usually you should have enough memory – but it’s nice to have because it shows basic bit masking operations.

Monday, February 2nd, 2009

Don’t know how I missed this but just this last month a new site has launched called wonderfl that allows quick as3 compilation side by side that is encouraged by community and similar to a demo scene.

This could be great for generating new ideas much like machima and demo scenes have done in the past.  This stype of stuff goes down with the flash community anyways but being able to do it on a site and fork and evolve scripts and game it is a great idea.

Effects with filters, bitmaps, pixel manipulation, pixel bender and papervision would benefit greatly from the type of innovation that could happen here quickly in small doses. See what you can throw down, maybe some fireworks.

Friday, January 16th, 2009

I use a SoundManager class for games and interactives that require it which I picked up at evolve by Matt Przybylski.  But I sometimes need to use Tweener rather than TweenLite depending on what the project uses already. So here is the class updated with Tweener.  Just grab the latest Tweener to work with this.  Sound is one of those things like tweening, it is easier to reuse code if everyone uses common libraries.

package game.util
{
	import caurina.transitions.properties.SoundShortcuts;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundLoaderContext;
	import flash.media.SoundTransform;
	import flash.net.URLRequest;
	import flash.utils.Dictionary;
	import flash.utils.getQualifiedClassName;
	import caurina.transitions.*;
	/**
	 * The SoundManager is a singleton that allows you to have various ways to control sounds in your project.
	 *

	 * The SoundManager can load external or library sounds, pause/mute/stop/control volume for one or more sounds at a time,
	 * fade sounds up or down, and allows additional control to sounds not readily available through the default classes.
	 *

	 * This class is dependent on TweenLite (http://www.tweenlite.com) to aid in easily fading the volume of the sound.
	 *
	 * @author Matt Przybylski [http://www.reintroducing.com]
	 * @version 1.0
	 *
	 * @author Ryan Christensen (http://drawlogic.com)
	 * @version 1.1 - added Tweener support and removed TweenLite support
	 */
	public class SoundManager
	{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
		// singleton instance
		private static var _instance:SoundManager;
		private static var _allowInstance:Boolean;
		private var _soundsDict:Dictionary;
		private var _sounds:Array;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
		// singleton instance of SoundManager
		public static function getInstance():SoundManager
		{
			if (SoundManager._instance == null)
			{
				SoundManager._allowInstance = true;
				SoundManager._instance = new SoundManager();
				SoundManager._allowInstance = false;
			}
			return SoundManager._instance;
		}
		public function SoundManager()
		{
			this._soundsDict = new Dictionary(true);
			this._sounds = new Array();
			if (!SoundManager._allowInstance)
			{
				throw new Error("Error: Use SoundManager.getInstance() instead of the new keyword.");
			}
		}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
		/**
		 * Adds a sound from the library to the sounds dictionary for playing in the future.
		 *
		 * @param $linkageID The class name of the library symbol that was exported for AS
		 * @param $name The string identifier of the sound to be used when calling other methods on the sound
		 *
		 * @return Boolean A boolean value representing if the sound was added successfully
		 */
		public function addLibrarySound($linkageID:*, $name:String):Boolean
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				if (this._sounds[i].name == $name) return false;
			}
			var sndObj:Object = new Object();
			var snd:Sound = new $linkageID;
			sndObj.name = $name;
			sndObj.sound = snd;
			sndObj.channel = new SoundChannel();
			sndObj.position = 0;
			sndObj.paused = true;
			sndObj.volume = 1;
			sndObj.startTime = 0;
			sndObj.loops = 0;
			sndObj.pausedByAll = false;
			this._soundsDict[$name] = sndObj;
			this._sounds.push(sndObj);
			return true;
		}
		/**
		 * Adds an external sound to the sounds dictionary for playing in the future.
		 *
		 * @param $path A string representing the path where the sound is on the server
		 * @param $name The string identifier of the sound to be used when calling other methods on the sound
		 * @param $buffer The number, in milliseconds, to buffer the sound before you can play it (default: 1000)
		 * @param $checkPolicyFile A boolean that determines whether Flash Player should try to download a cross-domain policy file from the loaded sound's server before beginning to load the sound (default: false)
		 *
		 * @return Boolean A boolean value representing if the sound was added successfully
		 */
		public function addExternalSound($path:String, $name:String, $buffer:Number = 1000, $checkPolicyFile:Boolean = false):Boolean
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				if (this._sounds[i].name == $name) return false;
			}
			var sndObj:Object = new Object();
			var snd:Sound = new Sound(new URLRequest($path), new SoundLoaderContext($buffer, $checkPolicyFile));
			sndObj.name = $name;
			sndObj.sound = snd;
			sndObj.channel = new SoundChannel();
			sndObj.position = 0;
			sndObj.paused = true;
			sndObj.volume = 1;
			sndObj.startTime = 0;
			sndObj.loops = 0;
			sndObj.pausedByAll = false;
			this._soundsDict[$name] = sndObj;
			this._sounds.push(sndObj);
			return true;
		}


		/**
		 * Removes a sound from the sound dictionary.  After calling this, the sound will not be available until it is re-added.
		 *
		 * @param $name The string identifier of the sound to remove
		 *
		 * @return void
		 */
		public function removeSound($name:String):void
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				if (this._sounds[i].name == $name)
				{
					this._sounds[i] = null;
					this._sounds.splice(i, 1);
				}
			}
			delete this._soundsDict[$name];
		}
		/**
		 * Removes all sounds from the sound dictionary.
		 *
		 * @return void
		 */
		public function removeAllSounds():void
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				this._sounds[i] = null;
			}
			this._sounds = new Array();
			this._soundsDict = new Dictionary(true);
		}
		/**
		 * Plays or resumes a sound from the sound dictionary with the specified name.
		 *
		 * @param $name The string identifier of the sound to play
		 * @param $volume A number from 0 to 1 representing the volume at which to play the sound (default: 1)
		 * @param $startTime A number (in milliseconds) representing the time to start playing the sound at (default: 0)
		 * @param $loops An integer representing the number of times to loop the sound (default: 0)
		 *
		 * @return void
		 */
		public function playSound($name:String, $volume:Number = 1, $startTime:Number = 0, $loops:int = 0):void
		{
			var snd:Object = this._soundsDict[$name];
			snd.volume = $volume;
			snd.startTime = $startTime;
			snd.loops = $loops;
			if (snd.paused)
			{
				snd.channel = snd.sound.play(snd.position, snd.loops, new SoundTransform(snd.volume));
			}
			else
			{
				snd.channel = snd.sound.play($startTime, snd.loops, new SoundTransform(snd.volume));
			}
			snd.paused = false;
		}
		/**
		 * Stops the specified sound.
		 *
		 * @param $name The string identifier of the sound
		 *
		 * @return void
		 */
		public function stopSound($name:String):void
		{
			var snd:Object = this._soundsDict[$name];
			snd.paused = true;
			snd.channel.stop();
			snd.position = snd.channel.position;
		}
		/**
		 * Pauses the specified sound.
		 *
		 * @param $name The string identifier of the sound
		 *
		 * @return void
		 */
		public function pauseSound($name:String):void
		{
			var snd:Object = this._soundsDict[$name];
			snd.paused = true;
			snd.position = snd.channel.position;
			snd.channel.stop();
		}
		/**
		 * Plays all the sounds that are in the sound dictionary.
		 *
		 * @param $useCurrentlyPlayingOnly A boolean that only plays the sounds which were currently playing before a pauseAllSounds() or stopAllSounds() call (default: false)
		 *
		 * @return void
		 */
		public function playAllSounds($useCurrentlyPlayingOnly:Boolean = false):void
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				var id:String = this._sounds[i].name;
				if ($useCurrentlyPlayingOnly)
				{
					if (this._soundsDict[id].pausedByAll)
					{
						this._soundsDict[id].pausedByAll = false;
						this.playSound(id);
					}
				}
				else
				{
					this.playSound(id);
				}
			}
		}
		/**
		 * Stops all the sounds that are in the sound dictionary.
		 *
		 * @param $useCurrentlyPlayingOnly A boolean that only stops the sounds which are currently playing (default: true)
		 *
		 * @return void
		 */
		public function stopAllSounds($useCurrentlyPlayingOnly:Boolean = true):void
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				var id:String = this._sounds[i].name;
				if ($useCurrentlyPlayingOnly)
				{
					if (!this._soundsDict[id].paused)
					{
						this._soundsDict[id].pausedByAll = true;
						this.stopSound(id);
					}
				}
				else
				{
					this.stopSound(id);
				}
			}
		}
		/**
		 * Pauses all the sounds that are in the sound dictionary.
		 *
		 * @param $useCurrentlyPlayingOnly A boolean that only pauses the sounds which are currently playing (default: true)
		 *
		 * @return void
		 */
		public function pauseAllSounds($useCurrentlyPlayingOnly:Boolean = true):void
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				var id:String = this._sounds[i].name;
				if ($useCurrentlyPlayingOnly)
				{
					if (!this._soundsDict[id].paused)
					{
						this._soundsDict[id].pausedByAll = true;
						this.pauseSound(id);
					}
				}
				else
				{
					this.pauseSound(id);
				}
			}
		}
		/**
		 * Fades the sound to the specified volume over the specified amount of time.
		 *
		 * @param $name The string identifier of the sound
		 * @param $targVolume The target volume to fade to, between 0 and 1 (default: 0)
		 * @param $fadeLength The time to fade over, in seconds (default: 1)
		 *
		 * @return void
		 */
		public function fadeSound($name:String, $targVolume:Number = 0, $fadeLength:Number = 1):void
		{
			var fadeChannel:SoundChannel = this._soundsDict[$name].channel;
			SoundShortcuts.init();
			Tweener.addTween(fadeChannel, { _sound_volume: $targVolume, time: $fadeLength, transition:"linear" } );
			//TweenLite.to(fadeChannel, $fadeLength, {volume: $targVolume});
		}
		/**
		 * Mutes the volume for all sounds in the sound dictionary.
		 *
		 * @return void
		 */
		public function muteAllSounds():void
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				var id:String = this._sounds[i].name;
				this.setSoundVolume(id, 0);
			}
		}
		/**
		 * Resets the volume to their original setting for all sounds in the sound dictionary.
		 *
		 * @return void
		 */
		public function unmuteAllSounds():void
		{
			for (var i:int = 0; i < this._sounds.length; i++)
			{
				var id:String = this._sounds[i].name;
				var snd:Object = this._soundsDict[id];
				var curTransform:SoundTransform = snd.channel.soundTransform;
				curTransform.volume = snd.volume;
				snd.channel.soundTransform = curTransform;
			}
		}
		/**
		 * Sets the volume of the specified sound.
		 *
		 * @param $name The string identifier of the sound
		 * @param $volume The volume, between 0 and 1, to set the sound to
		 *
		 * @return void
		 */
		public function setSoundVolume($name:String, $volume:Number):void
		{
			var snd:Object = this._soundsDict[$name];
			var curTransform:SoundTransform = snd.channel.soundTransform;
			curTransform.volume = $volume;
			snd.channel.soundTransform = curTransform;
		}
		/**
		 * Gets the volume of the specified sound.
		 *
		 * @param $name The string identifier of the sound
		 *
		 * @return Number The current volume of the sound
		 */
		public function getSoundVolume($name:String):Number
		{
			return this._soundsDict[$name].channel.soundTransform.volume;
		}
		/**
		 * Gets the position of the specified sound.
		 *
		 * @param $name The string identifier of the sound
		 *
		 * @return Number The current position of the sound, in milliseconds
		 */
		public function getSoundPosition($name:String):Number
		{
			return this._soundsDict[$name].channel.position;
		}
		/**
		 * Gets the duration of the specified sound.
		 *
		 * @param $name The string identifier of the sound
		 *
		 * @return Number The length of the sound, in milliseconds
		 */
		public function getSoundDuration($name:String):Number
		{
			return this._soundsDict[$name].sound.length;
		}
		/**
		 * Gets the sound object of the specified sound.
		 *
		 * @param $name The string identifier of the sound
		 *
		 * @return Sound The sound object
		 */
		public function getSoundObject($name:String):Sound
		{
			return this._soundsDict[$name].sound;
		}
		/**
		 * Identifies if the sound is paused or not.
		 *
		 * @param $name The string identifier of the sound
		 *
		 * @return Boolean The boolean value of paused or not paused
		 */
		public function isSoundPaused($name:String):Boolean
		{
			return this._soundsDict[$name].paused;
		}
		/**
		 * Identifies if the sound was paused or stopped by calling the stopAllSounds() or pauseAllSounds() methods.
		 *
		 * @param $name The string identifier of the sound
		 *
		 * @return Number The boolean value of pausedByAll or not pausedByAll
		 */
		public function isSoundPausedByAll($name:String):Boolean
		{
			return this._soundsDict[$name].pausedByAll;
		}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
		public function get sounds():Array
		{
			return this._sounds;
		}
//- HELPERS -----------------------------------------------------------------------------------------------
		public function toString():String
		{
			return getQualifiedClassName(this);
		}
//- END CLASS ---------------------------------------------------------------------------------------------
	}
}