嗨,我发现了这个功能
function valueToPercent($value:Number, $min:Number, $max:Number):Number {
var myPercent:Number;
var difference:Number = $max - $min;
myPercent = (($value - $min) / difference);
return myPercent;
}
我如何定义这些变量并获得结果?我需要输出各种百分比,这些百分比将成为变量,这将为饼图提供动力......
这没有用,但我显然做错了
function valueToPercent($value:Number, $min:Number, $max:Number):Number {
var myPercent:Number;
var difference:Number = $max - $min;
myPercent = (($value - $min) / difference);
return myPercent;
}
valueToPercent(45, 0, 345);
Trace(valueToPercent);
谢谢!
答案 0 :(得分:1)
你快到了。当方法返回值时,您可以将其分配给它返回的类型的变量
var percentage:Number = valueToPercent(45, 0, 345);
trace(percentage);
和/或
trace(valueToPercent(45, 0, 345));