简体   繁体   中英

why is this script in as3 not working??

Hi I made this code and I use flash cs5.5

var cijfer_txt:int = parseInt(textarea_text.text);

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

submit.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler_2);

function fl_TapHandler_2(event:TouchEvent):void
{

    switch (cijfer_txt){
    case 1:
    gotoAndStop(12);
    break;
    case 2:
    gotoAndStop(23);
    break;      }

};

but I don't get it why it isn't working, the animation has to go to frame 12 when I fill in "1" and stop and has to got to frame 23 if I fill in "2" and stop but he doesn't do it and I get sick of it!!

Try to set cijfer_txt in fl_TapHandler_2

function fl_TapHandler_2(event:TouchEvent):void
{

    cijfer_txt = parseInt(textarea_text.text);

    switch (cijfer_txt){

    }
}

I think you have problem with debugging so I'll help you:

First: change your code as follows -

var cijfer_txt:int;

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

submit.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler_2);

function fl_TapHandler_2(event:TouchEvent):void
{
    cijfer_txt = parseInt(textarea_text.text);
    trace("in the function, cijfer_txt = "+cijfer_txt);
    switch (cijfer_txt) {
       case 1:
         trace("in case 1");
         gotoAndStop(12);
         break;
       case 2:
         trace("in case 2");
         gotoAndStop(23);
         break;
       default:
         trace("in defaukt");
         break;
      }
}

NOW RUN IT AND WATCH THE CONSOLE\\OUTPUT FOR TRACE OUTPUTS, according to the output you can see what is hapening! trace(); is a very common method Good Luck (Don't forget to mark as accepted if it helped you!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM