AS3 Erreur, help needed!

  • Rika
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Oct 14, 2009
  • Messages: 14
  • Loc: Singapore
  • Status: Offline

Message Novembre 8th, 2009, 9:47 am

Ceci est mon code AS3, cependant cette erreur pour la ligne else (standarweight...txtinches.text)); continue d'afficher jusqu'à 1067: la contrainte implicite d'une valeur de type String à un type indépendant Number. Can anyone help me?


ACTIONSCRIPT Code: [ Select ]
stop();
btn_standard.addEventListener(MouseEvent.CLICK, standard);
function standard(evt:MouseEvent):void {
   gotoAndStop(1);
}
btn_metric.addEventListener(MouseEvent.CLICK, metric);
function metric(evt:MouseEvent):void {
   gotoAndStop(2);
}
 
var standardweight:Number=0;
 
//restrict to numbers and fullstops
txtpounds.restrict = "0-9, . ";
txtinches.restrict = "0-9, . ";
txtkg.restrict = "0-9, . ";
txtmetre.restrict = "0-9, . ";
 
submit_standard.addEventListener(MouseEvent.CLICK, stopUser);
 
function stopUser(evt:MouseEvent):void {
   if (txtpounds.text == "") {
      stage.focus = txtpounds;
   }
   else if (txtinches.text == "") {
      stage.focus = txtinches;
   }
   else {
      standardweight = Number(txtpounds.text)/((txtinches.text)*(txtinches.text));
         if (standardweight <= 18.5) {
            gotoAndStop(3);
         }
         else if(18.5 >= standardweight <= 24.9) {
            gotoAndStop(4);
         }
         else if(25 >= standardweight <= 29.9) {
            gotoAndStop(5);
         }
         else if(30 >= standardweight <= 34.9) {
            gotoAndStop(6);
         }
         else if(35 >= standardweight <= 39.9) {
            gotoAndStop(7);
         }
         else if(standardweight >= 40) {
            gotoAndStop(7);
         }
         else {
            gotoAndStop(1);
         }
   }
}
  1. stop();
  2. btn_standard.addEventListener(MouseEvent.CLICK, standard);
  3. function standard(evt:MouseEvent):void {
  4.    gotoAndStop(1);
  5. }
  6. btn_metric.addEventListener(MouseEvent.CLICK, metric);
  7. function metric(evt:MouseEvent):void {
  8.    gotoAndStop(2);
  9. }
  10.  
  11. var standardweight:Number=0;
  12.  
  13. //restrict to numbers and fullstops
  14. txtpounds.restrict = "0-9, . ";
  15. txtinches.restrict = "0-9, . ";
  16. txtkg.restrict = "0-9, . ";
  17. txtmetre.restrict = "0-9, . ";
  18.  
  19. submit_standard.addEventListener(MouseEvent.CLICK, stopUser);
  20.  
  21. function stopUser(evt:MouseEvent):void {
  22.    if (txtpounds.text == "") {
  23.       stage.focus = txtpounds;
  24.    }
  25.    else if (txtinches.text == "") {
  26.       stage.focus = txtinches;
  27.    }
  28.    else {
  29.       standardweight = Number(txtpounds.text)/((txtinches.text)*(txtinches.text));
  30.          if (standardweight <= 18.5) {
  31.             gotoAndStop(3);
  32.          }
  33.          else if(18.5 >= standardweight <= 24.9) {
  34.             gotoAndStop(4);
  35.          }
  36.          else if(25 >= standardweight <= 29.9) {
  37.             gotoAndStop(5);
  38.          }
  39.          else if(30 >= standardweight <= 34.9) {
  40.             gotoAndStop(6);
  41.          }
  42.          else if(35 >= standardweight <= 39.9) {
  43.             gotoAndStop(7);
  44.          }
  45.          else if(standardweight >= 40) {
  46.             gotoAndStop(7);
  47.          }
  48.          else {
  49.             gotoAndStop(1);
  50.          }
  51.    }
  52. }
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Novembre 8th, 2009, 9:47 am

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • Avatar de l’utilisateur
  • Inscription: Mai 28, 2003
  • Messages: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Message Novembre 8th, 2009, 12:27 pm

Lisez-le et voir si cela fait sens pour vous
http://www.wuup.co.uk/as3-quick-tips-st ... ice-versa/

Im pas très bon, avec la conversion de chaînes en nombres et vice-versa, etc, mais je peux vous dire thats pourquoi vous obtenez cette erreur. Son une incompatibilité de type de données et que vous essayez d'effectuer un calcul sur ce qui ne fonctionne pas.

Malheureusement je ne peux pas vous dire exactement comment l'écrire correctement à ce stade. I suck at maths. Même dans lol Flash.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Rika
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Oct 14, 2009
  • Messages: 14
  • Loc: Singapore
  • Status: Offline

Message Novembre 8th, 2009, 6:05 pm

Merci du lien fixe le problème!

Afficher de l'information

  • Total des messages de ce sujet: 3 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 42 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC