• 可以控制多层嵌套的movieClip播放和暂停


    1. package com.sina.utils
    2. {
    3.         import flash.display.MovieClip;
    4.        
    5.         /**
    6.          * .主要是解决一个单帧影片剪辑无法暂停和重播的问题
    7.          * @author ant-zhangpeng@staff.sina.com.cn
    8.          */
    9.         public class MovieClipManage
    10.         {
    11.                 private var _target:MovieClip;
    12.                 private var _type:String;
    13.                
    14.                 /**
    15.                  * 构造函数
    16.                  * @param        mc  目标影片剪辑
    17.                  */
    18.                 public function MovieClipManage(mc:MovieClip = null)
    19.                 {
    20.                         _target = mc;
    21.                 }
    22.                
    23.                 private function goto(mc:MovieClip, frame:int = 0):void
    24.                 {
    25.                         if(!(mc is MovieClip))
    26.                         {
    27.                                 throw new Error("MovieClipManage::: 目标不是movieClip");
    28.                                 return;
    29.                         }
    30.                         frame > 0 ?  mc[_type](frame) :  mc[_type]();
    31.                        
    32.                         if (mc.numChildren > 0)
    33.                         {
    34.                                 for (var i:int = 0; i < mc.numChildren; i++ )
    35.                             {
    36.                                         if (mc.getChildAt(i) as MovieClip)
    37.                                         {
    38.                                                 goto(mc.getChildAt(i) as MovieClip, frame);
    39.                                         }
    40.                                 }
    41.                         }
    42.                        
    43.                 }
    44.                
    45.                 //--------------------API---------------------------------
    46.                 /**
    47.                  * 暂停影片剪辑
    48.                  */
    49.                 public function pause(target:MovieClip = null):void
    50.                 {
    51.                         _type = "stop";
    52.                         target = target || _target;
    53.                         goto(target);
    54.                 }
    55.                
    56.                 /**
    57.                  * 恢复暂停影片剪辑
    58.                  */
    59.                 public function play(target:MovieClip = null):void
    60.                 {
    61.                         _type = "play";
    62.                         target = target || _target;
    63.                         goto(target);
    64.                 }
    65.                
    66.                 /**
    67.                  * 停止影片剪辑到第一帧
    68.                  */
    69.                 public function stop(target:MovieClip = null):void
    70.                 {
    71.                         _type = "gotoAndStop";
    72.                         target = target || _target;
    73.                         goto(target, 1);
    74.                 }
    75.                
    76.                 /**
    77.                  * 重播影片剪辑
    78.                  */
    79.                 public function replay(target:MovieClip = null):void
    80.                 {
    81.                         _type = "gotoAndPlay";
    82.                         target = target || _target;
    83.                         goto(target, 1);
    84.                 }
    85.         }
    86.        
    87. }
  • 相关阅读:
    初识WEB:输入URL之后的故事
    ecshop ecmall shopex
    .net 4.5如何使用Async和Await进行异步编程
    C#中yield用法
    安装Ecshop首页出现报错:Only variables should be passed by referen
    Ecshop安装过程中的的问题:cls_image::gd_version()和不支持JPEG
    javascript 操作dom
    使用X-UA-Compatible来设置IE浏览器兼容模式
    createDocumentFragment
    ckfinder在IE10,IE9中的弹出框不能选择,或者不能上传解决方法
  • 原文地址:https://www.cnblogs.com/czjone/p/1861792.html
Copyright © 2020-2023  润新知