Archive for the ‘Flex 2.0’ Category

StyleUtil.getDefaultStyleName()

Thursday, February 14th, 2008

When creating the default styles on a component you need to know the name of the class you are inside. The most common way of creating default styles is to use a static initializer.

package
{
 
	import mx.core.UIComponent;
	import mx.styles.CSSStyleDeclaration;
	import mx.styles.StyleManager;
 
	public class MyFlexComponent extends UIComponent
	{
		public function MyFlexComponent()
		{
			super();
		}
 
		private static var defaultStylesSet                : Boolean = setDefaultStyles();
 
		/**
		 *  @private
		 */
		private static function setDefaultStyles():Boolean
		{
			var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration( "MyFlexComponent" );
 
			 if( !style )
			{
		        	style = new CSSStyleDeclaration();
		        	StyleManager.setStyleDeclaration( "MyFlexComponent", style, true );
			}
 
			if( style.defaultFactory == null )
			{
	        		style.defaultFactory = function():void
				{
					this.style0 = "style0";
	            			this.style1 = "style1";
				};
	        	}
	        	return true;
	 	}
	}
}

This works fine, but it can be a problem if you refactor the class and change the class name as the string that is used in the above example won’t be updated. We’ve stumbled across this a few times and so our solution has been to write a method to take care of this class name for us.

(more…)

Yahoo! Maps AS 3.0 API

Monday, February 11th, 2008

All this talk about MS buying out Yahoo had a few people thinking Yahoo have already started to turn their backs on the Flash Platform, then along comes a Yahoo! Maps for ActionScript 3.0.

The all-new Yahoo! Maps component for Flex 3 enables you to add a map to a wide-range of web and desktop applications. Included in the API is support for other Yahoo! APIs including the geocoder, local search and traffic APIs along with an advanced marker and overlay manager to allow you to easily represent data on the map.

More info at http://developer.yahoo.com/flash/maps/

Adding Children to Skins (SpriteBorder & SpriteProgrammaticSkin)

Friday, December 28th, 2007

I was creating a skin today and I need to be able to create children within the skin and add them to it’s display list. This wasn’t possible when extending Border or ProgrammaticSkin as they are not DisplayObjectContainers, they extend FlexShape (i.e. a DisplayObject).

I came across this post where Ely suggested creating some base classes that have this functionality (i.e. extend FlexSprite), so here they for anyone else who needs them.

SpriteBorder
SpriteProgrammaticSkin

TODO/FIXME Extension for Flex Builder

Tuesday, December 11th, 2007

I’ve been waiting for this for ages!!

Dirk’s post is titled, ‘TODO/FIXME extension for Flex Builder 2′, but it also works a treat in FB 3.0 too.

Thanks!

Free Online Flex Training

Wednesday, November 21st, 2007

Adobe has partnered with Total Training™ to offer free online Adobe® Flex™ training for 30 days. The video training features Adobe Flex team veteran James Talbot and Adobe Certified Master Instructor Leo Schuman. This limited-time promotion runs until December 31, 2007.

More Info

Papervision3D Effects for Flex Source

Thursday, October 4th, 2007

I’ve put another two examples together and uploaded the source (you will need to download the Papervision3D source as well).

There’s still a lot of work to do on these to tidy them up, and ideally I’ll get them up on Subversion, but for now if anyone has ideas for improvements etc, please post in the comments.

Cube, Flip, Rotate and Zoom.

View examples and right click for source.

NOTE: For those interested, the presentation and notes from LFPUG on this subject can be found here.

UPDATE: Jörg Birkhold has updated the source so that they work with Papervision3D 2.0/Great White. The source is available on his blog at http://liquidnight.de/2008/06/10/papervision3d-effect-classes-for-great-white. Thanks Jörg!

EffectPV3D for Flex

Thursday, September 27th, 2007

Recently I’ve been working on getting the intergrating Papervision3D with Flex for creating 3D effects. I’ll be talking over the code and how it all works tonight at LFPUG, but I thought I’d show a sneak peak of 2 effect examples. Although Alex Uhlmann has a very similar project based on Sandy, the projects are a little different in how they work and how you implement them.

The main reasons for starting this project where that my Flex app made use of Papervision elsewhere, and it didn’t make sense to have two 3D engines. Also IMO Papervision3D is now the standard for 3D.

Flip
Cube

I be posting the full source sometime next week.

NOTE: These example have been updated to include the source.

FilteredDataGrid

Friday, September 14th, 2007

Pretty simple one this and therefore I wasn’t going to bother posting it, but I’ve passed it on a few people as a solution to a problem they had so maybe others will find it useful.

Using the FilteredDataGrid you bind to your original source, but then pass a method reference through to the FilteredDataGrid’s filterFunction property and filter out any data in the dataProvider that you don’t want or isn’t valid.

[as]package ws.tink.flex.controls
{

import mx.controls.DataGrid;

public class FilteredDataGrid extends DataGrid
{

private var _originalDataProvider : Object;
private var _filterFunction : Function;

override public function set dataProvider( value:Object ):void
{
super.dataProvider = filterDataProvider( value );
}

public function set filterFunction( value:Function ):void
{
_filterFunction = value;

if( _originalDataProvider ) dataProvider = _originalDataProvider;
}

public function filterDataProvider( value:Object ):Object
{
_originalDataProvider = value;

return ( _filterFunction != null ) ? _filterFunction( value ) : value;
}

}
}[/as]

and here’s an example of it in action with the source…

FilteredDataGridExample

NOTE: I’ve edited the code slightly so you can toggle on and off the filter fucnction. The example above shows this in action.

The same results could be achieved without the FilteredDataGrid, but it saves you having to…

1. Set up your own var to bind with the dataprovider.
2. Setting up the binding yourself to invoke the filter function.

You would then in the filter function assign the new values to your var that is bound to the dataProvider.

360Flex Session Notes

Thursday, August 16th, 2007

David Coletta is doing a good job of writing up the sessions he’s attended at 360Flex Seattle. Worth a read.

Apollo Alpha

Monday, March 19th, 2007

This morning see’s an the long awaited alpha release of Apollo on labs.

Apollo is the code name for a cross-operating system runtime being developed by Adobe that allows developers to leverage their existing web development skills (Flash, Flex, HTML, JavaScript, Ajax) to build and deploy rich Internet applications (RIAs) to the desktop.

Also of interest if your looking to play with Apollo is the free PDF download of ‘Apollo for Adobe Flex Developers Pocket Guide’.

Go fill your boots!