当前位置: 首页 > 工具软件 > SimpleButton > 使用案例 >

如果更改SimpleButton 按钮中的文本

金阳华
2023-12-01

http://bbs.9ria.com/forum.php?mod=viewthread&tid=179612&page=1#pid1767355


function SetBtnCap(btn:SimpleButton,str:String,idx:int):void {
    ((btn.upState as DisplayObjectContainer).getChildAt(idx) as TextField).text=str;
    ((btn.overState as DisplayObjectContainer).getChildAt(idx) as TextField).text=str;
    ((btn.downState as DisplayObjectContainer).getChildAt(idx) as TextField).text=str;
    ((btn.hitTestState as DisplayObjectContainer).getChildAt(idx) as TextField).text=str;
}

或者

function SetBtnCap(btn:SimpleButton,str:String,idx:int):void {
    ((btn.upState as DisplayObjectContainer).getChildAt(idx) as TextField).text=str;
    ((btn.overState as DisplayObjectContainer).getChildAt(idx) as TextField).text=str;
    ((btn.overState as DisplayObjectContainer).getChildAt(idx) as TextField).x = ((btn.upState as DisplayObjectContainer).getChildAt(idx) as TextField).x + 2;
    ((btn.overState as DisplayObjectContainer).getChildAt(idx) as TextField).y = ((btn.upState as DisplayObjectContainer).getChildAt(idx) as TextField).y + 2;
    ((btn.downState as DisplayObjectContainer).getChildAt(idx) as TextField).text=str;
    ((btn.hitTestState as DisplayObjectContainer).getChildAt(idx) as TextField).text=str;
}

或者、

 类似资料: