<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christophe Herreman &#187; Flash</title>
	<atom:link href="http://www.herrodius.com/blog/category/flash/feed" rel="self" type="application/rss+xml" />
	<link>http://www.herrodius.com/blog</link>
	<description>Thoughts from a software developer</description>
	<lastBuildDate>Thu, 10 Jun 2010 19:08:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spring ActionScript: Café Townsend sample application</title>
		<link>http://www.herrodius.com/blog/307</link>
		<comments>http://www.herrodius.com/blog/307#comments</comments>
		<pubDate>Sun, 07 Mar 2010 14:42:59 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Domain-Driven Design]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[Inversion of Control]]></category>
		<category><![CDATA[Spring ActionScript]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=307</guid>
		<description><![CDATA[A new Spring ActionScript sample application is now available. This is the Café Townsend application, originally created as a sample application for the Cairngorm framework, that we ported to Spring ActionScript. This should make it easier to compare this implementation with the implementations of some of the other frameworks.
Open the Café Townsend sample.
(Be sure to [...]]]></description>
			<content:encoded><![CDATA[<p>A new Spring ActionScript sample application is now available. This is the Café Townsend application, originally created as a sample application for the Cairngorm framework, that we ported to Spring ActionScript. This should make it easier to compare this implementation with the implementations of some of the other frameworks.</p>
<p><a href="http://www.herrodius.com/examples/cafe-townsend/" target="new">Open the Café Townsend sample.</a><br />
(Be sure to check the source by right-clicking and choosing "View Source" from the context menu, click <a href="http://www.herrodius.com/examples/cafe-townsend/srcview/index.html" target="new">here</a> to go to the source directly.)</p>
<p><a href="http://www.herrodius.com/examples/cafe-townsend/cafe-townsend.zip">Download the Flex/Flash Builder project and sources.</a></p>
<p><strong>Discussion</strong></p>
<p>In what follows, we will discuss the implementation details and motivate certain choices made in this design.</p>
<p><strong>Package Structure</strong></p>
<p>The first thing you might notice is the package structure, that might seem a bit odd at first since it is different from what most frameworks use or prescribe. This example follows the Layered Architecture, described by Eric Evans in the book <a href="https://www.amazon.com/dp/0321125215?tag=christherrem-20&#038;camp=0&#038;creative=0&#038;linkCode=as1&#038;creativeASIN=0321125215&#038;adid=1BZQW3KXDC2XEGJEWAYC&#038;">Domain-Driven Design: Tackling Complexity in the Heart of Software</a> (recommended reading). This architecture makes it easy to detect and apply the different layers of the application and forces us somewhat to have a clean separation of the responsibilities of each layer.</p>
<p>The layered architecture consists of four layers, as shown on the image below:</p>
<p><img src="http://www.herrodius.com/blog/wp-content/uploads/2010/03/LayeredArchitecture.png" alt="" title="LayeredArchitecture" width="320" height="293" class="aligncenter size-full wp-image-312" /></p>
<ul>
<li><strong>Presentation Layer</strong>: contains the user interface (the view component and in this example the presentation models)</li>
<li><strong>Application Layer</strong>: coordinates the application and forms a communication channel between the UI and the domain</li>
<li><strong>Domain Layer</strong>: the core of the software. This layer defines the entities and repositories/services that form the business logic of the application. For the most part only the interfaces for the services will be written here. This layer does not contain any implementation details.</li>
<li><strong>Infrastructure Layer</strong>: provides implementation details for all other layers. Concrete implementations of services will be put here.</li>
</ul>
<p>Note that it is certainly not needed to structure your application like this. Spring ActionScript does not impose or prescribe this structure, but we certainly think it is useful and wanted to introduce it in this example. Also note that while we have applied this architecture as packages in the same application, you might want to create different swc's or libraries for each of these layers so that they can easily be reused.</p>
<p><strong>Presentation Layer &#038; Presentation Models</strong></p>
<p>This example uses the Presentation Model (PM) as the main presentation pattern for the UI layer. The PM allows us to extract all state and controller logic for the view into a separate class that is view agnostic. A view component contains a reference to its corresponding PM and delegates all UI actions to it. The view component can either instantiate the PM directly, or it can be given one, either by a parent component or by having it "injected" by the Spring ActionScript framework. The process of automatically injecting properties into a (view) component is known as "Autowiring" in Spring ActionScript. Note that since the PM is not a UI component and does not know anything about the view, it can be easily unit tested.</p>
<p>An example of autowiring can be found in the EmployeeLogin.mxml class:</p>
<div class="igBar"><span id="lactionscript-5"><a href="#" onclick="javascript:showPlainTxt('actionscript-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-5">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Autowired<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> presentationModel:EmployeeLoginPresentationModel; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The PMs used in this example will either delegate directly to the business logic (for instance for loading the employees) or will delegate to the Application Layer (for instance for logging the user out of the application). Here again, there is no strict rule to follow, but you can decide for your own what approach seems the bests.</p>
<p>Note that autowiring is disabled by default. This is because in bigger applications, there might be a significant performance hit when autowiring is used. It is adviced to finetune the autowiring by configuring the autowire processor to include or exclude certain classes. To enable autowiring, simply add the following to the XML configuration:</p>
<div class="igBar"><span id="lxml-6"><a href="#" onclick="javascript:showPlainTxt('xml-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-6">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"autowiringStageProcessor"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"org.springextensions.actionscript.stage.DefaultAutowiringStageProcessor"</span><span style="font-weight: bold; color: black;">/&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Application Layer</strong></p>
<p>In some cases, the UI will delegate responsibilities to the Application Layer. Since the UI does not know about this layer, it needs a loosely coupled way of communicating with it. The communication channel that provides this capability in Spring ActionScript is the EventBus. It is implemented on top of Flash's event dispatching capability and forms a centralized medium for component and layer interaction.</p>
<p>In the example, the code behind the Logout button will dispatch an event via the EventBus. The application controller listens for this event and will handle it by invoking the logout method on the authentication service. Notice that the application controller takes the authentication service as a constructor argument and that the service is typed to the interface IAuthenticationService. The actual instance is provided in the (XML) configuration, were both the application controller and the authentication service and defined and linked to eachother.</p>
<p>Notice that the application controller does not explicitely listen for the logout event. Instead, it is sufficient to create a method and annotate it with the <strong>[EventHandler]</strong> metadata. Spring ActionScript will then introspect the controller, pick up all annotated methods and link them automatically with the event received from the EventBus.</p>
<p>Here's what the logout method looks like in the application controller:</p>
<div class="igBar"><span id="lactionscript-7"><a href="#" onclick="javascript:showPlainTxt('actionscript-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-7">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>EventHandler<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> logout<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">var</span> operation:IOperation = _authenticationService.<span style="color: #006600;">logout</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; operation.<span style="color: #006600;">addCompleteListener</span><span style="color: #66cc66;">&#40;</span>logout_completeHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Notice that the name of the logout method corresponds to the event being dispatched, namely "logout" (see the ApplicationEvents class for that). You can however also choose the name of this method as you like and specify the name of the event as an attribute of the EventHandler metadata.</p>
<p>As with autowiring, the processing of the EventHandler metadata is not enabled by default. If you want to use this in your application, simply add the following to the XML configuration:</p>
<div class="igBar"><span id="lxml-8"><a href="#" onclick="javascript:showPlainTxt('xml-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-8">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"eventHandlerProcessor"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"org.springextensions.actionscript.ioc.factory.config.EventHandlerMetaDataPostProcessor"</span><span style="font-weight: bold; color: black;">/&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>For more information on the EventBus, please refer to the <a href="http://www.springactionscript.org/docs/reference/html/the_eventbus.html">documentation</a>.</p>
<p><strong>Domain Layer</strong></p>
<p>The domain for this application is extremely simple. All it contains is an Employee entity and an employee service in the form of the IEmployeeService. Except for the actual entities of the domain, this layer does not contain any implementation details for the services it provides, but merely defines the interfaces for those services.</p>
<p><strong>Infrastructure Layer</strong></p>
<p>The infrastructure layer is where the technical details of the applications live. This layer provides the actual implementation of the services found in the other layers. Depending on the different contexts the application needs to be able to run in, you might provide different implementations of the services here. The implementations used in the application can then be defined the a Spring ActionScript Application Context. As an example, think of an application that needs to be able to connect to a set of services using Remote Objects in one scenario and needs to connect to a set of Webservices in another scenario. If we provide both implementations, we can easily reconfigure the application by changing the XML configuration of the application context.</p>
<p><strong>Application Context</strong></p>
<p>Once we have all components, we can bundle them together and prepare them to be used in the application. By doing this, we are configuring the <strong>context</strong> of the application. In Spring ActionScript this is done by instantiating a FlexXMLApplicationContext (in case you are working with Flex).</p>
<p>The application context in this example is configured using XML, but it could just as easily be configured using an MXML configuration. Both approaches have there pros and cons and you should decide what fits best for you project.</p>
<p>Looking at the Main.mxml class, which is the entry point of the application, we can see that a FlexXMLApplicationContext is instantiated and given the path to the external XML file (application-context.xml) that forms the application context's configuration. Now all we need to do is wait for the context to load before starting the application.</p>
<p><strong>Conclusion</strong></p>
<p>This example contains significantly less code than the original Cairngorm version. This is mainly because Spring ActionScript does not impose any strict architectural rules and provides the developer with plenty of choice for architecting things that best fit the application being developed. What might work in application A might not necessarily work well for application B or C. Being given so much freedom and choice might feel awkward at first, but you will notice that this is actual a good thing and you will benefit greatly from it.</p>
<p>If you have any remarks on this post, please leave them in comments or contact me. Whether they are errors, things that are unclear, or general questions... all feedback is welcome.</p>
<p>General information and document about Spring ActionScript can be found at <a href="http://www.springactionscript.org/">http://www.springactionscript.org/</a></p>
<p>Related articles:</p>
<ul>
<li><a href="http://www.herrodius.com/blog/284">The Operation API</a></li>
<li><a href="http://www.herrodius.com/blog/273">Spring ActionScript 1.0 RC1 Released</a></li>
<li><a href="http://www.herrodius.com/blog/255">Spring ActionScript Devoxx slides</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/307/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Spring ActionScript: The Operation API</title>
		<link>http://www.herrodius.com/blog/284</link>
		<comments>http://www.herrodius.com/blog/284#comments</comments>
		<pubDate>Thu, 04 Mar 2010 20:39:50 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Spring ActionScript]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=284</guid>
		<description><![CDATA[Introduction
As Flex and Flash developers, we are used to working with asynchronous code. Whenever we load data from a server for instance, we need to wait for the result to come back as we can't just read the result of such a call directly. The way in which we wait for these asynchronous calls to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>As Flex and Flash developers, we are used to working with asynchronous code. Whenever we load data from a server for instance, we need to wait for the result to come back as we can't just read the result of such a call directly. The way in which we wait for these asynchronous calls to complete differs from API to API. There are events, async tokens, callback functions, ... The fact that there is no unified approach to this, is a core problem in our opinion of Flash. It is not only confusing to developers, but it also prevents us from easily integrating these various techniques and abstracting away their details.</p>
<p>Consider a service that manages User objects by providing basic operations on these entities like create, read, update and delete (CRUD). If you plan on creating an interface for this user service so you can vary the implementation easily, what return type would the methods have?</p>
<div class="igBar"><span id="lactionscript-17"><a href="#" onclick="javascript:showPlainTxt('actionscript-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-17">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IUserService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">function</span> addUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>: ? ;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">function</span> deleteUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>: ? ;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">function</span> saveUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>: ? ;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">function</span> loadAllUsers<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>: ? ;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>We could either:</p>
<ul>
<li>return nothing and wait for events to be dispatched by the service when its methods have executed: this has the disadvantage that there is no real contract on the method.</li>
<li>return nothing and pass in a Responder or result and fault handler callback functions: this has the disadvantage that it blurs the signature of the service method with technical details.</li>
<li>return an AsyncToken: this is a stricter contract, but it would tie our code to the Flex framework and it would only work if you create implementations that support AsyncToken</li>
</ul>
<p>In general, the biggest problem is that there is no standard way of defining an asynchronous execution in the Flash Player.</p>
<p><strong>Operation API</strong></p>
<p>The solution Spring ActionScript provides comes in the form of the Operation API. This is a set of interfaces and classes that enables developers to work with asynchronous processes in a uniform fashion. An "operation" in Spring ActionScript vocabulary is the term used for an asynchronous execution and is defined by the IOperation interface. Once an operation is created, it executes immediately and when it is done executing, it either dispatches a "complete" event or an "error" event.</p>
<p>Going back to our user service, this means that we would type all return types of its (asynchronous) methods to IOperation:</p>
<div class="igBar"><span id="lactionscript-18"><a href="#" onclick="javascript:showPlainTxt('actionscript-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-18">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IUserService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">function</span> addUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>:IOperation;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">function</span> deleteUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>:IOperation;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">function</span> saveUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>:IOperation;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">function</span> loadAllUsers<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:IOperation;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Whether you now have an implementation that uses Remote Objects, Webservices, locally loaded XML data, a local SQLite database, ... clients working with the user service should not know and care about implementation details. All that they know is that asynchronous methods return an operation to which they can attach listeners to for dealing with the result or error of the call.</p>
<p>A client calling one of these methods might to something like the following, considering there is a userService of type IUserService:</p>
<div class="igBar"><span id="lactionscript-19"><a href="#" onclick="javascript:showPlainTxt('actionscript-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-19">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> user:User = <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"John"</span>, <span style="color: #ff0000;">"Doe"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> operation:IOperation = userService.<span style="color: #006600;">saveUser</span><span style="color: #66cc66;">&#40;</span>user<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">operation.<span style="color: #006600;">addCompleteListener</span><span style="color: #66cc66;">&#40;</span>saveUser_completeHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">operation.<span style="color: #006600;">addErrorListener</span><span style="color: #66cc66;">&#40;</span>saveUser_errorHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> saveUser_completeHandler<span style="color: #66cc66;">&#40;</span>event:OperationEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;">// user was saved</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;">// event.result contains an optional result of the asynchronous method</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> saveUser_errorHandler<span style="color: #66cc66;">&#40;</span>event:OperationEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;">// user was not saved, since an error occurred</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;">// event.error contains error information</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Notice that each operation has the convenience methods "addCompleteListener" and "addErrorListener" for listening to the events dispatched by the operation. The handlers for these events receive an instance of the OperationEvent which contains either the result or the error details.</p>
<p>We have also included some base classes that make it easy to create operations and services. The AbstractOperation class for instance provides a basic implementation of the IOperation interface and implements the event dispatching functionality. You might want to extend this class if you create your own operations.</p>
<p>Here's an example of a custom operation:</p>
<div class="igBar"><span id="lactionscript-20"><a href="#" onclick="javascript:showPlainTxt('actionscript-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-20">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyOperation <span style="color: #0066CC;">extends</span> AbstractOperation <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MyOperation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// execute something asynchronously</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// the resultHandler and errorHandler deal with the result of fault</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> resultHandler<span style="color: #66cc66;">&#40;</span>aResult:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dispatchCompleteEvent<span style="color: #66cc66;">&#40;</span>aResult<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> errorHandler<span style="color: #66cc66;">&#40;</span>anError:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dispatchErrorEvent<span style="color: #66cc66;">&#40;</span>anError<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Notice that we call the "dispatchCompleteEvent" and "dispatchErrorEvent" on either success or failure. We pass in the result or the error we received. These will internally be set on the operation so that clients can request them via the OperationEvent.</p>
<p>The Spring ActionScript framework also contains a series of operation implementations for working with Remote Objects, NetConnections, etc.</p>
<p><strong>Combining Operations into Services</strong></p>
<p>Taking this a step further, we also provide base classes for creating services that consist of operations. Going back to our user service, we might create an implementation that uses RemoteObject by subclassing the RemoteObjectService class. This class provides basic functionality for delegating to the underlying Remote Object. Here's an example:</p>
<div class="igBar"><span id="lactionscript-21"><a href="#" onclick="javascript:showPlainTxt('actionscript-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-21">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserService <span style="color: #0066CC;">extends</span> RemoteObjectService <span style="color: #0066CC;">implements</span> IUserService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> UserService<span style="color: #66cc66;">&#40;</span>remoteObject:RemoteObject<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span>remoteObject<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>:IOperation <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"addUser"</span>, user<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> deleteUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>:IOperation <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"deleteUser"</span>, user<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> saveUser<span style="color: #66cc66;">&#40;</span>user:User<span style="color: #66cc66;">&#41;</span>:IOperation <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"saveUser"</span>, user<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadAllUsers<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:IOperation <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"loadAllUsers"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Notice how easy it is to abstract away the use of a remote object and make clients unaware of this by only providing them with the IUserService interface. The "call" method is a very convenient method to forward the call to the remote object, without having to take care of AsyncTokens and Reponders.</p>
<p><strong>Progress Operations</strong></p>
<p>For operations that take longer to execute the IOperation interface has a subinterface called IProgressOperation. This might for instance be the loading of a sound file, a module, etc. Implementations of this interface can let clients know about the progress the operation made by dispatching progress events at certain intervals. When listening for these events, via the "addProgressListener" method, a ProgressOperationEvent is received that contains a "progress" and "total" property.</p>
<div class="igBar"><span id="lactionscript-22"><a href="#" onclick="javascript:showPlainTxt('actionscript-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-22">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> loadSoundOperation:IProgressOperation = <span style="color: #000000; font-weight: bold;">new</span> MyLoadSoundOperation<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"aSoundFile.mp3"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">loadSoundOperation.<span style="color: #006600;">addProgressListener</span><span style="color: #66cc66;">&#40;</span>loadSoundOperation_progressHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> loadSoundOperation_progressHandler<span style="color: #66cc66;">&#40;</span>event:ProgressOperationEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Loaded "</span> + event.<span style="color: #006600;">progress</span> + <span style="color: #ff0000;">" of "</span> + event.<span style="color: #006600;">total</span> + <span style="color: #ff0000;">" bytes"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Batch Operations</strong></p>
<p>When you are in a scenario where you need to execute several operations and you don't care about the order in which they finish, you might want to use the OperationQueue class. This is an implementation of the IProgressOperation interface that lets you add operations to a queue and receive information about the progress of the complete execution. Since this also is an IOperation, we can listen to the completion of the queue via the "addCompleteListener" method.</p>
<div class="igBar"><span id="lactionscript-23"><a href="#" onclick="javascript:showPlainTxt('actionscript-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-23">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> queue:OperationQueue = <span style="color: #000000; font-weight: bold;">new</span> OperationQueue<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// setup event listeners</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">queue.<span style="color: #006600;">addCompleteListener</span><span style="color: #66cc66;">&#40;</span>queue_completeHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">queue.<span style="color: #006600;">addProgressListener</span><span style="color: #66cc66;">&#40;</span>queue_progressHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// add operations to the queue</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">queue.<span style="color: #006600;">addOperation</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AnOperation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">queue.<span style="color: #006600;">addOperation</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AnotherOperation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">queue.<span style="color: #006600;">addOperation</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> YetAnotherOperation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> queue_completeHandler<span style="color: #66cc66;">&#40;</span>event:OperationEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Queue is done executing."</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> queue_progressHandler<span style="color: #66cc66;">&#40;</span>event:ProgressOperationEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Executed "</span> + event.<span style="color: #006600;">progress</span> + <span style="color: #ff0000;">" of "</span> + event.<span style="color: #006600;">total</span> + <span style="color: #ff0000;">" operations"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Mocking Operations</strong></p>
<p>During development it is often good to have mock or stub implementations of the services that normally connect to a backend. The main reason is that this provides a way of (unit) testing the use of the services without the backend running. Spring ActionScript provides a class called MockOperation for this purpose. Its constructor takes the following arguments:</p>
<ul>
<li>result: the result returned by the operation</li>
<li>delay (optional): the time the operations waits before completing, in milliseconds (default = 1000)</li>
<li>returnError (optional): a flag indicating wether or not the operation should return an error at random times (default = false)</li>
</ul>
<p>If you would mock the user service, you could do this as follows (only one method is implemented):</p>
<div class="igBar"><span id="lactionscript-24"><a href="#" onclick="javascript:showPlainTxt('actionscript-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-24">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadAllUsers<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:IOperation <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">var</span> users:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> TypedCollection<span style="color: #66cc66;">&#40;</span>User<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; users.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"John"</span>, <span style="color: #ff0000;">"Doe"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; users.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Mitch"</span>, <span style="color: #ff0000;">"Hedberg"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> MockOperation<span style="color: #66cc66;">&#40;</span>users<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Conclusion</strong></p>
<p>The Operation API provides a neat way of abstracting away technical details and makes it easier to swap implementations without affecting any code. It unifies asynchronous programming for the Flash Player into a simple set of interfaces and base classes. You will also see that it is the basis for other APIs in the Spring ActionScript framework such as the Command and Task API.</p>
<p>For more information on Spring ActionScript, refer to <a href="http://www.springactionscript.org">www.springactionscript.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/284/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PNGSizeExtractor</title>
		<link>http://www.herrodius.com/blog/265</link>
		<comments>http://www.herrodius.com/blog/265#comments</comments>
		<pubDate>Fri, 12 Feb 2010 21:07:58 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=265</guid>
		<description><![CDATA[I was trying to read the dimensions of some very large image files today when I bumped into the Flash Player 10 limitations regarding maximum image sizes. (More info about this is available here.) Since an image file that is too big will not be shown correctly, there is no use in uploading and using [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to read the dimensions of some very large image files today when I bumped into the Flash Player 10 limitations regarding maximum image sizes. (More info about this is available <a href="http://kb2.adobe.com/cps/496/cpsid_49662.html">here</a>.) Since an image file that is too big will not be shown correctly, there is no use in uploading and using it. I wanted to provide detailed feedback about the image dimensions and how they exceeded the allowed sizes, but that was not possible unfortunately since the width and height properties of the loaded image would remain 0. (I posted a question on StackOverflow about this issue <a href="http://stackoverflow.com/questions/2252693/get-dimension-of-locally-loaded-large-image">here</a>.)</p>
<p>The <a href="http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/">JPGSizeExtractor</a> class by Antti Kupila enables you to read the width and height of a JPG by reading the image's bytecode. Since we also need to support PNG files, I thought I'd create a simple PNGSizeExtractor myself.</p>
<p>Here's the code:</p>
<div class="igBar"><span id="lactionscript-28"><a href="#" onclick="javascript:showPlainTxt('actionscript-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-28">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">herrodius</span>.<span style="color: #006600;">utils</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp;&nbsp; * Reads the width and height from a PNG image.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp;&nbsp; *</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp;&nbsp; * http://en.wikipedia.org/wiki/Portable_Network_Graphics</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp;&nbsp; * http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp;&nbsp; *</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp;&nbsp; * @author Christophe Herreman</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PNGSizeExtractor <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const SIGNATURE_BYTES:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span>0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A<span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const CHUNK_TYPE_SIZE:uint = <span style="color: #cc66cc;color:#800000;">4</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Constructor</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> PNGSizeExtractor<span style="color: #66cc66;">&#40;</span>byteArray:ByteArray<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; decode<span style="color: #66cc66;">&#40;</span>byteArray<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Public Properties</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ----------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// width</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ----------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">_width</span>:uint;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">width</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">_width</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ----------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// height</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ----------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">_height</span>:uint;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">_height</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Private Methods</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> decode<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:ByteArray<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; readSignature<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; readIHDR<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> readSignature<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:ByteArray<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:uint = <span style="color: #cc66cc;color:#800000;">0</span>; i&lt;SIGNATURE_BYTES.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>.<span style="color: #006600;">readUnsignedByte</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> != SIGNATURE_BYTES<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"File is not a PNG file."</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> readIHDR<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:ByteArray<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">size</span>:uint = <span style="color: #0066CC;">data</span>.<span style="color: #006600;">readUnsignedInt</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">data</span>.<span style="color: #006600;">readUTFBytes</span><span style="color: #66cc66;">&#40;</span>CHUNK_TYPE_SIZE<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_width</span> = <span style="color: #0066CC;">data</span>.<span style="color: #006600;">readUnsignedInt</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_height</span> = <span style="color: #0066CC;">data</span>.<span style="color: #006600;">readUnsignedInt</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And here's how to use it. (byteArray is the data of the loaded PNG):</p>
<div class="igBar"><span id="lactionscript-29"><a href="#" onclick="javascript:showPlainTxt('actionscript-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-29">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> pngDecoder:PNGSizeExtractor = <span style="color: #000000; font-weight: bold;">new</span> PNGSizeExtractor<span style="color: #66cc66;">&#40;</span>byteArray<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>pngDecoder.<span style="color: #0066CC;">width</span>, pngDecoder.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And here is a small sample application that loads the file locally:</p>
<div class="igBar"><span id="lactionscript-30"><a href="#" onclick="javascript:showPlainTxt('actionscript-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-30">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">"1.0"</span>?&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Application xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> horizontalAlign=<span style="color: #ff0000;">"left"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Script&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">herrodius</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">PNGSizeExtractor</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fileReference:FileReference;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> browseButton_clickHandler<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;_fileReference = <span style="color: #000000; font-weight: bold;">new</span> FileReference<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;_fileReference.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">SELECT</span>, fileReference_selectHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;_fileReference.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, fileReference_completeHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;_fileReference.<span style="color: #006600;">browse</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> fileReference_selectHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;_fileReference.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> fileReference_completeHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fileNameTextInput.<span style="color: #0066CC;">text</span> = _fileReference.<span style="color: #0066CC;">name</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> pngDecoder:PNGSizeExtractor = <span style="color: #000000; font-weight: bold;">new</span> PNGSizeExtractor<span style="color: #66cc66;">&#40;</span>_fileReference.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textArea.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"Width: "</span> + pngDecoder.<span style="color: #0066CC;">width</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textArea.<span style="color: #0066CC;">text</span> += <span style="color: #ff0000;">"Height: "</span> + pngDecoder.<span style="color: #0066CC;">height</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #0066CC;">catch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:<span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">message</span>, <span style="color: #ff0000;">"Error decoding image"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:Script&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Browse for a PNG file."</span> fontWeight=<span style="color: #ff0000;">"bold"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:HBox <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextInput id=<span style="color: #ff0000;">"fileNameTextInput"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> editable=<span style="color: #ff0000;">"false"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"browseButton"</span> label=<span style="color: #ff0000;">"..."</span> click=<span style="color: #ff0000;">"browseButton_clickHandler(event)"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextArea id=<span style="color: #ff0000;">"textArea"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100%"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:Application&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/265/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring ActionScript 0.8.1 Released</title>
		<link>http://www.herrodius.com/blog/208</link>
		<comments>http://www.herrodius.com/blog/208#comments</comments>
		<pubDate>Tue, 15 Sep 2009 20:02:27 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Spring ActionScript]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=208</guid>
		<description><![CDATA[Dear Community,
I'm pleased to announce that the Spring ActionScript 0.8.1 release is now available.
Download&#160;&#124;&#160;API Documentation&#160;&#124;&#160;HTML Docs&#160;&#124;&#160;PDF Docs&#160;&#124;&#160;Changelog
This release includes the Spring ActionScript framework, the Cairngorm extensions and the PureMVC extensions and is mainly a bugfix release based on user feedback, for which we are very grateful.
Besides a series of bugfixes, we have also refactored the [...]]]></description>
			<content:encoded><![CDATA[<p>Dear Community,</p>
<p>I'm pleased to announce that the Spring ActionScript 0.8.1 release is now available.</p>
<p align='center'><a href="http://www.springactionscript.org/downloads/spring-actionscript-0.8.1-distribution-with-dependencies.zip">Download</a>&nbsp;|&nbsp;<a href="http://www.springactionscript.org/asdoc/index.html">API Documentation</a>&nbsp;|&nbsp;<a href="http://www.springactionscript.org/docs/reference/html/springactionscript.html">HTML Docs</a>&nbsp;|&nbsp;<a href="http://www.springactionscript.org/docs/reference/pdf/springactionscript.pdf">PDF Docs</a>&nbsp;|&nbsp;<a href="http://www.springactionscript.org/changes-report.html">Changelog</a></p>
<p>This release includes the Spring ActionScript framework, the Cairngorm extensions and the PureMVC extensions and is mainly a bugfix release based on user feedback, for which we are very grateful.</p>
<p>Besides a series of bugfixes, we have also refactored the stage wiring system a bit so it now enables you to extend it with custom functionality. Two proof-of-concept implementations were added, namely the <a href="http://www.springactionscript.org/docs/reference/html/container-documentation.html#the_localizationstageprocessor_class">LocalizationStageProcessor</a> and the <a href="http://www.springactionscript.org/docs/reference/html/container-documentation.html#the_simplesecuritystageprocessor_class">SimpleSecurityStageProcessor</a>.</p>
<p><strong>LocalizationStageProcessor</strong></p>
<p>This first processor enables you to assign resource values to components that are added to the stage, thus removing the need to add binding code for components at design-time. The values are assigned on a simple 'configuration-by-name' basis: a resource string in the form 'myButton_label=Click me' will assign the value 'Click me' to the label property of a stage component with the id 'myButton'.</p>
<p>There's a small <a href="https://src.springframework.org/svn/se-springactionscript-as/trunk/spring-actionscript-core/samples/localization/src/">sample app</a> as well showcasing the localization processor.</p>
<p><strong>SimpleSecurityStageProcessor</strong></p>
<p>The second processor is slightly more elaborate and offers runtime security/authorization functionality.</p>
<p>There's also a small <a href="https://src.springframework.org/svn/se-springactionscript-as/trunk/spring-actionscript-core/samples/security/src/">sample application</a> for this processor.</p>
<p>Basically what this processor does is create an ISecurityManager instance for a given component that is added to the stage. (Whether or not this creation will be considered is determined by the approval result of an IObjectSelector). This ISecurityManager holds a list of role and right names that are applicable for the specified stage component and is able to block access to the component after evaluation of these security rules.</p>
<p>The way to block access is determined by the AccessStrategy enum, that is part of the SimpleStageSecurityManager implementation of the ISecurityManager. It can set the enabled property to false, or visible to false, etc. The implementation of these security interfaces is SIMPLE, hence the names. For now, we didn't want to include a very elaborate implementation since security can vary very widely from application to application. These interfaces are really meant as a 'roll-your-own' package, Spring ActionScript just offers the infrastructure in this case.</p>
<p><strong>Last Words</strong></p>
<p>Although this is a minor release, we would recommend all users to upgrade.</p>
<p>Further, we are always looking for user feedback and input. Be it bug reports, patches, new ideas, etc, all help is welcome. If you think you can contribute to the project in whatever way, don't hesitate to leave something in the comments or mail me at christophe [DOT] herreman [AT] gmail [DOT] com.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/208/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Spring ActionScript 0.8 Released</title>
		<link>http://www.herrodius.com/blog/176</link>
		<comments>http://www.herrodius.com/blog/176#comments</comments>
		<pubDate>Fri, 17 Jul 2009 16:20:56 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Spring ActionScript]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=176</guid>
		<description><![CDATA[Dear Community,
I'm pleased to announce that the Spring ActionScript 0.8 release is now available.
Download&#160;&#124;&#160;API Documentation&#160;&#124;&#160;HTML Docs&#160;&#124;&#160;PDF Docs&#160;&#124;&#160;Changelog
This release includes the Spring ActionScript framework, the Cairngorm extensions and the PureMVC extensions.
All libraries are available for download at the following Maven repository: http://projects.yoolab.org/maven/content/repositories/
From now on, we will regularly publish new snapshots of the libraries there.
Direct links to [...]]]></description>
			<content:encoded><![CDATA[<p>Dear Community,</p>
<p>I'm pleased to announce that the Spring ActionScript 0.8 release is now available.</p>
<p align='center'><a href="http://projects.yoolab.org/maven/content/repositories/releases/org/springextensions/actionscript/spring-actionscript-core/0.8/spring-actionscript-core-0.8.swc">Download</a>&nbsp;|&nbsp;<a href="http://www.springactionscript.org/asdoc/index.html">API Documentation</a>&nbsp;|&nbsp;<a href="http://www.springactionscript.org/docs/reference/html/springactionscript.html">HTML Docs</a>&nbsp;|&nbsp;<a href="http://www.springactionscript.org/docs/reference/pdf/springactionscript.pdf">PDF Docs</a>&nbsp;|&nbsp;<a href="http://www.pranaframework.org/docs/0.8/changelog.txt">Changelog</a></p>
<p>This release includes the Spring ActionScript framework, the Cairngorm extensions and the PureMVC extensions.</p>
<p>All libraries are available for download at the following Maven repository: <a href="http://projects.yoolab.org/maven/content/repositories/">http://projects.yoolab.org/maven/content/repositories/</a></p>
<p>From now on, we will regularly publish new snapshots of the libraries there.</p>
<p>Direct links to the libraries:<br />
- <a href="http://projects.yoolab.org/maven/content/repositories/releases/org/springextensions/actionscript/spring-actionscript-core/0.8/spring-actionscript-core-0.8.swc">Spring ActionScript 0.8</a><br />
- <a href="http://projects.yoolab.org/maven/content/repositories/releases/org/springextensions/actionscript/spring-actionscript-cairngorm/0.8/spring-actionscript-cairngorm-0.8.swc">Spring ActionScript Cairngorm 0.8</a><br />
- <a href="http://projects.yoolab.org/maven/content/repositories/releases/org/springextensions/actionscript/spring-actionscript-puremvc-standard/0.8/spring-actionscript-puremvc-standard-0.8.swc">Spring ActionScript PureMVC 0.8</a></p>
<p>Dependencies:<br />
- <a href="http://projects.yoolab.org/maven/content/repositories/snapshots/org/as3commons/as3commons-lang/1.0.0-SNAPSHOT/as3commons-lang-1.0.0-20090716.151324-14.swc">AS3Commons Lang</a><br />
- <a href="http://projects.yoolab.org/maven/content/repositories/releases/org/as3commons/as3commons-logging/1.0.0/as3commons-logging-1.0.0.swc">AS3Commons Logging</a><br />
- <a href="http://projects.yoolab.org/maven/content/repositories/releases/org/as3commons/as3commons-reflect/1.0.0/as3commons-reflect-1.0.0.swc">AS3Commons Reflect</a></p>
<p><em>Note: AS3Commons Lang is a snapshot of 1.0. We will work with a release for the following releases of Spring ActionScript</em></p>
<p>Besides a series of bugfixes, optimizations and improvements, some of the major changes and enhancements include:</p>
<p><strong>Autowiring support</strong></p>
<p>Using autowiring allows you to inject objects managed by the container into view components and other objects. To autowire a property, annotate it with the [Autowired] metadata tag. The support we build in is pretty enhanced and allows you to customize the autowire behavior in many different ways. Within the Autowired metadata tag you can specify the object name and you can also configure the container to filter autowire candidates using your own filter specifications. Please see the <a href="http://www.springactionscript.org/docs/reference/html/container-documentation.html#autowiring_objects">documentation on autowiring</a> for more info.</p>
<p><strong>Custom Namespaces</strong></p>
<p>The XML configuration now supports namespaces and allows you to create custom namespaces yourself. A few namespaces have been added to simplify the configuration of common objects for RMI and Messaging. More info on <a href="http://www.springactionscript.org/docs/reference/html/xml-schema-based-configuration.html">available namespaces and schemas</a> and <a href="http://www.springactionscript.org/docs/reference/html/extensible_xml_authoring.html">creating custom ones</a> can be found in the documentation. The XSD schemas are available <a href="http://www.springactionscript.org/schema/">http://www.springactionscript.org/schema/</a></p>
<p><strong>MXML Configuration</strong></p>
<p>We now also support configuration through MXML. The markup is very similar to the regular XML config, but with some slight differences. Please see the documentation on <a href="http://www.springactionscript.org/docs/reference/html/container-documentation.html#composing_mxml_based_configuration_metadata">MXML Configuration</a></p>
<p><strong>AS3Commons</strong></p>
<p>As a side project, we have started the <a href="http://www.as3commons.org">AS3Commons</a> project that offers reusable ActionScript 3.0 libraries. Most of the libraries currently available in AS3Commons are build using code from the Spring ActionScript framework. This means that a lot of code has been removed from Spring ActionScript and is now available for use in projects not using Spring ActionScript. Please note that you might have to update quite some import statements to refer to AS3Commons instead of Spring ActionScript. We apologize for any inconvenience this might cause, but this is only a one-time process.</p>
<p>We hope you find the AS3Commons libraries useful. All libraries (releases and snapshots) can also be found at the <a href="https://dev.yoolab.org/maven/content/repositories/">Maven repository</a>.</p>
<p><strong>Documentation</strong></p>
<p>The documentation has been tremendously improved in this version. Next to the <a href="http://www.springactionscript.org/asdoc/index.html">API documentation</a>, we now provide a reference guide in <a href="http://www.springactionscript.org/docs/reference/html/springactionscript.html">HTML</a> and <a href="http://www.springactionscript.org/docs/reference/pdf/springactionscript.pdf">PDF</a> format. General info can be found at the project website: <a href="http://www.springactionscript.org">www.springactionscript.org</a></p>
<p><strong>Last Words</strong></p>
<p>If you feel like helping us out, we could certainly use your help. This project is entirely created on a volunteer basis and in our spare (and limited) free time so needless to say that the more people, the faster we can deliver new releases and guarantee the quality of the framework. So if you think you have someting to offer, be it as a developer, tester, documentation writer, sample creator, ... please contact me (christophe [DOT] herreman [AT] gmail [DOT] com) or leave something in the comments. All help is more than welcome.</p>
<p>Enjoy this release and have fun coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/176/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Spring ActionScript: site and documentation update</title>
		<link>http://www.herrodius.com/blog/164</link>
		<comments>http://www.herrodius.com/blog/164#comments</comments>
		<pubDate>Tue, 02 Jun 2009 08:00:23 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Inversion of Control]]></category>
		<category><![CDATA[Spring ActionScript]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/164</guid>
		<description><![CDATA[Some quick news about the status of the project.
The Spring ActionScript project has a new home at http://www.springactionscript.org!
We have been updating the documentation extensively and although this is still a work in progress, this should be a valuable resource to get started with the framework. Please see the "Documentation" section for more info and available [...]]]></description>
			<content:encoded><![CDATA[<p>Some quick news about the status of the project.</p>
<p>The Spring ActionScript project has a new home at <a href="http://www.springactionscript.org">http://www.springactionscript.org</a>!</p>
<p>We have been updating the documentation extensively and although this is still a work in progress, this should be a valuable resource to get started with the framework. Please see the "Documentation" section for more info and available doc formats.</p>
<p>There are also some neat new features like advanced autowiring and support for custom XML namespaces (available in SVN) that will be distributed with the new 0.8 release, expected to be released by the end of this week.</p>
<p>As usual, we appreciate any feedback. Join our <a href="http://groups.google.com/group/springactionscript-dev">Google developers group</a> or the <a href="http://forum.springsource.org/forumdisplay.php?f=60">forum</a>.</p>
<p>Have fun coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/164/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Introducing the AS3Commons project</title>
		<link>http://www.herrodius.com/blog/163</link>
		<comments>http://www.herrodius.com/blog/163#comments</comments>
		<pubDate>Mon, 01 Jun 2009 08:30:52 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[AS3Commons]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/163</guid>
		<description><![CDATA[While working on the Spring ActionScript framework, we wrote a lot of code that could perfectly be used outside of the framework. That's why we decided to start the AS3Commons project, based on idea of the Apache Commons project, and provide a set of core libraries useful to every ActionScript 3.0 developer.
This announcement is also [...]]]></description>
			<content:encoded><![CDATA[<p>While working on the <a href="http://www.springactionscript.org">Spring ActionScript</a> framework, we wrote a lot of code that could perfectly be used outside of the framework. That's why we decided to start the AS3Commons project, based on idea of the Apache Commons project, and provide a set of core libraries useful to every ActionScript 3.0 developer.</p>
<p>This announcement is also the immediate release of 2 of the libraries included:</p>
<ul>
<li>AS3Commons-Reflect: a reflection library</li>
<li>AS3Commons-Logging: an abstraction layer over logging frameworks</li>
</ul>
<p><em>Note: we realize there is another as3commons library out there. However this library is no longer being maintained and developed as confirmed by the author. We apologize in advance for the confusion this might cause. We are currently looking into the code and will try to include/replace the functionality in the new project.</em></p>
<p><strong>AS3Commons-Reflect</strong></p>
<p>This is a reflection library, or a clear API written around describeType(). It allows you to get runtime information about classes and objects running in your application, like the properties and methods available in a class, the metadata associated with a certain property, ... and it also allows you to dynamically instantiate objects and invoke their methods.</p>
<p>We had previously moved this from the Spring ActionScript sources to the AS3Reflect project. However, since we had plans of extracting other part of the framework as well, we decided to bundle everything under the AS3Commons project. The AS3Reflect library is hence no longer available and we advice all users to update to the new release.</p>
<p>For more info, please see <a href="http://www.as3commons.org/as3-commons-reflect">http://www.as3commons.org/as3-commons-reflect</a></p>
<p><strong>AS3Commons-Logging</strong></p>
<p>This is a logging abstraction layer over existing logging frameworks. It is a lightweight library that offers a logger interface and a set of adapters and decorators for existing logging frameworks, like the logging API in the Flex framework.</p>
<p>It is perfectly fit for library and framework developers that want to enable logging information in their distributed libraries without tying their code to a specific logging framework. Logging happens via the logger interfaces provided by AS3Commons-Logging and users are then able to configure the logger with the implementation they prefer.</p>
<p>Here's a small example:</p>
<div class="igBar"><span id="lactionscript-32"><a href="#" onclick="javascript:showPlainTxt('actionscript-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-32">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// configure the LoggerFactory with the Flex logging framework</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> loggerSetup:* = <span style="color: #66cc66;">&#40;</span>LoggerFactory.<span style="color: #006600;">loggerFactory</span> = <span style="color: #000000; font-weight: bold;">new</span> FlexLoggerFactory<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// get a logger from the factory, in which all log statements will be handled by the Flex logger</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> logger:ILogger = LoggerFactory.<span style="color: #006600;">getLogger</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"com.domain.MyClass"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>We will update the project with new adapters for existing logging frameworks. Let us know if you have any framework that you would like to see supported.</p>
<p>For more info, please see: <a href="http://www.as3commons.org/as3-commons-logging">http://www.as3commons.org/as3-commons-logging</a></p>
<p><strong>Get Involved</strong></p>
<p>We welcome participation from all that are interested, at all skill levels. Coding, documentation and testing are all critical parts of the software development process. If you are interested in participating in any of these aspects, please join us! You can leave a comment or mail me at christophe.herreman [at] gmail [dot] com.</p>
<p><a href="http://www.as3commons.org">www.as3commons.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/163/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Spring ActionScript 0.7.1 Released</title>
		<link>http://www.herrodius.com/blog/161</link>
		<comments>http://www.herrodius.com/blog/161#comments</comments>
		<pubDate>Fri, 06 Feb 2009 08:38:50 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Inversion of Control]]></category>
		<category><![CDATA[Spring ActionScript]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/161</guid>
		<description><![CDATA[Dear Community,
I'm pleased to announce that the Spring ActionScript 0.7.1 release is now available.
Download&#160;&#124;&#160;API Documentation&#160;&#124;&#160;Changelog
This is a minor release that fixes 2 blocking issues:
- import nodes were not parsed correctly, which resulted in the imported nodes not being created.
- circular reference error when 2 objects have bidirectional references.
We also added some extra classes to the [...]]]></description>
			<content:encoded><![CDATA[<p>Dear Community,</p>
<p>I'm pleased to announce that the Spring ActionScript 0.7.1 release is now available.</p>
<p align='center'><a href="https://sourceforge.net/project/showfiles.php?group_id=194107&#038;package_id=306949">Download</a>&nbsp;|&nbsp;<a href="http://www.pranaframework.org/docs/0.7.1/api/">API Documentation</a>&nbsp;|&nbsp;<a href="http://www.pranaframework.org/docs/0.7.1/changelog.txt">Changelog</a></p>
<p>This is a minor release that fixes 2 blocking issues:<br />
- import nodes were not parsed correctly, which resulted in the imported nodes not being created.<br />
- circular reference error when 2 objects have bidirectional references.</p>
<p>We also added some extra classes to the domain package.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/161/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Vote for the Mobile Rock Werchter Guide as an Adobe Max Finalist!</title>
		<link>http://www.herrodius.com/blog/156</link>
		<comments>http://www.herrodius.com/blog/156#comments</comments>
		<pubDate>Mon, 24 Nov 2008 17:54:23 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Boulevart]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/156</guid>
		<description><![CDATA[Calling out for some support for my co-worker Thomas Joos who has created a Rock Werchter Mobile Guide. If you have a minute, be sure to give him your vote! Congrats Thomas!


Quoting Thomas: "Last week I received an email from Adobe bringing me the wonderful news that our Rock Werchter Mobile Guide was selected as [...]]]></description>
			<content:encoded><![CDATA[<p>Calling out for some support for my co-worker <a href="http://vilebody.wordpress.com/">Thomas Joos</a> who has created a Rock Werchter Mobile Guide. If you have a minute, be sure to give him your vote! Congrats Thomas!</p>
<p><center><img src="http://vilebody.wordpress.com/files/2008/11/afbeelding-9.png" alt="" /></center></p>
<p><br/><br />
<strong>Quoting Thomas:</strong> "Last week I received an email from Adobe bringing me the wonderful news that our Rock Werchter Mobile Guide was selected as an Award Finalist entry for the Adobe Max Milan 2008 Awards in the ”Develop” category. We are very honoured to be one of the finalists and are happy to see the work we did together with Barefoot is getting a lot of attention and recognition. To give you an idea: the youtube video showcasing our werchter mobile guide running onto the iphone is already been watched more than a 128.000 times! We would like to thank Adobe for this great opportunity and Barefoot for working together on this cool and innovative project. Having Barefoot and their mind-blowing technology as our partner is awesome and we are proud we got this far together, as a team."</p>
<p>The entries can be found at <a href="http://max.adobe.com/eu/experience/#?s=5&#038;p=3">http://max.adobe.com/eu/experience/#?s=5&#038;p=3</a></p>
<p>A direct link to enter your vote: <a href="https://www.adobemaxsubmission.com/viewer/?projectid=626&#038;location=EMEA">https://www.adobemaxsubmission.com/viewer/?projectid=626&#038;location=EMEA</a></p>
<p>For more details and the original post, see <a href="http://labs.boulevart.be/index.php/2008/11/24/adobe-max-milan-award-finalist/">http://labs.boulevart.be/index.php/2008/11/24/adobe-max-milan-award-finalist/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/156/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>2M08: Keynote with Serge Jespers and Jason Levine</title>
		<link>http://www.herrodius.com/blog/147</link>
		<comments>http://www.herrodius.com/blog/147#comments</comments>
		<pubDate>Fri, 23 May 2008 07:52:46 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/147</guid>
		<description><![CDATA[I'm sitting at the keynote of Multi-Mania. Serge and Jason are talking about the history of Flash. Actually, Serge is talking to the crowd and Jason is adding some sound effects. They are quite a funny duo  
[9.40] Serge is talking about The Open Screen Project.
Flash Player 10 now. Let's talk new features:
- custom [...]]]></description>
			<content:encoded><![CDATA[<p>I'm sitting at the keynote of Multi-Mania. Serge and Jason are talking about the history of Flash. Actually, Serge is talking to the crowd and Jason is adding some sound effects. They are quite a funny duo <img src='http://www.herrodius.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>[9.40] Serge is talking about The Open Screen Project.</p>
<p>Flash Player 10 now. Let's talk new features:<br />
- custom filters and effects: Pixelbender, scripting language to write your own filters. You can use these custom filters in across application...Photoshop, Flash<br />
- Rich text layout: Hebrew<br />
- enhanced video support</p>
<p>MAKE SOME NOISE: The campaign by Andre Michelle. Serge is showing some examples made by the community. An equalizer built in Flash. Oldskooll Atari tunes interpreted at runtime.</p>
<p>Serge shows some more demos. Very performant filtering. And a 3D demo of Doom, awesome!</p>
<p>New services by Adobe:<br />
- Scene7 imaging<br />
- SHARE<br />
- Pacifica<br />
- Cocomo</p>
<p>More info on Pacifica: Voice over IP for Flash. Serge shows the Adobe Directory, internal tool to find colleagues. Serge is available! <img src='http://www.herrodius.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Adobe Directory is an AIR application that is connected to the Pacifica server and is able to call Cell Phones. Live demo...the phone actually rings! Applause...</p>
<p>Adobe Flash CS4: Demo time. Don't click that button Serge (he has a paper with instructions about what not to do <img src='http://www.herrodius.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )! He creates a motion tween, applause! Now moves the animation line. Oh no, Serge is going to click the button...I saw that! My god, this is stand-up comedy, hehe</p>
<p>Serge is showing 3D support. Rotating text in multiple axes. Jason should be the voice for movie trailers. "But wait! There's more".</p>
<p>Serge is connecting some balls. Inverse Kinematics FTW!!! This is awesome.</p>
<p>[10.10] Jason now takes over. He's hilarious, hahaha. Will be showing some new features. Talking about some new ways to work with video. He's very excited.</p>
<p>He shows OnLocation perhaps running on a Macintosh. Capture video and add relevant metadata. The metadata stays with the files troughout the production process. Now shows Premiere Pro. Speech Transcription, Speech to Text. Explains how the subtitles will be searchable. Scrubs the timeline, text is highlighted.</p>
<p>Jason also has a list. Don't show this next thing <img src='http://www.herrodius.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Now shows SoundBooth. Editing multiple tracks. Synchronizes the changes between SoundBooth and Premiere.</p>
<p>Showing differences in loudness. Equalize volume levels. He's really good at sound effects. He spent a lot of time at the dark room...and still. "Who's the Gorilla, he's my brother!".</p>
<p>[10.21] Device Central now. Emulate playback of any type of content on mobile devices. Exports presets to After Effects. "You click render and.... you're done!"</p>
<p>Serge is taking over. MAX 2008 Europe, 1-4 December 2008 in Milan, Italy.</p>
<p>Applause, applause, applause...</p>
<p>...The End...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/147/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
