开发者

how to get the id value From one mxml file to another mxml file in flex?

My Apllication is in Flex 3.5...My Code is Here,How to take the id value of textare? Button.Mxml

<mx:Button width="20" height="20" label="TextArea" id="textarea" click="setShape(DrawObject.TEXT);showTextArea()"/>

My Another file is here: Main.Mxml

 private function doMouseDown_canvas():void
                    {
                            if(this.shapeStyle==DrawObject.TEXT)
                            {
                                    if(isDrawing)
                   开发者_如何学运维                 {
                                            isDrawing = false;
                                            this.d = drawFactory.makeDrawObject(this.shapeStyle,segment, this.drawColor, this.thickness, textarea.text);
                                            dispatchEvent(new Event(BoardMediator.SEND_SHAPE));

                                    textarea.visible = false;
                                    }else
                                    {
                                            isDrawing = true;
                                            x1 = canvas.mouseX;
                                            y1 = canvas.mouseY;
                                            segment.push(x1);
                                            segment.push(y1);

                                            textarea.text = "";
                                    textarea.visible = true;
                                            textarea.x = canvas.mouseX;
                                            textarea.y = canvas.mouseY;
                                            textarea.setFocus();

                                            locateEditor();
                                    }
                            }else
                            {
                                    isDrawing = true;
                                    x1 = canvas.mouseX;
                                    y1 = canvas.mouseY;
                                    segment.push(x1);
                                    segment.push(y1);
                                    canvas.rawChildren.addChild(feedback);
                            }
                    }


you have to use the Button.mxml somewhere ...!? setting the ID of something inside a mxml file, makes this object a public attribute of the corresponding class.

if the <mx:Button> is the only thing inside your button.mxml get rid of the ID inside the button.mxml and set it from the outside.

if you have a surrounding container, sth, like a HGroup you can access it from your main like this:

<myNS:Button id="myButton" />

and in the fx:Script tag:

myButton.textarea;

cheers


MxmlOne.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx">
    <s:Button id="myBtn" label="something"/>
</s:Panel>

MxmlTwo.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Script>
        <![CDATA[

            private function someFunc():void
            {
                myPanel.myBtn.label = 'Some label';
            }
        ]]>
    </fx:Script>
    <MxmlOne id="myPanel"/>
</s:WindowedApplication>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜