2012-06-07 4 views
0

이것은 매우 간단해야하지만 나는 내 인생에 대해 런타임에 레이블 텍스트를 설정하는 것처럼 보이지 않습니다. 당신이 외부 방법을 실행할 수있는 스크립트 블록에있는 유일한 코드 클래스 가져 오기입니다 :레이블에 텍스트 설정

<?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" 
       width="398" height="85" minWidth="398" minHeight="85"> 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 
    <s:Label id="lbl_param" x="19" y="10" width="105" height="29" text="Paramaters: "/> 

    <fx:Script> 
     <![CDATA[ 
      lbl_param.text = "test113"; 
     ]]> 
    </fx:Script> 
</s:Application> 

답변

3

방법에 있어야 lbl_param.text을 설정하는 귀하의 코드가 "정의되지 않은 속성의 lbl_param의 액세스 (1120)"이 발생합니다 또는 변수 정의. 이 샘플에서는 초기화 이벤트 투수의 코드를 넣습니다 :

<?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" 
       width="398" height="85" minWidth="398" minHeight="85" initialize="init()"> 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 
    <s:Label id="lbl_param" x="19" y="10" width="105" height="29" text="Paramaters: "/> 

    <fx:Script> 
     <![CDATA[ 
      public function init():void{ 
      lbl_param.text = "test113"; 
      } 
     ]]> 
    </fx:Script></s:Application> 

면책 조항 : 나는 브라우저에서이 코드를 쓰고는 "컴파일러"완벽하지 않을 수 있습니다.

+0

고마워요. 모든 코드가 함수로 묶여있는 한 완벽하게 작동합니다. 당신의 생명의 은인. 나는 node.js와 javascript에 정말 능숙 해졌고이 언어를 선택하여 실행할 수 있다고 생각했습니다. 아뇨, 척 testa. –

관련 문제