Yes, Alex.  You Rock dude(ss)!!

For those who may follow and look at this let me add a
few notes.

I needed to add an import statement to bring in the 
Container class (done from scratch, this happens automatically):

        import mx.core.Container;

I then updated the combo box array to include the "components" 
qualifier and called the fAddCustomView function with the data item 
from the combo box(cbCompList):

        e.g. <mx:Object label="Component2" data="components.Comp2"/>

        <mx:Button x="25" y="68" label="Add Custom Component"
           click="fAddCustomView(cbCompList.selectedItem.data)"/>

However, this produced an Flash9 error.  The call was passing a 
string rather than the class itself.

        TypeError: Error #1034: Type Coercion failed: cannot 
        convert "components.Comp3" to Class.
        at ViewStackTest2/___Button2_click()

So, I modified the array to have a reference to the class as the 
data, instead of the string (simply by enclosing the string in curly 
braces).

        e.g.<mx:Object label="Component2" data="{components.Comp2}"/>

It works!!  Thanks.
Alex, you've taught me how to instantiate an object, specifying the 
class at runtime!  This is a huge step towards creating a more 
Dynamic UI.


I'm looking for a freelance Flex/CF tutor/mentor.  (See FlexJobs.)
Let me know if you are interested.

Paul


--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Are you asking about:
> 
>  
> 
> private function fAddCustomView(compClass:Class):void
> {
> var canCustView:Container = Container(new compClass());
> canCustView.label = "Custom " + 
> cbCompList.selectedItem.label;
> vsComps.addChild(canCustView);
> }
> 
> 
> 
> ...
> 
> fAddCustomView(Comp1);
> 


Reply via email to