zoukankan      html  css  js  c++  java
  • 关于设计:Actionscript 载入外部文件与打印处理

    7-1 显示动画影片的载入完成百分比

    this.stop();
    var ballArray=[ball1_mc,ball2_mc,ball3_mc,ball4_mc,ball5_mc,ball6_mc,ball7_mc,ball8_mc,ball9_mc,ball10_mc];
    var myInfo:LoaderInfo=this.loaderInfo;

    function chgBall(num){
     for (var i=0;i<num;i++){
      ballArray[i].gotoAndStop(2);
     }
    }

    this.addEventListener("enterFrame", initHandler);
    function initHandler(event:Event){
     var myTbytes=myInfo.bytesTotal; 
     var myLoaded=myInfo.bytesLoaded;
     var percent = Math.floor(myLoaded / myTbytes * 100);
         msg_txt.text=percent + "%";
     if (percent>=100){
      //this.gotoAndStop(2);
      chgBall(10);
     }else if (percent>=90){
      chgBall(9);
     }else if(percent>=80){
      chgBall(8);
     }else if(percent>=70){
      chgBall(7);
     }else if(percent>=60){
      chgBall(6);
     }else if(percent>=50){
      chgBall(5);
     }else if(percent>=40){
      chgBall(4);
     }else if(percent>=30){
      chgBall(3);
     }else if(percent>=20){
      chgBall(2);
     }else if(percent>=10){
      chgBall(1);
     }
    }

    7-2 显示动画影片的载入状态(时间倒数,完成与总载入大小)

    this.stop();
    var myInfo:LoaderInfo=this.loaderInfo;

    function setNum(num){
     return Math.round(num/1000);
    }

    this.addEventListener("enterFrame", initHandler);
    function initHandler(event:Event){
     var myTbytes=myInfo.bytesTotal; 
     var myLoaded=myInfo.bytesLoaded;
     var percent = myLoaded/myTbytes;
     if (percent<=1){
      var time = (myTbytes-myLoaded)/(myLoaded/getTimer());
     }
     bar_mc.bar.scaleX=percent;
     total_txt.text=setNum(myTbytes);
     loaded_txt.text=setNum(myLoaded);
     time_txt.text=setNum(time) + "sec";
    }

    7-3 告知使用者外部文件的数据载入剩余量

    var myLoader:Loader = new Loader();
     var url:String = "DSC_0249.JPG";
     var urlReq:URLRequest = new URLRequest(url);
     myLoader.load(urlReq);
     pic_mc.addChild(myLoader);
     
    this.addEventListener("enterFrame", initHandler);
    function initHandler(event:Event){
     var myInfo:LoaderInfo=myLoader.contentLoaderInfo;
     myLoaded=myInfo.bytesLoaded;
     myTbytes=myInfo.bytesTotal;
     remainNUM=Math.round((myTbytes-myLoaded)/1000);
     state_txt.text=remainNUM+"kb";

    7-4 载入外部文本文件

    var word:URLLoader = new URLLoader(); 
    var wordreq:URLRequest = new URLRequest("strawberry .txt");
    word.load(wordreq);

    word.addEventListener(Event.COMPLETE, onTEXTFileLoaded);
    function onTEXTFileLoaded(me:Event){
           in_txt.text = word.data;
    }

  • 相关阅读:
    Opengl编程指南第三章:视图
    OpenGL编程指南第四章:颜色
    OpenGL编程指南第七章:显示列表
    推荐:字体、排版简明入门
    OpenGL编程指南第八章:绘制像素、位图、字体和图像
    推荐:字体、排版简明入门
    OpenGL编程指南第五章:光照
    转载一篇密码学基本介绍
    ARM_异常和中断学习笔记
    ARM指令学习笔记
  • 原文地址:https://www.cnblogs.com/cnsg/p/2510976.html
Copyright © 2011-2022 走看看