chris_c super acro


Age : 38 Inscrit le : 18 Nov 2007 Messages : 5193
| |
Admin administrateur


Inscrit le : 11 Déc 2005 Messages : 9751 Localisation : Toulouse
| Sujet: Re: toString Sam 10 Mai - 2:12 | |
| | chris_c a écrit: | Ca marche dans Flash mais pas avec mtasc, comment corriger ca:
| Code: | couleur = "0x"+String(a.toString(16))+String(c.toString(16))+String(b.toString(16));
|
a,b,c sont des variables number entre 1 et 255 |
Effectivement ça ne fonctionne pas ! Ici, cela affiche "0xabc"
Je ne sais pas faire de façon simple. Je ferais des fonctions :
| Code: | static function toHex2(a:Number):String{
var a1 = Math.floor(a/16); var a0 = a-(a1*16); return toHex1(a1)+toHex1(a0); } static function toHex1(a):String{ if(a < 10) return a; if(a==10) return "a"; if(a==11) return "b"; if(a==12) return "c"; if(a==13) return "d"; if(a==14) return "e"; return "f"; } |
ceci n'est pas testé, c'est un 1er jet...
Phildes _________________
|
|
Kwelmès programmeur


Age : 17 Inscrit le : 29 Sep 2007 Messages : 899 Localisation : dans les profondeurs insondables de l'infinité cosmique
| Sujet: Re: toString Sam 10 Mai - 12:03 | |
| j'avais testé toString(16) et ça marchait à l'exportation:
var couleur=bmp.getPixel(100,200); _root.debug.text=couleur.toString(16);
par contre ça soulignait dans mtasc... comme la fonction splice _________________
 http://www.kwlms.o-n.fr http://www.kwlms.o-n.fr http://www.kwlms.o-n.fr |
|