Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Thread Tools Rate Thread Display Modes
Old 04-01-2008, 04:49 PM   #1
Registered User
Join Date: Jan 2008
Posts: 69
Default Compiling components independently to application

The application I am working on draws custom components based on a list retrieved from a database ("DynamicElem1","DynamicElem2"). For example
ActionScript Code:
for each(var elemName:String in elemList)   {     var classToUse:Class = getDefinitionByName(elemName) as Class;     var cfElem:UIComponent = new classToUse;     addChild(cfElem);   }

At a later date further components may be required, eg DynamicElem3. I would like to develop the application so that the components can be compiled independently of the main application but still be used by the main application as above. Is this possible? Thanks.

Last edited by dr_zeus; 04-02-2008 at 04:51 PM. Reason: please use [as][/as] formatting tags
angie is offline   Reply With Quote
Old 04-01-2008, 05:16 PM   #2
dr_zeus's Avatar
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999

Yes. You can compile them into a SWF, load the SWF into your application at runtime, and access those components through the loaded SWFs ApplicationDomain.
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote
Old 04-02-2008, 09:52 AM   #3
Registered User
Join Date: Jan 2008
Posts: 69

I've taken a quick look at this and have a few more questions. How can I compile an ActionScript class into an SWF using Flex Builder? Am I able to use the component the same as any well known component in the main SWF? My components will implement an interface that is well known by the main application, would I need to specify the interface in a shared library so it can be used in all SWF's? Thanks.
angie is offline   Reply With Quote
Old 04-07-2008, 09:41 AM   #4
Registered User
Join Date: Jan 2008
Posts: 69

I didn't have much success using the application domain, so I've looked into a different approach which seems to work but I was wondering whether this will have any negative impact of application size/performance?

- I've created a library project (ElemInterfaces) which contains a number of interfaces implements by the elements
- I've created a number of library projects (Elem1, Elem2...). These link to the ElemInterfaces library with a link type of External.
- I've created another library project (Componentslist) which links to the other libraries. It contains a single class which declares variables of type Elem1, Elem2 etc
- I've created my main application which links to ComponentsList with the Link Type set as RSL. It also links to ElemInterfaces with the link type set to External.
- In the main application I can instantiate objects of type Elem1 and Elem2 using GetDefinitionByName as below.

I can also create a new Elem library, link this to ComponentsList, compile ComponentsList and deploy without needing to compile my main application.

Is this an acceptable design? Also, I'm having some problems using the External link type. Linking to ElemInterfaces as External is fine, but if I try to set the link in ComponentsList to Elem1 to External I get the following run time error 'VerifyError: Error #1014: Class mx.containers::VBox could not be found.' But when it is 'Merged in code' it is fine. Any ideas would be much appreciated.
angie is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pusing 2 complex components to one tileList ljonny18 Flex 2, 3 & 4 0 11-20-2007 01:45 PM
[solution] MX Components in pure actionscript... shadowmint ActionScript 3.0 3 10-18-2007 11:53 AM
Creating Components - Compiling library items into component... Deathwalker666 Components 0 04-03-2007 03:17 PM
Why do components take so long to appear on stage? xbrotherx Components 3 06-21-2006 04:00 PM
Compiling problems in Flash MX using Macromedia standard components danliles Components 8 02-20-2005 04:38 PM

All times are GMT. The time now is 04:31 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.