Hi everyone I’m new in both languages… I found a example for scrambled numbers in JavaScript and HTML I would like to convert that code into ActionScript code, the languages looks similar for me but when I compile it in Flash Builder nothing happens… I would like to understand how to do the example but in ActionScript and MXML code…
JavaScript code parts that I don’t understand how to do it in ActionScript:
function check(value)
{
if ( value != Math.round(value) )
alert("You must enter an integer in this input box.");
}
function generate( )
{
var minval = parseInt(**document.form.min.value**);
if ( isNaN(minval) || minval != parseFloat(**document.form.min.value**))
And To implement this with TextInput in HTML:
<INPUT TYPE="text" NAME="**min**" VALUE="" ONCHANGE="check(**this.value**)">
I don’t know hot to leave it in AS3 and MXML…
I tried:
public function generate()
{
var minval = parseInt(**min**);
if ( isNaN(minval) || minval != parseFloat(**min**))
{
and the MXML:
<s:TextInput id="**min**" change="**check(this)**" />
As you can see I’m very lost…
<![CDATA[This code works the way you want I guess.
Please bear something in mind that the parseInt function ignores any trailing non numeric characters after a valid integer. Say for example, the code works if you enter “a” first, but fails if u enter 1a. More details about the function can be found here
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package.html#parseInt()