Apache flex AS 3函数可选值获取错误
我有一个gui类,函数可选值获取错误。如果我没有传递fillcolor和其他可选值 错误:Apache flex AS 3函数可选值获取错误,apache-flex,flash,actionscript-3,actionscript,Apache Flex,Flash,Actionscript 3,Actionscript,我有一个gui类,函数可选值获取错误。如果我没有传递fillcolor和其他可选值 错误: ReferenceError: Error #1069: Property fillColor not found on String and there is no default value. AS 3.0 var windowBase:Sprite = UIClip("Sprite"); /* sliderClip = Gui.UIClip("MovieClip",{width:1
ReferenceError: Error #1069: Property fillColor not found on String and there is no default value.
AS 3.0
var windowBase:Sprite = UIClip("Sprite");
/* sliderClip = Gui.UIClip("MovieClip",{width:100, height:50, fillColor:0xFFFF0D, alpha:.7});
*/
function UIClip (type:String, params:object = '') {
var clip;
trace("Hello")
if (type == 'MovieClip') {
clip = new MovieClip ;
} else {
clip = new Sprite;
}
//trace(params + "params.fillColor " + params.fillColor)
if (params is Object) {
clip.graphics.beginFill ((params.fillColor != "") ? params.fillColor : 0xFFFFFF, params.alpha ? params.alpha : 1 );
clip.graphics.lineStyle (params.lineThickness != "" ? params.lineThickness : 1, params.borderColor ? params.borderColor: 0x000000);
clip.graphics.drawRoundRect (0,0,
(params.width != undefined ) ? params.width : 100,
(params.height != undefined) ? params.height : 100 ,
params.eW ? params.eW : 0,
params.eH ? params.eH : 0);
clip.graphics.endFill ();
//trace("Hello")
}
return clip;
}
如何解决此问题?条件“if(params is Object)”为真。字符串也是对象。
如果可选参数没有默认值,我将使用null
试试这个:
函数UIClip(类型:String,参数:object=null)
并测试“if(params!=null)”