Actionscript 3 闪存AS3错误:增量的1106操作数必须是引用

Actionscript 3 闪存AS3错误:增量的1106操作数必须是引用,actionscript-3,Actionscript 3,1106递增的操作数必须是引用 this.format.size = Object(Number(this.format.size)--); 你可以试试 var tmpNum:Number = Number(this.format.size); this.format.size = Object(tmpNum--); !!但为什么不使用: this.format.size--; this.format.size为null或未定义,或者size不是format的属性(即this.forma

1106递增的操作数必须是引用

this.format.size = Object(Number(this.format.size)--);
你可以试试

var tmpNum:Number = Number(this.format.size);
this.format.size  = Object(tmpNum--);
!!但为什么不使用:

this.format.size--;

this.format.size为null或未定义,或者size不是format的属性(即this.format为null)

首先:在何处创建format变量

第二条:线路

 this.format.size = Object(Number(this.format.size)--);
没有道理。当减量用作后缀运算符时,将在处理后缀运算符之前返回表达式的值。 使用:


该归咎于演员/数字转换
--
-=1
的缩写。所以它需要一些东西来存储新的值。但是数字转换返回的是一个值,而不是一个引用,因此您在其中编写的内容转换为:

//let's say this.format.size holds the value '5'
this.format.size = Object(5 -= 1);
显然,你不能在一个值中存储一个值

如果您不能100%确定this.format.size返回一个数字,那么简单的解决方法是:

this.format.size = parseInt( this.format.size ) -1;
但显然,最好先验证存储在format.size中的值

//let's say this.format.size holds the value '5'
this.format.size = Object(5 -= 1);
this.format.size = parseInt( this.format.size ) -1;