zoukankan      html  css  js  c++  java
  • 移动的云朵

     1 package antCodes
     2 {
     3     import flash.display.Sprite;
     4     import flash.utils.getDefinitionByName;
     5 
     6     public class SampleCloud extends Sprite
     7     {
     8         //笔者习惯以双下划线开头的属性表示与库中元件相关
     9         private var __CloudA:Class;
    10         private var __CloudB:Class;
    11         private var __Sky:Class;
    12         public function SampleCloud() {
    13             initView();
    14             var sky:Sprite = new __Sky();
    15             //三朵云彩,使用基类CloudMovieClip做为类型
    16             var cloudABig    :CloudMovieClip = new __CloudA();
    17             var cloudASmall    :CloudMovieClip = new __CloudA();
    18             var cloudB        :CloudMovieClip = new __CloudB();
    19             //分别调整三朵云彩的位置、大小和速度
    20             cloudABig.speed = 1.5;
    21             cloudABig.x = 300;
    22             
    23             cloudASmall.speed = 1;
    24             cloudASmall.scaleX = 0.5;            
    25             cloudASmall.scaleY = 0.5;
    26             cloudASmall.x = 200;
    27             cloudASmall.y = 125;
    28             cloudASmall.alpha = 0.5;
    29                         
    30             cloudB.y = 150;
    31             cloudB.x = 500;
    32             cloudB.speed = 0.5;
    33             //加入显示列表
    34             addChild(sky);
    35             addChild(cloudB);
    36             addChild(cloudABig);
    37             addChild(cloudASmall);            
    38         }        
    39         private function initView():void {
    40             __CloudA = getDefinitionByName("CloudA") as Class;
    41             __CloudB = getDefinitionByName("CloudB") as Class;
    42             __Sky      = getDefinitionByName("SkySprite") as Class;
    43         }
    44         
    45     }
    46 }
     1 package antCodes
     2 {
     3     import flash.display.MovieClip;
     4     import flash.events.Event;
     5     public class CloudMovieClip extends MovieClip
     6     {
     7         private var _speed:Number = 1;
     8         //speed是云彩移动的速度
     9         public function CloudMovieClip(){
    10             super();
    11             //添加动画效果
    12             addEventListener(Event.ENTER_FRAME, move);
    13         }
    14         public function set speed(nS:Number):void {
    15             _speed = nS;
    16         }
    17         //每帧的云彩移动
    18         private function move(evt:Event):void {
    19             this.x -= _speed;
    20         }        
    21     }
    22 }
  • 相关阅读:
    多线程 介绍
    AE中如何获取曲线的一部分(转)
    friday
    THU
    MON
    SAT
    周三
    TUE
    绝对遗憾!
    monday
  • 原文地址:https://www.cnblogs.com/finger/p/movingCloud.html
Copyright © 2011-2022 走看看