2011-03-23 9 views
1

"어떻게해야합니까"라는 질문이 하나 더 있습니다. 구성 요소가 있고 런타임에 포커스 색을 변경하고 싶다고 가정합니다. 내가 가진 무엇포커스를 다시 그려야하는 구성 요소

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
       creationComplete="init()"> 
    <mx:Script><![CDATA[  
     private function init():void { 
      //putting focus inside needed component 
      focusTest.setFocus(); 
      focusTest.setSelection(0, 0); 

      // creates a new Timer 
      var minuteTimer:Timer = new Timer(1000, 30); 

      // designates listeners for the interval and completion events 
      minuteTimer.addEventListener(TimerEvent.TIMER, onTick); 
      minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete); 

      // starts the timer ticking 
      minuteTimer.start(); 
     }  
     public function onTick(event:TimerEvent):void { 
      // displays the tick count so far 
      trace("tick " + event.target.currentCount); 
      if (focusTest.getStyle('focusColor') != 0x008CEA) { 
       focusTest.setStyle('focusColor', 0x008CEA); 
      } else { 
       focusTest.setStyle('focusColor', 0xFF0000); 
      } 
      //Update everything somehow :)    
     }  
     public function onTimerComplete(event:TimerEvent):void { 
      trace("Time's Up!"); 
     }    
     ]]></mx:Script> 
    <mx:TextInput id="focusTest"/> 
</mx:Application> 

: 여기 당신을 위해 예를 들어 (내가 어떤 버튼을 제외했고 그것의 초점을 잃지 구성 요소를 방지하기 위해 같은 경우의 원인은 완벽하게의 색상을 변경)의 타이머는 두색 이상의 줄무늬. 속성이 변경되고 있습니다 (예 : 브라우저의 탭을 전환하는 동안 색상이 바뀌면 올바른 상태를 잡을 수 있음).

내가 뭘 원하는거야 :이 초점을 만들려면 (내가 전체 응용 프로그램에 updateDisplayList()를 호출하려고했습니다 "validate"로 시작하는 모든 방법을 시도했습니다 마법 않고 다시 그려, 나는 시도했다 styleChanged ... aggrrh .. 나는 생각을 떠났다. :)).

의견이 있으십니까?

어떤 도움, 평소와 같이, 대단히 감사합니다 :)

+1

즉시 다시 그리도록 구현되지 무언가가있다; 그래서 포커스를 잃고 포커스를 다시 얻어야합니다 (브라우저 탭을 전환하여 수행하는 것처럼 들린다). 포커스 링이 변경되면 updateDisplayList()를 재정 의하여 포커스 링을 다시 그립니다. 포커스 요소가 어디에/언제/어떻게 그려지는지 파악하기 위해 프레임 워크 코드를 살펴 봐야합니다. – JeffryHouser

+0

Aww .. 쌍 'focusTest.drawFocus (false); focusTest.drawFocus (true); ' 문제를 해결 .. 난 더 이상 깨끗한 솔루션이 있는지 궁금 해서요? :) 추신 도와 줘서 고마워요. 슈퍼 플렉스 맨 같아요. 곤경에 처한 곳, 그리고 올바른 장소에 타격을 가하는 곳. * 낄낄 웃음 * – Antenka

+0

도와 줘서 다행입니다. ;) – JeffryHouser

답변

1

당신이 themeColorfocusTest.drawColor(true)가 잘 작동 사용하는 경우. 다시 그리기 위해 drawFocus()를 사용해야하고, focusColor가 Flex 3 setStyle 속성 (Flex 4에서만 사용됨)이라고 생각하지 않습니다.

잘못된 setStyle/getStyle 속성을 사용하면 오류가 발생하지 않으므로 까다로운 점이 있습니다. 오류는 무시됩니다.

if (focusTest.getStyle('themeColor') != 0x008CEA) { 
     focusTest.setStyle('themeColor', 0x008CEA); 
    } else { 
     focusTest.setStyle('themeColor', 0xFF0000); 
    } 
    focusTest.drawFocus(true); 

전체 코드 : 나는 "focusColor"을 추측해야한다면

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
       creationComplete="init()"> 
    <mx:Script><![CDATA[  
     private function init():void { 
      //putting focus inside needed component 
      focusTest.setFocus(); 
      focusTest.setSelection(0, 0); 

      // creates a new Timer 
      var minuteTimer:Timer = new Timer(1000, 30); 

      // designates listeners for the interval and completion events 
      minuteTimer.addEventListener(TimerEvent.TIMER, onTick); 
      minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete); 

      // starts the timer ticking 
      minuteTimer.start(); 
     }  
     public function onTick(event:TimerEvent):void { 
      // displays the tick count so far 
      // displays the tick count so far 

      trace("tick " + event.target.currentCount); 
      if (focusTest.getStyle('themeColor') != 0x008CEA) { 
       focusTest.setStyle('themeColor', 0x008CEA); 
      } else { 
       focusTest.setStyle('themeColor', 0xFF0000); 
      } 

      focusTest.drawFocus(true); 
      //Update everything somehow :)    
     }  
     public function onTimerComplete(event:TimerEvent):void { 
      trace("Time's Up!"); 
     }    
    ]]></mx:Script> 
    <mx:TextInput id="focusTest" width="222"/> 
</mx:Application> 
+0

* Sight *가 작동하지 않습니다 .. 탭을 전환하고 돌아 가면 업데이트되지 않습니다. 하지만 어쨌든, 시도 주셔서 감사합니다 :) Btw, 나는 이미 비슷한 경우에 'themeColor'를 사용하여 권장 누군가를 보았지만, 나는 약간의 의구심을 가졌다. 그것은 글로벌 컬러를 바꾸고있다. – Antenka

+0

안녕하세요. 위에서 사용/테스트 한 전체 코드를 넣었으므로 정상적으로 작동합니다. 그것을 시도해보십시오, 어쩌면 약간의 차이가있을 수 있습니다. – Ryan

+0

이상하게 들리 겠지만, 여기서는 작동하지 않습니다. :(코드를 완전히 .... 추적에서 각 초마다 변화를 알 수 있지만 시각적으로 응용 프로그램에서는 변경되지 않았습니다. – Antenka

관련 문제