to implement two functions from a link button


i have created script:

 

<?xml version="1.0" encoding="utf-8"?>

<s:application minwidth="955" minheight="600"

xmlns:fx="http://ns.adobe.com/mxml/2009"

    xmlns:s="library://ns.adobe.com/flex/spark"

    xmlns:mx="library://ns.adobe.com/flex/mx" 

    initialize="createlistener()">

 

<fx:declarations>

</fx:declarations>

 

<fx:script>

    <![cdata[

        import spark.events.indexchangeevent;

        // define custom function labelfunction property

        // display object in ddl control.

        public function mylabelfunc(item:object):string {

             return item.firstname + " " + item.lastname;

        }

        // define custom function labeltoitemfunction property

        // convert new value object of correct format

        // storage in data provider of control.

        public function mylabeltoitemfunc(value:string):object {

             var tempobj:object = new object();

             var spacechar:int = value.indexof(' ');

             tempobj.firstname = value.substr(0, spacechar);

             tempobj.lastname = value.substr(spacechar+1, value.length);

             return tempobj;

            }

             // event handler determine if selected item new.

            protected function mycb_changehandler(event:indexchangeevent):void

            {

                 // determine if index specifies new data item.

                 if(mycb.selectedindex == spark.components.combobox.custom_selected_item)

                     // add new item data provider.

                     mycb.dataprovider.additem(mycb.selecteditem);

            }

 

 

        import spark.components.combobox;

       private function setlabel():void {

            if (l2.label=="show combobox") {

                l2.label = "show textbox";

 

                               } else {               

                l2.label = "show combobox";

 

            }

          }

          private function createlistener():void {

                l2.addeventlistener(mouseevent.click,showcustombox);               

            }

          import mx.controls.alert;

          private function showcustombox(e:mouseevent):void{

          t2.text += " listener." + "\n";

          alert.show("an event occurred.");

 

          }

 

 

        }

 

    ]]>

</fx:script>

 

 

    <s:states >

    <s:state name="immediate"/>

    <s:state name="deferred"/>

    </s:states>

 

<s:bordercontainer bordercolor="#0b85b7"

    cornerradius="8"

    borderweight="4">

<s:vgroup top="10" horizontalalign="center" >

<s:combobox id="mycb"

            includein="immediate"

            itemcreationpolicy="immediate"

 

            labelfunction="mylabelfunc"

labeltoitemfunction="mylabeltoitemfunc"

change="mycb_changehandler(event);">

           <s:dataprovider>

           <mx:arraycollection>

            <fx:object firstname="abhinav" lastname="somal"/>

            <fx:object firstname="adit" lastname="kumar"/>

            </mx:arraycollection>

          </s:dataprovider> 

        </s:combobox>

 

 

        <s:textinput id="t1"

 

            includein="deferred"           

            itemcreationpolicy="deferred"/>

 

 

 

        <mx:linkbutton id="l2" label="show textbox"

          click="currentstate='deferred';setlabel();"/>

 

        <s:textarea id="t2"

       

        text="the selected item is: {mycb.selecteditem.firstname + ' '

        + mycb.selecteditem.lastname};

        {l2.label};

        {b1.label};

       

        "/> 

 

<mx:button id="b1" label="send"  >

</mx:button>

 

 

      

  

</s:vgroup>

</s:bordercontainer>   

</s:application>

 

 

in changed link label,but not able dropdown list ..

kindly help..



More discussions in Flex (Read Only)


adobe

Comments

Popular posts from this blog

Gavik Photoslide GK2: Not able to upload photos - Joomla! Forum - community, help and support

How to decompile jsxbin to jsx

Thread: networkmanager's dsl connection can't have static LAN ip?