Tony Alves
Flex, .Net, and Fluorine

Flex Preloader Example

Tuesday, 31 July 2007 16:37 by talves
You want to be able to write your custom preloader in FLEX?

Jesse Warden will be able to walk you through it here.

Before you leave to go write your new preloader, make sure to read my comment on needing to remove the event listeners when you are done.

Summary:
Awesome stuff! There is a caveat to consider.

1. The preloader overwrites the event Listeners, but leaves them once the application is loaded. This is ok if you never load anything else into your flex application. If you load a module into your application, flex will fire the FlexEvent.INIT_PROGRESS event again causing an error due to the clip.preloader becoming null.

2. Solution:
Instantiate a private variable called _preloader in your constructor;

private var _preloader:Sprite;
public override function set preloader(preloader:Sprite):void
{
_preloader = preloader;
_preloader.addEventListener( ProgressEvent.PROGRESS , onSWFDownloadProgress );
_preloader.addEventListener( Event.COMPLETE , onSWFDownloadComplete );
_preloader.addEventListener( FlexEvent.INIT_PROGRESS , onFlexInitProgress );
_preloader.addEventListener( FlexEvent.INIT_COMPLETE , onFlexInitComplete );
centerPreloader();
}


Remove the listeners once the application is loaded and you are complete;

private function onDoneAnimating():void
{
clip.stop();
_preloader.removeEventListener( ProgressEvent.PROGRESS , onSWFDownloadProgress );
_preloader.removeEventListener( Event.COMPLETE , onSWFDownloadComplete };
_preloader.removeEventListener( FlexEvent.INIT_PROGRESS , onFlexInitProgress );
_preloader.removeEventListener( FlexEvent.INIT_COMPLETE , onFlexInitComplete );
dispatchEvent( new Event( Event.COMPLETE ) );
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Extending Flex TextInput to capture Enter Key

Thursday, 19 July 2007 16:34 by talves
I have many customers who use text entry very heavily. The users always ask for as little mouse use as possible when entering data into the application. To solve this, I have extended the TextInput and Button to listen for the Enter key and fire an event similar to a click of the mouse. There is a visual helper on the control taken from an article that allows the user to see very quickly what was not entered and what has been entered (as long as the developer uses a colored background).

The developer can now place these text input boxes all over the screen and when a user finishes entering into the field the enter key will cause the focus to change to the next box.

ExtendingControls Demo
Put focus in one of the boxes; Hit the enter key; You will see the focus change; Try not to use the mouse (hard for me at first).

ExtendingControls Source

You can also right click and View Source.

I hope this can help someone out.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Flex DataGrid ItemRenderer Gotcha

Monday, 16 July 2007 16:31 by talves
Struggling with a datagrid in flex taking too much memory?
Your datagrid is too slow?
You thought you could just use any component container as an item renderer?

These are the gotcha's of the flex datagrid.

Here are two blog posts by Alex Harui from Adobe that explain how to make sure your datagrid does not get bogged down when creating item renderers.

Thinking About Item Renderers
More Thinking About Item Renderers

He put up source demos, but the source must be downloaded to view.
I have set up the examples with source for you. You can right click any of the examples to browse the source.
Item Renderer Demos

Hope this helps you as much as it helped me.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed