2013-07-29 4 views
0

애플리케이션 데이터를 지우지 않고 내 모바일 앱을 시작하면 내 스킨 클래스가 표시되지 않습니다.Flex 4.6의 모바일 앱 초기화에 skinClass가 표시되지 않습니다.

홈페이지에 스킨 클래스가있는 맞춤 검색 버튼 구성 요소가 있습니다. 스킨 클래스는 다른 뷰로 이동하여 홈페이지로 돌아와서 적용된 스킨을 볼 수있을 때만 변경 사항을 보여줍니다. 그러나 애플리케이션 초기화시 스킨을 표시하는 방법을 찾는 데 문제가 있습니다.

HomeView.mxml 단지에 마우스 클릭 이벤트 리스너를 추가 내가 PureMVC framework을 사용하고

<s:VGroup width="50%" height="100%" > 
    <s:SkinnableContainer width="100%" height="100%" skinClass="com.abc.mobile.views.skins.BackgroundFillSkin"> 
     <s:VGroup width="100%" height="100%" horizontalAlign="center"> 
      <s:VGroup width="100%" height="50%" verticalAlign="middle" horizontalAlign="center"> 
       <components:ImageButton buttonMode="true" styleName="btnSrs" 
             imageSkin="{Images.iconDashboardSR}" 
             skinClass="com.abc.mobile.views.skins.ImageButtonSkin" 
             id="btnSrs"/>        
       <s:Label textAlign="center" verticalAlign="middle" styleName="homeScreenLabel" text="SRs" minWidth="120" id="lblSrs"/> 
      </s:VGroup> 
      <s:VGroup width="100%" height="50%" verticalAlign="middle" horizontalAlign="center"> 
       <components:ImageButton buttonMode="true" label="Asdsda" 
             imageSkin="{Images.iconCR}" 
             skinClass="com.abc.mobile.views.skins.ImageButtonSkin" id="btnCrs"/> 
       <s:Label textAlign="center" verticalAlign="middle" styleName="homeScreenLabel" text="CRs" minWidth="120"/> 
      </s:VGroup>    
     </s:VGroup> 
    </s:SkinnableContainer>     
</s:VGroup> 

, CREATION_COMPLETE에 이렇게 HomeViewMediator 통화 setupView

homeView.btnSrs.addEventListener(MouseEvent.CLICK,showDashboard); 

ImageButtonSkin.mxml SkinClass

<?xml version="1.0" encoding="utf-8"?> 
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" 
      xmlns:skins="com.abc.mobile.views.skins.*"> 
    <s:states> 
     <s:State name="disabled"/> 
     <s:State name="down"/> 
     <s:State name="over"/> 
     <s:State name="up"/> 
    </s:states>  
    <fx:Metadata> 
     [HostComponent("com.abc.mobile.views.components.ImageButton")] 
    </fx:Metadata>    
    <skins:NotificationButton id="notification" 
           visible="{int(hostComponent.toolTip)>0}" 
           includeInLayout="{int(hostComponent.toolTip)>0}" 
           depth="1" right="-10" top="-15" label="{hostComponent.toolTip}" 
           fontWeight="bold" fontSize="13" color="0x690502"/> 

    <s:BitmapImage source="{hostComponent.getStyle('imageSkin')}" 
        source.up="{hostComponent.getStyle('imageSkin')}" 
        bottom="0" left="0" right="0" top="0"/> 
</s:SparkSkin> 

ImageButton.as 클래스

package com.abc.mobile.views.components 
{ 
    import spark.components.Button;  
    [Style(name="imageSkin",type="*")] 
    public class ImageButton extends Button 
    { 
     public function ImageButton() 
     { 
      super(); 
      this.buttonMode = true; 
     } 
    } 
} 

업데이트

초기화에 모바일 앱의 스크린 샷을 추가 및 enter image description here

솔루션으로 업데이트 홈페이지로 다른 뷰에서 반환

override public function styleChanged(styleProp:String):void { 
      super.styleChanged(styleProp); 
      if (styleProp!=null) 
      { 
       switch(hostComponent.id){ 
        case "btnSrs": bi.source=Images.iconDashboardSR;break; 
        case "btnCrs": bi.source=Images.iconCR;break; 

       }     
       invalidateDisplayList();      
       return; 
      } 
     } 

답변

1

source="{hostComponent.getStyle('imageSkin')}" -이 바인딩은 스타일 변경을 감지하지 않습니다. styleChanged 메서드를 재정의하여 'imageSkin'스타일 변경을 감지하고 이미지 소스를 다시 적용하십시오.

+0

감사합니다. 나는 조금 앞서 나아갔습니다. bi.source에서'MultiDPIBitmapSource' 소스를 수동으로 적용하면 이미지를 보여줄 수는 있지만, 이제 어떻게 자신의 이미지를 가져 오는 버튼을 결정할 수 있습니까? – abi1964

+0

고마워 내 문제를 해결했다 – abi1964

+1

흠 ... styleprop을 'imageSkin'과 비교하고 이미지 소스를 getStyle ('imageSkin')으로 설정하는 것이 어떨까요? 그런데 표준 버튼에는 아이콘 스타일이 있고 스킨에는 아이콘 패딩 abd 위치에 대한 스타일이 몇 가지 더 있습니다. 모든 스타일은 hostcomponent의 스킨에 의해 상속되므로 hostComponent.getStyle 대신 getStyle을 사용할 수 있습니다. – user1875642