Fl.controls not found, how do I import the fl package in ActionScript 3 AS3

Flash components are fantastic as long as you don't start customizing them. I never used them in AS2 because they would often access the root of my movie and add things that messed with my code. Now with ActionScript3 (AS3) Security settings, I can load components into a seperate SWF which keeps the loaded components influence out of my code. I find the documentation for these flash components to be rather poor. So far the best documentation that I have found resides here:

[http://help.adobe.com/en_US/ActionScript/3.0_UsingComponentsAS3/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7fd4.html](http://help.adobe.com/en_US/ActionScript/3.0_UsingComponentsAS3/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7fd4.html)

Also people get confused between using these components in Flash Professional and in Flex Builder. If you are using Flash Pro then you should use the fl package, if you are using flex then you should be using the mx package. There are two ways to import packages from the fl package. For example to use compile time checking of the classes in the fl.controls package you would do the following:

go to the menu window

open the components panel

drag your component into the library

some examples of available components in the fl.controls package would be:


If you are coding inside of this FLAs timeline where you have dragged your components, you can just start coding and assume the classes like TIleList will be globally available from the library.

If you are downloading the generated SWF (component.swf) into a seperate SWF (uiControler.swf) which has classes that work with the components in the component.swf then you need to import the classes by adding their class path. Goto control shift F12 (command shift F12 on a mac) in your FLA (uiControler.FLA) or click menu file>publish settings and then under the flash tab click actionscript settings there you can add the class path for the fl package. It will be something like the following in CS3:

C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Component Source\ActionScript 3.0\User Interface\

in CS4 you will need these paths:

C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\First Run\Classes
C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\ActionScript 3.0\projects\Flash\src\fl
C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0

There is also a dynamic way to aquire the classes from the component.swf if you dont want to include the class path in uiControler.swf. This is considered sloppy programming because you remove compile time checking however rules can be broken in some casses. For example what if you are programming a library that relies on these components, you don't want to distribute a SWC and you don't want to distribute the fl package. But you will distribute the UI assets in a SWF with the library. This way you avoid having the user drag things on stage or change the class path. They just import your libary and start using it.

Here is an example:

var loaderObject:LoaderInfo = _uiAssets.root.loaderInfo;
// Get the same domain with movie loaded
var domain:ApplicationDomain = loaderObject.applicationDomain;
//dynamic classes
var TileListClass:Class;
var ScrollBarDirectionClass:Class;
var ScrollPolicyClass:Class;
var DataProviderClass:Class;
//get classes for - fl.controls.TileList
// Pull class from file .swf with the same domain
try {
TileListClass = domain.getDefinition ( "fl.controls.TileList" ) as Class;
ScrollBarDirectionClass = domain.getDefinition ( "fl.controls.ScrollBarDirection" ) as Class;
ScrollPolicyClass = domain.getDefinition ( "fl.controls.ScrollPolicy" ) as Class;
DataProviderClass = domain.getDefinition ( "fl.data.DataProvider" ) as Class;
var titleList:Object = new TileListClass();
var dataProvider:Object = new DataProviderClass();
} catch (e:Error){
trace("Error: "+_UI_NAME+" class fl.controls not found "+e.message);
}


comments powered by Disqus