效果:初始化效果:

mouse over的效果:

代码:

 
  
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"   
  3.                xmlns:s="library://ns.adobe.com/flex/spark"   
  4.                xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" 
  5.                 creationComplete="init()"> 
  6.     <fx:Declarations> 
  7.         <!-- 将非可视元素(例如服务、值对象)放在此处 --> 
  8.     </fx:Declarations> 
  9.     <fx:Script> 
  10.         <![CDATA[  
  11.             import spark.components.Image;  
  12.             var helpBtn:Image = new Image;  
  13.             public function init():void{  
  14.                 createChildren()  
  15.             }  
  16.             /**重写skinablecontainer的createchildren方法*/  
  17.             override protected function createChildren():void{  
  18.                 super.createChildren();  
  19.                 helpBtn.source = "assets/updateTipOut.png";  
  20.                 helpBtn.addEventListener(MouseEvent.MOUSE_OVER,helpBtnOver);  
  21.                 helpBtn.left = 65;  
  22.                 helpBtn.top = -25;  
  23.                 lab.addElement(helpBtn);  
  24.             }  
  25.             protected function helpBtnOver(event:MouseEvent):void  
  26.             {  
  27.                 helpBtn.source ="assets/updateTipOver.png";  
  28.             }  
  29.               
  30.         ]]> 
  31.     </fx:Script> 
  32.     <s:TitleWindow id="lab" width="523" height="456" title="123131"/> 
  33. </s:Application> 

上述代码  指的是:在as代码中给titlewindow加一个addelement,里面添加一个组件,重写了titlewindow的父类的父类的。。。的父类skinablecontainer的createChildren方法