色有885 发表于 2009-1-8 11:12:09

实用Flash应用程序—打字练习(4) (1)

5、场景中帧的划分

  把主场景划分为4段循环的帧结构。     4.2.5.1.第一帧,用于初始化全局变量。  fscommand ("fullscreen", "true");
  fscommand ("showmenu", "false");
  baseDepth = 1;
  testDepth = 10;
  menuDepth = 2;
  menux = 118;//菜单的横坐标
  menuy = 102;//菜单的纵坐标
  timeBarWidth = 76;//时间棒的总长度
  startTimer = false;
  typePause = false;
  nowTimer = getTimer();//计时一次
  showType = "menu"; //显示菜单
  menushowFram = true;// 显示背景
  backToFram = false;//是否返回到开始界面
  loadText = false;//是否开始倒入原文
  level = 1;//难度级别为1
  text1 = "";
  text2 = "";
  textLength = 0;
  loopNum = 0;  back = false;
  again = false;
  timeOver = false;
  typeSound = new Sound();
  typeSound.attachSound("type");
  errorSound = new Sound();
  errorSound.attachSound("error");
  typeSoundPlay = true;time = 3;
  errorNum = 0;
  speedNum = 0;
  choose = new String("normalText");
  inputText = choose;
  attachMovie("fram", "fram", baseDepth);//显示开始界面的背景     4.2.5.2  第二帧到第三帧;   第2帧设一个标签“mainLoop":  if(loadText==true)
    gotoAndPlay("loadNum");//跳到下载原文的循环中
  if (showFram == false)
  {
    fram.removeMovieClip();//把背景从屏幕上抹去
    removeMovieClip (showType);//把菜单从屏幕上抹去
    attachMovie("typeSpace", "typeSpace", testDepth);
    gotoAndPlay ("typeLoop");//跳到练习的场景中
  } else
  {
    attachMovie(showType, showType, menuDepth);//跳到另一个菜单中
  }
  _root._x = menux;//设置横坐标
  _root._y = menuy;//设置纵坐标第3帧的代码:
  gotoAndPlay("mainLoop");  4.2.5.3第3个循环段:  从第5帧到第6帧。  第5帧标签“typeLoop";  if (backToFram == true)
  {  //响应在typeSpace剪辑上的按钮BACK的事件返回到开始界面
    removeMovieClip ("typeSpace");
    gotoAndPlay (1);
  }
  if(again==true)//响应在typeSpace剪辑上的按钮AGAIN的事件
  {  //场景不变,重复上一次的练习
    removeMovieClip("showScores");
    text1.scroll=1;
    text2="";
    loopNum=0;
    again=false;
  }//以下的代码是用于练习过程中实时判断,检测我们分为几个小节进行分析。   







                                                                                                   

                                    5、场景中帧的划分

  把主场景划分为4段循环的帧结构。     4.2.5.1.第一帧,用于初始化全局变量。  fscommand ("fullscreen", "true");
  fscommand ("showmenu", "false");
  baseDepth = 1;
  testDepth = 10;
  menuDepth = 2;
  menux = 118;//菜单的横坐标
  menuy = 102;//菜单的纵坐标
  timeBarWidth = 76;//时间棒的总长度
  startTimer = false;
  typePause = false;
  nowTimer = getTimer();//计时一次
  showType = "menu"; //显示菜单
  menushowFram = true;// 显示背景
  backToFram = false;//是否返回到开始界面
  loadText = false;//是否开始倒入原文
  level = 1;//难度级别为1
  text1 = "";
  text2 = "";
  textLength = 0;
  loopNum = 0;  back = false;
  again = false;
  timeOver = false;
  typeSound = new Sound();
  typeSound.attachSound("type");
  errorSound = new Sound();
  errorSound.attachSound("error");
  typeSoundPlay = true;time = 3;
  errorNum = 0;
  speedNum = 0;
  choose = new String("normalText");
  inputText = choose;
  attachMovie("fram", "fram", baseDepth);//显示开始界面的背景     4.2.5.2  第二帧到第三帧;   第2帧设一个标签“mainLoop":  if(loadText==true)
    gotoAndPlay("loadNum");//跳到下载原文的循环中
  if (showFram == false)
  {
    fram.removeMovieClip();//把背景从屏幕上抹去
    removeMovieClip (showType);//把菜单从屏幕上抹去
    attachMovie("typeSpace", "typeSpace", testDepth);
    gotoAndPlay ("typeLoop");//跳到练习的场景中
  } else
  {
    attachMovie(showType, showType, menuDepth);//跳到另一个菜单中
  }
  _root._x = menux;//设置横坐标
  _root._y = menuy;//设置纵坐标第3帧的代码:
  gotoAndPlay("mainLoop");  4.2.5.3第3个循环段:  从第5帧到第6帧。  第5帧标签“typeLoop";  if (backToFram == true)
  {  //响应在typeSpace剪辑上的按钮BACK的事件返回到开始界面
    removeMovieClip ("typeSpace");
    gotoAndPlay (1);
  }
  if(again==true)//响应在typeSpace剪辑上的按钮AGAIN的事件
  {  //场景不变,重复上一次的练习
    removeMovieClip("showScores");
    text1.scroll=1;
    text2="";
    loopNum=0;
    again=false;
  }//以下的代码是用于练习过程中实时判断,检测我们分为几个小节进行分析。   







                                                                                                   

                                      1.让原文文本向上卷动。  if(Key.isDown(Key.PGDN))
  {  
    text1.scroll =1;
  }
  if(Key.isDown(Key.PGUP)){
    text1.scroll-=1;
  }  2.排除SHIFT键码错误。  SHIFT用于大小写转换,但他也有自己的键码值。所以我们必须屏蔽掉SHIFT的返回值:  if(Key.getCode() !=Key.SHIFT )
  {//屏蔽掉SHIFT的返回值后
    var tempText1=text1.charAt(Selection.getBeginIndex()-1);
    var tempText2=text2.charAt(Selection.getBeginIndex()-1);
    if(tempText1 !=tempText2 && textLength1!=text2.length)
    {
      if(Key.getCode() != Key.BACKSPACE)
      {
        errorSound.start(0,1);
      }
      textLength1=text2.length;
    }
    if(tempText1 ==tempText2 && textLength1!=text2.length)
    {
       textLength1=text2.length;
      if(typeSoundPlay==true)
      {
        typeSound.start(0,1);
      }
    }
  } // e
页: [1]
查看完整版本: 实用Flash应用程序—打字练习(4) (1)