7/29/2010 12:23:28 AM
Title:
error conversion
i code the following as as2 to as3
But it raise an error as follows:
Scene 1, Layer 'action', Frame 1, Line 177 1067: Implicit coercion of a value of type String to an unrelated type Number.
can anybody to help me to convert
obj1.txt.addEventListener(FocusEvent.FOCUS_OUT, funFocus)
function funFocus(evt:FocusEvent):void //onKillFocus = function()
{
if (evt.target.parent.decimal == 0)
{
var noStr:String = String(parseFloat(this.text));
if (noStr.length<this.maxChars)
{
noOfZero = this.maxChars-noStr.length;
while (noOfZero-->0)
{
noStr = "0"+noStr;
}
}
evt.target.text = isNaN(noStr) ? "" : noStr;
}
else
{
noStr = String(parseFloat(this.text));
if (noStr.indexOf(".") == -1)
{
noStr += ".";
}
if (noStr.length<this.maxChars)
{
noOfZero = this.maxChars-noStr.length;
while (noOfZero-->0)
{
noStr += "0";
}
}
if (noStr.substr(-1) == ".")
{
noStr = noStr.substr(0, -1);
}
this.text = isNaN(noStr) ? "" : noStr;
}
}
}
7/29/2010 6:09:57 AM
check your source code in line 177 , you must be setting some String Value to Number.
Do the type conversion to Number
var stringVariable:String= Number(someSting);