Archive for tag: flex

CODE: Migrating From Pure AS3 To Flex

Courtesy of Jamie S

We have started using Flex and Flash Builder quite frequently but we wanted still to use our own framework and code library. We found that various sprite manipulation scripts such as [addChild] would error when we were using flex objects. Instead we needed to use [addElement]. But our low-level framework uses [DisplayObjectContainer] in order to retain as much flexibity as possible and the compiler doesn't recognise [addElement] as a function of [DisplayObjectContainer]. We resolved this by using the [call] function:

targetView["addElement"].call(targetView, childView); 

This turned up a new challenge: our framework uses a number of default graphical elements which are pulled from custom swc files. But these elements are flash sprites and can't be directly attached to flex components. The answer was to create a new UIComponent at runtime and attach the flash spites to them:

var childContainer:UIComponent = new UIComponent;
childContainer.addChild(childView);
this.view["addElement"].call(targetView, childContainer);

So, we can continue to rely on the power of our own framework whilst combining it with the platform flexibility of Flex.

 

Website development at Signals

Our experience and technical expertise in creating websites, intranets and extranets ensures that we deliver real commercial benefit to businesses. Read more about what we do HERE.