[FLEX3] 상속받은 클래스 스타일 프로퍼티의 초기화.

1. Canvas객체의 스타일을 정의한 css파일이 있습니다.

/* CSS file */
Canvas{
 background-color: #ff0000;
}


2. 부모클래스를 상속받은 커스텀 캔버스 객체가 있습니다.
CustomCanvas.as

package
{
 import mx.containers.Canvas;
 public class CustomCanvas extends Canvas
 {
  public function CustomCanvas()
  {
   super();
  }
  
 }
}


어플리케이션에서 아래와 같이 사용하면 빨간색 배경을 가진 두개의 캔버스가 나란히 그려집니다.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"
 height="100%" layout="horizontal" xmlns:local="*"  >
 <mx:Style source="css/css.css"/>

 </mx:Script>
 <mx:Canvas width="100" height="100" />
 <local:CustomCanvas width="100" height="100" id="c"/>
</mx:Application>

이때 일반캔버스는 스타일을 적용하고 싶지만 CustomCanvas는 적용하고 싶지 않을때 아래와 같이 하면됩니다.



CustomCanvas.as

package
{
 import mx.containers.Canvas;
 public class CustomCanvas extends Canvas
 {
  public function CustomCanvas()
  {
   super();
  }
  override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
   super.updateDisplayList(unscaledWidth, unscaledHeight);
   try{
     this.setStyle("backgroundColor", null);
   }catch(e:Error){
    
   }
  }
 }
}


아래와 같은 코딩은 소용이 없습니다.(삽질하지 맙시다.)
1.
setStyle(backgroundColor, undefined);

2.
setStyle(backgroundColor, "undefined");

3.
clearStyle("backgroundColor");

4.
override public function styleChanged(styleProp:String):void{
    if(styleProp && styleProp == "backgroundColor") return;
    super.styleChanged(styleProp);
 }
5.
 override public function setStyle(styleProp:String, newValue:*):void{
    if(styleProp && styleProp == "backgroundColor") return;
    super.setStyle(styleProp, newValue);
  }

다른건 모르겠는대.. 3, 4, 5 는 왜 안되는지 모르겠습니다..
함수를 재정의한곳은 CustomCanvas에서 했습니다.
styleChanged나 setStyle으로 아에 backgroundColor 속성이 안들어오는거 같더라구요..




다른 방법을 알고 계신다면 공유해주시면 감사하겠습니다~