Archive for the 'ActionScript' Category

[SOURCE FILES] UIComponent: Create Flex components from scratch

Source and example files from the presentation are now available through the following links:

1) What you get for free with UIComponent
2) [view] Component lifecycle
3) [view step one | step two] Invalidation

I have a text version of the presentation in the works. Anyways, I hope this is helpful to you as you create your own custom Flex components!

Text on a curved path in Flex - Resurrected

Updated: I’m going ahead and making the rough original source available since I have less time to work on this than expected. Please let me know if this helps you on any project or at least gets you started :)

One of the more popular posts on this blog is “Warping Text in Flex“. People are frequently asking for the source code and I am frequently not giving it to them (unless they say please) because it’s really really dreadful. Truly. So I have brought the project back to life as something I’m not embarrassed of.

An open sourced as-is etc version of this component will be posted shortly (preview below). The component will use a three point Bézier curve for the text path. Currently, this version uses the geometry classes from http://www.algorithmist.net/ but the released version may or may not.

Continue reading for a simple preview …
Continue reading ‘Text on a curved path in Flex - Resurrected’

Formally introducing <my:SimpleMP3 />

To learn more about the mysimplemp3 project, click the <my:SimpleMP3 /> tab at the top of this website. The project is hosted here on Google Code where you can download the latest swc or check out the source.

Currently the only demo is my proof of concept found here. I’m looking forward to seeing the components and projects you end create with mysimplemp3. Please keep me posted - and let me know about feature requests and potential bugs! Thanks.

Almost introducing <my:SimpleMP3 />

What's this? It looks easy!

OK. I really don't like building MP3 player components in AS3 for Flex. It's doable, sure, but tedious. In fact, I don't like it enough that I've done something about it. Now it can be fun to make an MP3 player in Flex! (not available yet, but there's a demo below).

XML:
  1. <my:SimpleMP3
  2.     id="music"
  3.     url="http://url.com/my.mp3" />

Now, just treat it like you'd expect!

Actionscript:
  1. music.play();
  2. music.pause();
  3. music.stop();
  4. music.volume = 0..1;

Yes, there's more: scrubbing, streaming, buffering, panning left to right, auto load, auto play, auto rewind, repeat and most importantly ... states! Read more and play with a quick demo after the jump.
Continue reading 'Almost introducing <my:SimpleMP3 />'

Interesting read about inheritance in ActionScript

Here is a cool article from the Flex 3 livedocs on ActionScript 3.0 and how the language handles fixed property and prototype inheritance. There is also a brief history of AS from version 1.0 to present. The content may not help you with day-to-day tasks, but it is an interesting and fun read.

The ModelLocator Holds Application Data

(Go to 'Cairngorm Series' to view all titles)

This is the second post in a series on Cairngorm fundamentals. We will be covering the concept of the ModelLocator, the Model in MVC. In short, the ModelLocator is a Singleton which implements a marker interface (no method definitions) from the Cairngorm framework called com.adobe.cairngorm.model.IModelLocator. The ModelLocator class defines properties that hold all application data. From now on we'll just call this class the Model.

Continue reading 'The ModelLocator Holds Application Data'

Moving towards MVC without Cairngorm

(Go to 'Cairngorm Series' to view all titles)

This is the first post in a new series on Cairngorm fundamentals. I begin the series with three steps towards a Model View Controller implementation using familiar concepts and no framework. Future posts will build on these concepts using the Cairngorm framework until we have built a working application.

Continue reading 'Moving towards MVC without Cairngorm'

Flex View Component Techniques in MXML & AS

I've been searching for a way to write view code in my Flex & AIR projects that is completely reusable, scalable and simple yet powerful. I've read about and used the questionably named 'code-behind' techniques that Ted and Adobe promote. I've tried the 'script src' technique that Tink is passionate about. I've used 'view helpers' and I've even tried the rarely discussed 'code-in-front' technique that Marc has written about. However, I've recently been creating my views with a technique I call the 'simple' method which is in the same school of thought as Marc's idea. Here's a table that describes the five methods mentioned above for creating views in Flex:

Flex view code separation techniques table

Continue to try out each technique in a Flex application with source and find out why I especially like the all MXML 'simple' method ...

Continue reading 'Flex View Component Techniques in MXML & AS'

Flex Part 02+: A Better Model Object

This post is an extension of an earlier post entitled "Flex Part 02: Value Objects & Model Objects".

Recap: Model Objects are similar to Value Objects in that they hold the same data, except that the Model Object is responsible for making sure that no 'bad' data gets into the VO. The Model Object enforces business rules like, "phone must be at least ten digits long" which a VO cannot do on its own. A Model Object may even include methods for easily manipulating properties.

In the earlier post I presented some example code for a Model Object. It turns out that what I provided is a pain to maintain over time. There's just too much duplication and poor use of public properties. Continue reading for my attempt at a better, easier Model Object ...

Continue reading 'Flex Part 02+: A Better Model Object'

FormattedStepper extends NumericStepper

Sometimes it is necessary to display a formatted value such as currency or a percentage in a NumericStepper component, but that is not a default behavior. I need something extremely simple that can be written as:

XML:
  1. <mx:CurrencyFormatter id="currencyFormatter"
  2.     currencySymbol="$"
  3.     precision="2"/>
  4.  
  5. <controls:FormattedStepper formatter="{currencyFormatter}"/>

My internet searches turned up this similar attempt, but it seemed overly complicated (just my opinion). Continue reading to view my attempt at a simple formatted numeric stepper with source. I've also included an example of a custom formatter as well as an item renderer / item editor in a DataGrid.

Continue reading 'FormattedStepper extends NumericStepper'