Topic: config widget with mxml/flex

Hello!

Back here after a long time. I am trying to build a config widget for my app using flex/mxml in FlashDevelop. While I could build the UI, I am trying to find if the chumby properties are available somehow in the mxml.

rubpa

Re: config widget with mxml/flex

In AS3, the parameters show up as properties of a LoaderInfo object.

Typically this is available from a MovieClip using the "root" property. From other objects, you'll need to set up some way of getting to "root" by having some MovieClip store it somewhere.

See here for some information that might be helpful.

Re: config widget with mxml/flex

Duane, I checked out that page. I could not find any flex example. My project is a FlashDevelop flex 4 project with only the following code. I'm able to trigger ccHandler function in which I intend to use the root params. However root is null in this function.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="ccHandler()">
    
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:layout>
        <s:VerticalLayout paddingTop="5" paddingLeft="5"/>
    </s:layout> 

    <fx:Script>
        <![CDATA[
            import spark.events.DropDownEvent;

            // Event handler to determine if the selected item is new.
            protected function placesCloseHandler(event:DropDownEvent):void
            {
                trace("code="+places.selectedItem.code);
            }
            
            protected function ccHandler():void
            {
                ta.text += "ccHandler called";
                for (var i:String in this.root.loaderInfo.parameters)
                {
                   ta.text += ("root.loaderInfo.parameters[\"" + i + "\"] = " + root.loaderInfo.parameters[i]);
                }
            }
        ]]>
    </fx:Script>
    
    <s:DropDownList id="places" width="250" close="placesCloseHandler(event);"> 
        <mx:ArrayCollection>
            <fx:Object code="1" label="A"/>
            <fx:Object code="2" label="B"/>
        </mx:ArrayCollection>
    </s:DropDownList>
    
    <s:TextArea id="ta" width="200" text="hello">
        
    </s:TextArea>
</s:Application>

The reason for choosing flex is that it has a drop down control and I need it in my config widget!

Re: config widget with mxml/flex

Well, Flex/mxml ultimately compiles to AS3, so everything that works for AS3 should work in Flex.

However, it appears Flex has some additional marshalling code in the Application class.

Try this code.

Re: config widget with mxml/flex

Excellent! Thank you.