photoalbum_class.as

来自「这是《Flash MX编程与创意实现》的源代码」· AS 代码 · 共 37 行

AS
37
字号
/*
  PhotoAlbum class
  
  This is an extremely simple class used to illustrate 
  the process and key OOP principles used in designing
  a custom object.
  
  Discussed in Chapter 2 of 
  Robert Penner's Programming Macromedia Flash MX
  
  http://www.robertpenner.com/profmx
*/

_global.PhotoAlbum = function (holder_mc, photos_arr) {
    this.holder = holder_mc;
    this.photos = photos_arr;
    this.showPhotoAt (0);
};

PhotoAlbum.prototype.showPhotoAt = function (n) {
    var lastIndex = this.photos.length - 1;
    if (n > lastIndex) n = 0;
    else if (n < 0) n = lastIndex;
    this.index = n;
    this.holder.loadMovie (this.photos[this.index]);
};

PhotoAlbum.prototype.next = function () {
    this.showPhotoAt (this.index + 1);
};

PhotoAlbum.prototype.prev = function () {
    this.showPhotoAt (this.index - 1);
};


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?