详细内容
 
当前位置
Flash课件制作仿百度文库阅读PDF文件
作者:管理员    发布于:2012-07-15 21:06:07    文字:【】【】【
Flash课件制作仿百度文库阅读PDF文件
此文档阅读器使用简单原理制作而成,制作此在线文档阅读器需有后台支持,后台使用SWFTOOLS中的PDFTOSWF工具进行转换,再使用AS3加载生成的SWF文件,下面看具体AS3源码吧,后台源码就不贴了,各位朋友可去网上搜...


 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5 
 6     public class child extends MovieClip
 7     {
 8         public function child()
 9         {
10             // constructor code
11         }
12     }
13 }
 

cnway_logo.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5     public class cnway_logo extends MovieClip
 6     {
 7         public function cnway_logo()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

down_listbtn.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5     public class down_listbtn extends MovieClip
 6     {
 7         public function down_listbtn()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

downpage_btn.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5     public class downpage_btn extends MovieClip
 6     {
 7         public function downpage_btn()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

fangda_btn.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5     public class fangda_btn extends MovieClip
 6     {
 7         public function fangda_btn()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

Mouse_hand.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5     public class Mouse_hand extends MovieClip
 6     {
 7         public function Mouse_hand()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

screen.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5     public class screen extends MovieClip
 6     {
 7         public function screen()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

Stages.as

 

 1 package ui
 2 {
 3     import flash.display.Stage;
 4 
 5     public class Stages
 6     {
 7         static private var mystages:Stage;
 8         public function Stages():void
 9         {
10             
11         }
12         static public function get stagess():Stage
13         {
14             return mystages;
15         }
16         static public function set stagess(sg:Stage):void
17         {
18             mystages = sg;
19         }
20     }
21 }
 

suoxiao_btn.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5     public class suoxiao_btn extends MovieClip
 6     {
 7         public function suoxiao_btn()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

up_listbtn.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4 
 5     public class up_listbtn extends MovieClip
 6     {
 7         public function up_listbtn()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

uppage_btn.as

 

 1 package ui
 2 {
 3     import flash.display.MovieClip;
 4     
 5     public class uppage_btn extends MovieClip
 6     {
 7         public function uppage_btn()
 8         {
 9             // constructor code
10         }
11     }
12 }
 

loading.as

 

 1 package ui
 2 {
 3     import flash.display.Shape;
 4     import flash.display.Sprite;
 5     import flash.display.StageAlign;
 6     import flash.display.StageScaleMode;
 7     import flash.events.Event;
 8     import flash.geom.Matrix;
 9     import flash.utils.Timer;
10     import flash.events.TimerEvent;
11     import flash.display.Loader;
12     import flash.net.URLRequest;
13 
14     public class loading extends Sprite
15     {
16         private var nums:int = 12;
17         private var m2:Matrix = new Matrix();
18         private var m:Matrix =  new Matrix();
19         private var Abar:Array = new Array();
20         private var segAngle:Number;
21         private var seg:Number;
22         private var j:Number = 0;
23         private var timer:Timer = new Timer(50);
24         private var logo:cnway_logo = new cnway_logo();
25         public function loading()
26         {
27             init();
28         }
29         private function init():void
30         {
31             this.addChild(logo);
32             logo.x = - 30;
33             logo.y = 55;
34             initBar();
35         }
36         private function initBar():void
37         {
38             segAngle = 2 * Math.PI / this.nums;
39             seg = 1 / this.nums;
40             for (var i:int = 0; i < this.nums; i++)
41             {
42                 var bar:Shape=new Shape();
43                 Abar[i] = bar;
44                 bar.graphics.beginFill(0x000000);
45                 bar.graphics.drawRoundRect(0,0,10,3,4,4);
46                 bar.graphics.endFill();
47                 this.addChild(bar);
48                 bar.x = bar.y = 100;
49                 m.identity();
50                 m.translate(7,-1);
51                 m.rotate(segAngle*i);
52                 m.translate(-7,1);
53                 m2.identity();
54                 m2.translate(100,100);
55                 m.concat(m2);
56                 bar.transform.matrix = m;
57             }
58             timer.addEventListener(TimerEvent.TIMER,alphaHalder);
59             timer.start();
60         }
61 
62         private function alphaHalder(evt:TimerEvent):void
63         {
64             for (var i:int = 0; i < this.nums; i++)
65             {
66                 var bar:Shape = Abar[i] as Shape;
67                 bar.alpha = j;
68                 if (j == 1.0833333333333333)
69                 {
70                     j = 0;
71                 }
72                 j +=  seg;
73             }
74         }
75     }
76 }
 

control包:

TipTextFiled.as

 

 1 package control
 2 {
 3     import flash.display.MovieClip;
 4     import flash.text.TextField;
 5     import flash.text.TextFormat;
 6     import ui.Stages;
 7     import flash.display.Stage;
 8     import flash.display.Sprite;
 9 
10     public class TipTextFiled extends MovieClip
11     {
12         private static var mytext:TextField = new TextField();
13         private static var myformat:TextFormat = new TextFormat();
14         private static var myshape:Sprite = new Sprite();
15         private static var mystage:Stage = Stages.stagess;
16         public function TipTextFiled():void
17         {
18         }
19         public static function addTipTextFiled(myname:String):void
20         {
21             mytext = new TextField();
22             myshape = new Sprite();
23             myformat.font = "Times New Roman";
24             myformat.color = 0x000000;
25             myformat.size = 12;
26             mytext.text = myname;
27             mytext.width = mytext.textWidth + 8;
28             mytext.height = mytext.textHeight + 6;
29             mytext.setTextFormat(myformat);
30             myshape.graphics.beginFill(0xfbfbfb);
31             myshape.graphics.lineStyle(1,0x000000,0.2);
32             myshape.graphics.drawRect(0,0,mytext.textWidth + 4,mytext.textHeight);
33             myshape.graphics.endFill();
34             myshape.addChild(mytext);
35             mytext.x = 1;
36             mytext.y = -2;
37             mystage.addChild(myshape);
38             if (mystage.mouseX >= mystage.width - myshape.width)
39             {
40                 myshape.x = mystage.mouseX - myshape.width / 2;
41             }
42             else
43             {
44                 myshape.x = mystage.mouseX;
45             }
46             myshape.y = mystage.mouseY + myshape.height;
47         }
48         public static function removeTipTextFiled():void
49         {
50             try
51             {
52                 myshape.removeChild(mytext);
53                 mytext = null;
54                 mystage.removeChild(myshape);
55                 myshape = null;
56             }
57             catch (e)
58             {
59 
60             }
61         }
62     }
63 }
 

Scrollbar.as

 

package control
{
 import flash.display.Sprite;
 import flash.events.MouseEvent;
 import flash.events.Event;
 import ui.Stages;
 import flash.geom.Rectangle;
 import flash.display.Stage;
 import flash.geom.Matrix;
 import flash.display.SpreadMethod;
 import flash.display.GradientType;
 import flash.display.MovieClip;

 public class Scrollbar extends Sprite
 {
  public var obj:MovieClip;//需进行滚动的对象
  public var scrollmask:Sprite;//遮罩对象
  public var scrollheight:Number;//滚动条高度
  public var scrolltextnum:int;//文本显示行数
  public var textspeed:int;//文本滚动速度(行/像素)
  public var Scroll:Sprite;//自定义滚动条对象
  public var bar:Sprite;//滑块
  public var up:Sprite;//向上按钮
  public var down:Sprite;//向下按钮
  public var bg:Sprite;//滑槽
  public var num:int;//计算滑块高度所用
  public var scrollwidth:Number;//左右滚动条宽度
  public var left_right_scroll:Sprite;//左右自定义滚动条对象
  public var left_right_bar:Sprite;//左右滚动条滑块
  public var left:Sprite;//向左按钮
  public var right:Sprite;//向右按钮
  public var left_right_bg:Sprite;//左右滚动条滑槽
  public var num2:int;//计算左右滑块宽度

  private var displayobject:Stage;//接受stage
  private var bars:Number;//滑块可滑动距离
  private var bars2:Number;
  private var rect:Rectangle;//滑块可拖动范围
  private var rect2:Rectangle;
  private var i:int = 0;
  private var i2:int = 0;
  private var n:Number;
  private var n2:Number;
  ////构造器函数/////
  public function Scrollbar():void
  {
  }
  /////初始化函数/////
  public function init():void
  {
   displayobject = Stages.stagess;
   if (checkhide())
   {
    addEventListeners();
   }
   else
   {
    bar.visible = false;
   }
   setxy();
  }
  public function init2():void
  {
   displayobject = Stages.stagess;
   if (check_leftandright_hide())
   {
    leftandright_addEventListeners();
   }
   else
   {
    left_right_bar.visible = false;
   }
   setxy2();
  }
  ///判断是否显示滚动条等///
  private function checkhide():Boolean
  {
   if (Scroll != null)
   {
    if (obj.height <= scrollmask.height)
    {
     return false;
    }
    return true;
   }
   return false;
  }
  ///判断是否显示左右滚动条等///
  private function check_leftandright_hide():Boolean
  {
   if (left_right_scroll != null)
   {
    if (obj.width <= scrollmask.width)
    {
     return false;
    }
    return true;
   }
   return false;
  }
  ///设置滚动条高度,对象遮罩等////
  private function setxy():void
  {
   bar.y = bg.y;
   if (bar.height >= 10)
   {
    num *=  50;
    n = (obj.height - scrollmask.height)/(num+100);
    bar.height = scrollmask.height - (obj.height - scrollmask.height)/n;
   }
   bars = bg.height - bar.height;
   obj.mask = scrollmask;
   rect = new Rectangle(bar.x,bg.y,0,bg.height - bar.height - 30);
  }
  private function setxy2():void
  {
   left_right_bar.x = left_right_bg.x;
   if (left_right_bar.width >= 10)
   {
    num2 *=  50;
    n2 = (obj.width - scrollmask.width)/(num2+100);
    left_right_bar.width = scrollmask.width - (obj.width - scrollmask.width)/n2;
   }
   bars2 = left_right_bg.width - left_right_bar.width;
   obj.mask = scrollmask;
   rect2 = new Rectangle(left_right_bg.x,left_right_bar.y,left_right_bg.width - left_right_bar.width - 30,0);
  }
  ///当被滚动对象更新时,而需要改变滚动条状态,调用此方法///
  public function update(num:int):void
  {
   if (checkhide())
   {
    num *=  20;
    i++;
    bar.visible = true;
    if (bar.height >= 10)
    {
     n = (obj.height - scrollmask.height)/(num+10);
     bar.height = scrollmask.height - (obj.height - scrollmask.height)/n;
    }
    bar.y = bg.y + bg.height - bar.height;
    bar.y +=  bars * textspeed /(obj.height - scrollmask.height);
    updatebar();
    bars = bg.height - bar.height;
    rect = new Rectangle(bar.x,bg.y + 0.5,0,bg.height - bar.height);
    if (i == 1)
    {
     bar.visible = true;
     addEventListeners();
    }
   }
   else
   {
    bar.visible = false;
   }
  }
  ///当被滚动对象更新时,而需要改变左右滚动条状态,调用此方法///
  public function update2(num:int):void
  {
   if (check_leftandright_hide())
   {
    num *=  10;
    i2++;
    left_right_bar.visible = true;
    if (left_right_bar.width >= 10)
    {
     n2 = (obj.width - scrollmask.width)/(num+10);
     left_right_bar.width = scrollmask.width - (obj.width - scrollmask.width)/n2;
    }
    left_right_bar.x = left_right_bg.x + left_right_bg.width - left_right_bar.width;
    left_right_bar.x +=  bars2 * textspeed /(obj.width - scrollmask.width);
    updatebar2();
    bars2 = left_right_bg.width - left_right_bar.width;
    rect2 = new Rectangle(left_right_bg.x,left_right_bar.y,left_right_bg.width - left_right_bar.width,0);
    if (i2 == 1)
    {
     left_right_bar.visible = true;
     leftandright_addEventListeners();
    }
   }
   else
   {
    left_right_bar.visible = false;
   }
  }
  ///为滚动条添加监听事件////
  private function addEventListeners():void
  {
   bar.addEventListener(MouseEvent.MOUSE_DOWN,barclick);
   bar.addEventListener(MouseEvent.MOUSE_UP,barup);
   displayobject.addEventListener(MouseEvent.MOUSE_UP,barup);
   up.addEventListener(MouseEvent.MOUSE_DOWN,upclick);
   down.addEventListener(MouseEvent.MOUSE_DOWN,downclick);
   Scroll.addEventListener(MouseEvent.MOUSE_WHEEL,mousewheel);
   displayobject.addEventListener(MouseEvent.MOUSE_WHEEL,mousewheel);
  }
  ///为左右滚动条添加监听事件///;
  private function leftandright_addEventListeners():void
  {
   left_right_bar.addEventListener(MouseEvent.MOUSE_DOWN,left_right_barclick);
   left_right_bar.addEventListener(MouseEvent.MOUSE_UP,left_right_barup);
   displayobject.addEventListener(MouseEvent.MOUSE_UP,left_right_barup);
   left.addEventListener(MouseEvent.MOUSE_DOWN,leftclick);
   right.addEventListener(MouseEvent.MOUSE_DOWN,rightclick);
  }
  ///鼠标点击滑块方法///;
  private function barclick(evt:MouseEvent):void
  {
   bar.startDrag(false,rect);
   bar.addEventListener(Event.ENTER_FRAME,bar_enter_frame);
  }
  private function left_right_barclick(evt:MouseEvent):void
  {
   left_right_bar.startDrag(false,rect2);
   left_right_bar.addEventListener(Event.ENTER_FRAME,bar_enter_frame2);
  }
  ///鼠标点击滑块释放方法///;
  private function barup(evt:MouseEvent):void
  {
   bar.stopDrag();
   delevent();
  }
  private function left_right_barup(evt:MouseEvent):void
  {
   left_right_bar.stopDrag();
   delevent2();
  }
  ///鼠标点击向上按钮方法///
  private function upclick(evt:MouseEvent):void
  {
   if (checkbar())
   {
    bar.y -= bars * textspeed /(obj.height-scrollmask.height);//滑块移动的距离=滚动对象滚动的像素*滑块可移动的总距离/(被滚动对象的高度-遮罩的高度(即显示范围的高度))
    objrun(0-textspeed);
    //调用方法移动对象;
    updatebar();//校正滑块位置
   }
  }
  private function leftclick(evt:MouseEvent):void
  {
   if (checkbar2())
   {
    left_right_bar.x -= bars2 * textspeed /(obj.width - scrollmask.width);
    objrun2(0-textspeed);
    updatebar2();
   }
  }
  ///鼠标点击向下按钮方法///
  private function downclick(evt:MouseEvent):void
  {
   if (checkbar())
   {
    bar.y +=  bars * textspeed /(obj.height - scrollmask.height);
    objrun(textspeed);
    updatebar();
   }
  }
  private function rightclick(evt:MouseEvent):void
  {
   if (checkbar2())
   {
    left_right_bar.x += bars2 * textspeed /(obj.width - scrollmask.width);
    objrun2(textspeed);
    updatebar2();
   }
  }
  ///鼠标滑轮事件///
  private function mousewheel(evt:MouseEvent):void
  {
   if (evt.delta > 0)
   {
    if (checkbar())
    {
     bar.y -=  bars * textspeed /(obj.height - scrollmask.height);
     objrun(-textspeed);
     updatebar();
    }
   }
   else
   {
    if (checkbar())
    {
     bar.y +=  bars * textspeed /(obj.height - scrollmask.height);
     objrun(textspeed);
     updatebar();
    }
   }
  }
  private function bar_enter_frame(evt:Event):void
  {
   obj.y = scrollmask.y - (bar.y - bg.y)*(obj.height - scrollmask.height)/bars;
   if (obj.y > scrollmask.y)
   {
    obj.y = scrollmask.y;
   }
   else if (obj.y < (scrollmask.y - obj.height + scrollmask.height))
   {
    obj.y = scrollmask.y - obj.height + scrollmask.height;
   }
  }
  private function bar_enter_frame2(evt:Event):void
  {
   obj.x = scrollmask.x - (left_right_bar.x - left_right_bg.x)*(obj.width - scrollmask.width)/bars2;
   if (obj.x > scrollmask.x)
   {
    obj.x = scrollmask.x;
   }
   else if (obj.x < (scrollmask.x - obj.width + scrollmask.width))
   {
    obj.x = scrollmask.x - obj.width + scrollmask.width;
   }
  }
  private function objrun(i:Number):void
  {
   obj.y -=  i;
   if (obj.y > scrollmask.y)
   {
    obj.y = scrollmask.y;
   }
   else if (obj.y < (scrollmask.y - obj.height + scrollmask.height))
   {
    obj.y = scrollmask.y - obj.height + scrollmask.height;
   }
  }
  private function objrun2(i:Number):void
  {
   obj.x -=  i;
   if (obj.x > scrollmask.x)
   {
    obj.x = scrollmask.x;
   }
   else if (obj.x < (scrollmask.x - obj.width + scrollmask.width))
   {
    obj.x = scrollmask.x - obj.width + scrollmask.width;
   }
  }
  private function checkbar():Boolean
  {
   if (bar.y >= bg.y && bar.y <= (bars + bg.y))
   {
    return true;
   }
   return false;
  }
  private function checkbar2():Boolean
  {
   if (left_right_bar.x >= left_right_bg.x && left_right_bar.x <= (bars2 + left_right_bg.x))
   {
    return true;
   }
   return false;
  }
  ///删除卸载事件侦听///
  private function updatebar():void
  {
   if (bar.y < bg.y)
   {
    bar.y = bg.y;
   }
   else if (bar.y >(bg.y + bg.height - bar.height))
   {
    bar.y = bg.y + bg.height - bar.height;
   }
  }
  private function updatebar2():void
  {
   if (left_right_bar.x < left_right_bg.x)
   {
    left_right_bar.x = left_right_bg.x;
   }
   else if (left_right_bar.x >(left_right_bg.x + left_right_bg.width - left_right_bar.width))
   {
    left_right_bar.x = left_right_bg.x + left_right_bg.width - left_right_bar.width;
   }
  }
  private function delevent2():void
  {
   left_right_bar.removeEventListener(Event.ENTER_FRAME,bar_enter_frame2);
  }
  private function delevent():void
  {
   bar.removeEventListener(Event.ENTER_FRAME,bar_enter_frame);
  }
 }
}

 

文档类:Main.as

 

package 
{
 import flash.display.MovieClip;
 import flash.display.Loader;
 import flash.events.Event;
 import flash.net.URLRequest;
 import flash.events.MouseEvent;
 import flash.display.StageAlign;
 import flash.display.StageScaleMode;
 import com.*;
 import ui.*;
 import control.*;
 import flash.display.Sprite;
 import flash.text.TextField;
 import flash.text.TextFormat;
 import flash.events.IOErrorEvent;
 import flash.events.ProgressEvent;
 import flash.display.Shape;
 import flash.net.URLLoader;

 public class Main extends MovieClip
 {
  private var mymovie:MovieClip;
  private var num:int;
  private var http://www.cnblogs.com/zhoujunfeng2011/admin/String;
  private var myloading:loading;
  private var up_btn:uppage_btn = new uppage_btn();
  private var down_btn:downpage_btn = new downpage_btn();
  private var fd_btn:fangda_btn = new fangda_btn();
  private var sx_btn:suoxiao_btn = new suoxiao_btn();
  private var up_scrollbtn:up_listbtn = new up_listbtn();
  private var down_scrollbtn:down_listbtn = new down_listbtn();
  private var left_scrollbtn:up_listbtn = new up_listbtn();
  private var right_scrollbtn:down_listbtn = new down_listbtn();
  private var left_right_bg:Sprite;
  private var left_right_bar:Sprite;
  private var left_right_scrollcont:Sprite = new Sprite();
  private var mymouse:Mouse_hand = new Mouse_hand();
  private var mc_width:int = 595;
  private var mc_height:int = 841;
  private var myscrollbar:Scrollbar;
  private var scrollmask:Sprite;
  private var scrollcont:Sprite = new Sprite();
  private var bg:Sprite;
  private var bar:Sprite;
  private var nums:int = 0;
  private var PageTotal:TextField = new TextField();
  private var Paged:TextField = new TextField();
  private var textformat:TextFormat = new TextFormat();
  private var progress_txt:TextField = new TextField();
  private var count:int = 0;
  private const my_y:Array = [30,-20,-70,-120,-170,-220,-270,-320,-370,-420,-470];
  private const my_x:Array = [0,-50,-100,-150,-200,-250,-300,-350,-400,-450,-500];
  private var mu_child:child = new child();
  private var screen_child:screen = new screen();
  private var myx:Number;
  public function Main():void
  {
   //stage.align = StageAlign.LEFT;
   stage.scaleMode = StageScaleMode.SHOW_ALL;
   Stages.stagess = this.stage;
   init();
  }
  private function init():void
  {
   var myurlloader:URLLoader = new URLLoader();
   myurlloader.addEventListener(Event.COMPLETE,xmlcom);
   myurlloader.load(new URLRequest("http://files.cnblogs.com/zhoujunfeng2011/SWF/data.xml"));
  }
  private function xmlcom(evt:Event):void
  {
   var myxml:XML = new XML(evt.target.data);
   var txt1:TextField = new TextField();
   var txt2:TextField = new TextField();
   var txt3:TextField = new TextField();
   var format:TextFormat = new TextFormat();
   format.font = "Times New Roman";
   format.color = 0x000000;
   format.size = 24;
   txt1.text = "第";
   txt1.selectable = false;
   txt2.text = "页 共";
   txt2.selectable = false;
   txt3.text = "页";
   txt3.selectable = false;
   textformat.font = "Times New Roman";
   textformat.color = 0x000000;
   textformat.size = 14;
   txt1.setTextFormat(textformat);
   txt2.setTextFormat(textformat);
   txt3.setTextFormat(textformat);
   myscrollbar = new Scrollbar();
   addChild(up_btn);
   up_btn.x = 470;
   up_btn.y = 15;
   up_btn.buttonMode = true;
   addChild(down_btn);
   down_btn.x = up_btn.x + 40;
   down_btn.y = up_btn.y;
   down_btn.buttonMode = true;
   addChild(fd_btn);
   fd_btn.x = up_btn.x - 80;
   fd_btn.y = up_btn.y;
   fd_btn.buttonMode = true;
   addChild(sx_btn);
   sx_btn.x = fd_btn.x + sx_btn.width + 10;
   sx_btn.y = fd_btn.y;
   sx_btn.buttonMode = true;
   addChild(txt1);
   txt1.x = 224;
   txt1.y = 5;
   txt1.width = txt1.textWidth + 6;
   addChild(txt2);
   txt2.x = txt1.x + 50;
   txt2.y = txt1.y;
   txt2.width = txt2.textWidth + 6;
   addChild(txt3);
   txt3.x = txt2.x + 70;
   txt3.y = txt2.y;
   txt3.width = txt3.textWidth + 6;
   PageTotal.text = "0";
   Paged.text = "0";
   PageTotal.setTextFormat(textformat);
   Paged.setTextFormat(textformat);
   PageTotal.selectable = false;
   Paged.selectable = false;
   addChild(Paged);
   Paged.x = 250;
   Paged.y = 5;
   Paged.width = Paged.textWidth + 20;
   addChild(PageTotal);
   PageTotal.x = 318;
   PageTotal.y = 5;
   PageTotal.width = PageTotal.textWidth + 20;
   addChild(screen_child);
   screen_child.x = 560;
   screen_child.y = 16;
   screen_child.buttonMode = true;
   addChild(mu_child);
   mu_child.x = 590;
   mu_child.y = 15;
   mu_child.buttonMode = true;
   url = encodeURI(myxml.child("swf")[0].@url);
   var myloader:Loader = new Loader();
   myloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progress_function);
   myloader.contentLoaderInfo.addEventListener(Event.COMPLETE,com);
   myloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,load_error);
   myloader.load(new URLRequest(url));
   myloading = new loading();
   addChild(myloading);
   myloading.x = this.stage.stageWidth / 3;
   myloading.y = this.stage.stageHeight / 3;
   addChild(progress_txt);
   progress_txt.selectable = false;
   progress_txt.setTextFormat(format);
   progress_txt.text = count + "%";
   progress_txt.x = myloading.x + 130;
   progress_txt.y = myloading.y + 95;
  }
  private function progress_function(evt:ProgressEvent):void
  {
   count = (evt.bytesLoaded/evt.bytesTotal) * 100;
   progress_txt.text = count + "%";
  }
  private function load_error(evt:IOErrorEvent):void
  {
   progress_txt.textColor = 0xff0000;
   progress_txt.text = "加载失败!";
  }
  private function DrawInMask():Sprite
  {
   var sp:Sprite = new Sprite();
   sp.graphics.beginFill(0x000000);
   sp.graphics.drawRect(0,0,mc_width,mc_height);
   sp.graphics.endFill();

   return sp;
  }
  private function DrawInbg(w:Number,h:Number):Sprite
  {
   var sp:Sprite = new Sprite();
   sp.graphics.beginFill(0xcccccc);
   sp.graphics.drawRect(0,0,w,h);
   sp.graphics.endFill();

   return sp;
  }
  private function DrawInBar(w:Number,h:Number):Sprite
  {
   var sp:Sprite = new Sprite();
   sp.graphics.beginFill(0x666666);
   sp.graphics.drawRect(0,0,w,h);
   sp.graphics.endFill();

   return sp;
  }
  private function com(evt:Event):void
  {
   removeChild(myloading);
   myloading = null;
   removeChild(progress_txt);
   progress_txt = null;
   evt.target.content.removeEventListener(ProgressEvent.PROGRESS,progress_function);
   evt.target.content.removeEventListener(Event.COMPLETE,com);
   evt.target.content.removeEventListener(IOErrorEvent.IO_ERROR,load_error);
   mymovie = MovieClip(evt.target.content);
   mymovie.width = mc_width;
   mymovie.height = mc_height;
   num = mymovie.totalFrames;
   addChild(mymovie);
   mymovie.y = 30;
   mymovie.cacheAsBitmap = true;
   UIinit();
   up_btn.addEventListener(MouseEvent.CLICK,up_click);
   up_btn.addEventListener(MouseEvent.MOUSE_OVER,up_over);
   up_btn.addEventListener(MouseEvent.MOUSE_OUT,up_out);
   down_btn.addEventListener(MouseEvent.CLICK,down_click);
   down_btn.addEventListener(MouseEvent.MOUSE_OVER,down_over);
   down_btn.addEventListener(MouseEvent.MOUSE_OUT,down_out);
   fd_btn.addEventListener(MouseEvent.CLICK,fangda_click);
   fd_btn.addEventListener(MouseEvent.MOUSE_OVER,fangda_over);
   fd_btn.addEventListener(MouseEvent.MOUSE_OUT,fangda_out);
   sx_btn.addEventListener(MouseEvent.CLICK,suoxiao_click);
   sx_btn.addEventListener(MouseEvent.MOUSE_OVER,suoxiao_over);
   sx_btn.addEventListener(MouseEvent.MOUSE_OUT,suoxiao_out);
   mymovie.addEventListener(MouseEvent.CLICK,mymovie_click);
   mu_child.addEventListener(MouseEvent.CLICK,mu_child_click);
   mu_child.addEventListener(MouseEvent.MOUSE_OVER,mu_child_over);
   mu_child.addEventListener(MouseEvent.MOUSE_OUT,mu_child_out);
   screen_child.addEventListener(MouseEvent.CLICK,screen_child_click);
   screen_child.addEventListener(MouseEvent.MOUSE_OVER,screen_child_over);
   screen_child.addEventListener(MouseEvent.MOUSE_OUT,screen_child_out);
  }
  private function UIinit():void
  {
   PageTotal.text = String(num);
   Paged.text = String(mymovie.currentFrame);
   scrollmask = DrawInMask();
   scrollmask.x = mymovie.x;
   scrollmask.y = mymovie.y;
   bg = DrawInbg(15,mymovie.height - 32);
   bar = DrawInBar(15,mymovie.height - 200);
   scrollcont.addChild(up_scrollbtn);
   up_scrollbtn.x = this.stage.stageWidth - up_scrollbtn.width / 2 + 0.5;
   up_scrollbtn.y = 40;
   scrollcont.addChild(bg);
   bg.x = this.stage.stageWidth - bg.width;
   bg.y = up_scrollbtn.y + up_scrollbtn.height / 2 -3;
   scrollcont.addChild(down_scrollbtn);
   down_scrollbtn.x = up_scrollbtn.x;
   down_scrollbtn.y = bg.y + bg.height + 6;
   scrollcont.addChild(bar);
   bar.x = bg.x;
   bar.y = bg.y;
   addChild(scrollcont);
   left_right_bg = DrawInbg(580,15);
   left_right_bar = DrawInBar(580,15);
   left_right_scrollcont.addChild(left_scrollbtn);
   left_scrollbtn.rotation = 270;
   left_scrollbtn.x = left_scrollbtn.width/2;
   left_scrollbtn.y = 880;
   left_right_scrollcont.addChild(left_right_bg);
   left_right_bg.x = left_scrollbtn.width - 4;
   left_right_bg.y = left_scrollbtn.y - left_scrollbtn.height/2 + 0.5;
   left_right_scrollcont.addChild(right_scrollbtn);
   right_scrollbtn.rotation = 270;
   right_scrollbtn.x = left_right_bg.x + left_right_bg.width + 6;
   right_scrollbtn.y = left_scrollbtn.y;
   left_right_scrollcont.addChild(left_right_bar);
   left_right_bar.x = left_right_bg.x;
   left_right_bar.y = left_right_bg.y;
   addChild(left_right_scrollcont);
   myscrollbar.obj = mymovie;
   myscrollbar.scrollmask = scrollmask;
   myscrollbar.scrollheight = mymovie.height - 63;
   myscrollbar.textspeed = 10;
   myscrollbar.bg = bg;
   myscrollbar.bar = bar;
   myscrollbar.up = up_scrollbtn;
   myscrollbar.down = down_scrollbtn;
   myscrollbar.num = nums;
   myscrollbar.Scroll = scrollcont;
   myscrollbar.left = left_scrollbtn;
   myscrollbar.right = right_scrollbtn;
   myscrollbar.left_right_bar = left_right_bar;
   myscrollbar.left_right_bg = left_right_bg;
   myscrollbar.num2 = nums;
   myscrollbar.left_right_scroll = left_right_scrollcont;
   myscrollbar.init();
   myscrollbar.init2();
  }
  private function up_click(evt:MouseEvent):void
  {
   if (mymovie.currentFrame != 1)
   {
    mymovie.prevFrame();
   }
   else
   {
    mymovie.gotoAndStop(num);
   }
   Paged.text = String(mymovie.currentFrame);
  }
  private function up_over(evt:MouseEvent):void
  {
   TipTextFiled.addTipTextFiled("上一页");
  }
  private function up_out(evt:MouseEvent):void
  {
   TipTextFiled.removeTipTextFiled();
  }
  private function down_click(evt:MouseEvent):void
  {
   if (mymovie.currentFrame != num)
   {
    mymovie.nextFrame();
   }
   else
   {
    mymovie.gotoAndStop(1);
   }
   Paged.text = String(mymovie.currentFrame);
  }
  private function down_over(evt:MouseEvent):void
  {
   TipTextFiled.addTipTextFiled("下一页");
  }
  private function down_out(evt:MouseEvent):void
  {
   TipTextFiled.removeTipTextFiled();
  }
  private function fangda_click(evt:MouseEvent):void
  {
   if (mymovie.width < mc_width + 1000 || mymovie.height < mc_height + 1000)
   {
    nums++;
    mymovie.width +=  100;
    mymovie.height +=  100;
    mymovie.x = my_x[nums];
    mymovie.y = my_y[nums];
    myscrollbar.update(nums);
    myscrollbar.update2(nums);
   }
  }
  private function fangda_over(evt:MouseEvent):void
  {
   TipTextFiled.addTipTextFiled("放大");
  }
  private function fangda_out(evt:MouseEvent):void
  {
   TipTextFiled.removeTipTextFiled();
  }
  private function suoxiao_click(evt:MouseEvent):void
  {
   if (mymovie.width > mc_width || mymovie.height > mc_height)
   {
    nums--;
    mymovie.width -=  100;
    mymovie.height -=  100;
    mymovie.x = my_x[nums];
    mymovie.y = my_y[nums];
    myscrollbar.update(nums);
    myscrollbar.update2(nums);
   }
  }
  private function suoxiao_over(evt:MouseEvent):void
  {
   TipTextFiled.addTipTextFiled("缩小");
  }
  private function suoxiao_out(evt:MouseEvent):void
  {
   TipTextFiled.removeTipTextFiled();
  }
  private function mymovie_click(evt:MouseEvent):void
  {
   if (int(Paged.text) != mymovie.currentFrame)
   {
    Paged.text = String(mymovie.currentFrame);
   }
  }
  private function mu_child_click(evt:MouseEvent):void
  {
   switch (stage.displayState)
   {
    case "normal" :
     stage.displayState = "fullScreen";
     break;
    case "fullScreen" :
    default :
     stage.displayState = "normal";
     break;
   }
  }
  private function mu_child_over(evt:MouseEvent):void
  {
   switch (stage.displayState)
   {
    case "normal" :
     TipTextFiled.addTipTextFiled("全屏显示");
     break;
    case "fullScreen" :
    default :
     TipTextFiled.addTipTextFiled("退出全屏");
     break;
   }
  }
  private function mu_child_out(evt:MouseEvent):void
  {
   TipTextFiled.removeTipTextFiled();
  }
  private function screen_child_click(evt:MouseEvent):void
  {
   if(mymovie.width != mc_width || mymovie.height != mc_height)
   {
    nums = 0;
    mymovie.x = 0;
    mymovie.y = 30;
    mymovie.width = mc_width;
    mymovie.height = mc_height;
    myscrollbar.update(nums);
    myscrollbar.update2(nums);
   }
  }
  private function screen_child_over(evt:MouseEvent):void
  {
   TipTextFiled.addTipTextFiled("适屏");
  }
  private function screen_child_out(evt:MouseEvent):void
  {
   TipTextFiled.removeTipTextFiled();
  }
 }
}
脚注信息
版权所有 Copyright(C)2008-2015 龙腾动画(北京龙腾创星科技有限公司) 京ICP备16063988号-3       本站关键词:flash动画制作 

 
QQ在线咨询
咨询热线
010-57477990
7*24咨询热线
13701141129