Archive

Archive for the ‘Flex 4 Examples’ Category

Flex 4 List remembering verticalScrollPosition

June 18, 2010 22 comments

A simple requirement, but ~6 hours of frustration.

All I wanted to do was to remember the scroll position that the user was at after an update of the dataprovider items on a list occurred. I had a solution in flex 3 for the (Advanced)DataGrid control that listened for a scroll event and remembered the last known scroll position that would then be set in commit properties after the dataProvider for the grid dispatched a COLLECTION_CHANGE event.

Naturally, I started with that same solution on the Flex 4 list. It was a little trickier, discovering that no event was fired from the list when a scroll event occurred. It turns out that in the skin class, you have to listen to the vertical scroll bar on the scroller object, but this of course is entirely dependent on where your scroller or viewport container that handles scrolling lives, regardless of skinclass.

Read more…

Advertisements

Object/Dictionary Reference counting and Memory Management

March 7, 2010 Leave a comment

Since it is such an important topic and such a problem for the community, I thought I would make another post pertaining to optimizing for the garbage collector.

I was looking for information in the object/dictionary docs completely unrelated to memory management, but ran across this statement:

As long as any reference to the object exists, the garbage collection system will not recover the memory that the object occupies. If the value of myObject is changed such that it points to a different object or is set to the value null, the memory occupied by the original object becomes eligible for garbage collection, but only if there are no other references to the original object.

Wow.

Yes, you do need to explicitly set all non-simple types to null and splice/delete array indices and hash key entries.

Read more…

Using Spark skins to style Halo components

February 9, 2010 3 comments

Most of the halo components in the flex framework have a skin style. Sometimes it is labeled skin, others with border-skin, and if no general one skin style for the component exists, there are typically skin styles for individual pieces.

Lets use the halo vertical scroll bar as an example (svn) (zip) (swf):
Read more…

Conditional Compilation

February 3, 2010 Leave a comment

There is a cool compiler flag that allows you to conditionally compile code into your binaries called -define.

This really cool feature has an annoying side effect though:

Read more…

Data Binding Series

January 22, 2010 1 comment

Ever {wonder} how data binding works? The magic of data binding is a combination of code generation by the flex pre-compiler and the Flex event model, which is an implementation of the observer pattern.
Read more…

Passing the rest parameter

November 5, 2009 1 comment

As you probably know, you can create a function where the last parameter is a “…rest” variable.

You probably also know that when inside the function, the comma delimited variables from the caller show up as an array. This is unfortunate when you want to pass the set of values through to another function.

Read more…

Application global access

October 14, 2009 Leave a comment

In flex 4, accessing your application globally has changed from Application.application in flex 3, to FlexGlobals.topLevelApplication.

Flex 3:

import mx.core.Application;
var myApp:MyApp = Application.application as MyApp;

Flex 4:

import mx.core.FlexGlobals;
var myApp:MyApp = FlexGlobals.topLevelApplication as MyApp;
Categories: Flex 4 Examples