2011-07-21 66 views
0

我的Apllication是在Flex 3.5中...我的代碼是在這裏,如何獲取textare的id值? Button.Mxml如何獲取id值從一個mxml文件到flex中的另一個mxml文件?

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

我的另一個文件是在這裏: 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); 
          } 
        } 
+0

請注意讓問題更清楚嗎?我不知道你在問什麼。 –

+0

不知道問題是什麼。 。 。 – Nate

回答

0

你必須從某個地方使用Button.mxml ......! 設定的MXML文件內東西ID,使得該對象的相應類的公共屬性。

如果<mx:Button>是你button.mxml內唯一擺脫button.mxml裏面的ID和從外面設置。

如果你有一個周圍的容器,某事,就像一個HGroup你可以從你的主這樣訪問:

<myNS:Button id="myButton" /> 

,並在fx:Script標籤:

myButton.textarea; 

歡呼

0

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

謝謝先生,它的信息非常好 – aabi

相關問題