The multiplication in as2
hi dears
when i trace this code :
The answer is 14.
but this code:
The answer is 12!
i want use 2th code in to input text field, how fix it?
please check the source:
Attached Files
.
Hi,
Hers a wacky way of doing it with keeping to your set up !!!
PHP Code:
input . restrict = "0-9" ;
input . maxChars = 3 ;
var ziro = 0 ;
var TheText = "000" ;
total . text = TheText ;
input . text = TheText ;
goto_btn . onPress = function()
{
setVerse = input . text ;
if ( setVerse . length < 3 )
{
trace ( "add another number" );
}
if ( setVerse > 111 )
{
total . text = TheText ;
input . text = TheText ;
setVerse = ziro ;
}
else
{
if ( setVerse > 99 )
{
setVerse = setVerse ;
trace ( setVerse );
ShowResult ();
}
if ( setVerse > 9 && setVerse < 100 )
{
setVerse = setVerse . substring ( 1 , input . text . length );
trace ( setVerse );
ShowResult ();
}
if ( setVerse < 10 )
{
setVerse = setVerse . substring ( 2 , input . text . length );
trace ( setVerse );
ShowResult ();
}
}
};
function ShowResult ()
{
Mult = setVerse * 2 ;
trace ( Mult );
if ( Mult > 99 )
{
total . text = Mult ;
}
if ( Mult > 9 && Mult < 100 )
{
total . text = "0" + Mult ;
}
if ( Mult < 9 )
{
total . text = "00" + Mult ;
}
}
Try this:
PHP Code:
function format_number ( num : String ): Number {
if ( typeof ( num ) == "number" ) {
return - 1 ;
}
my_str = "" ;
setnum = false ;
var my_array = num . split ( "" );
for (var i = 0 ; i < my_array . length ; i ++) {
if ( my_array [ i ]> 0 ) {
setnum = true ;
}
if ( setnum == true ) {
my_str = my_str + my_array [ i ];
}
}
return Number ( my_str );
}
var my_num = "014" ;
trace ( 1 * format_number ( my_num ));
poltuda
Originally Posted by
fruitbeard
Hi,
Hers a wacky way ...
thanks dear fruitbeard
you fix 2*014 but the 1th code'2*14' has error!
what am i doing to disble ziro in Beginning of word? its mean user cant type ziro in Beginning of word?
Originally Posted by
poltuda
Try this:
poltuda
thanks dear poltuda
your code is very useful and work very good
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width