相冊類_Flash教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:條件循環(huán)的使用前兩天,看到有個朋友發(fā)帖子問if和do..while之間的區(qū)別,當時只回答了一點:即do..while至少執(zhí)行一次;而if可能一次都不執(zhí)行就跳出循環(huán)。其他的就想不起來了
PhotoAlbum構造函數(shù): 創(chuàng)建相冊:(1)用戶指定一個位置用來存放照片。
(2)用戶指定照片URL的清單。
(3)用戶發(fā)出“創(chuàng)建相冊”的命令,提供位置和清單。
(4)創(chuàng)建相冊。
(5)顯示相冊中的第一張照片。
_global.PhotoAlbum=function(holder_mc,photos_arr){
this.holder=holder_mc;
this.photos=photos_arr;
this.showPhotosAt(0);
}; showPhotoAt()方法的定義: 顯示特定下標的照片:
(1)用戶發(fā)出顯示特定下標的照片的命令并給出一個數(shù)字。
(2)顯示該下標的照片。
(3)假如新數(shù)字對相冊來說太小,顯示最后一張照片。
(4)假如新數(shù)字對相冊來說太大,顯示第一張照片。
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]); }; 下一頁next()方法定義: PhotoAlbum.prototype.next=function(){ this.showPhotoAt(this.index 1); }; 上一頁prev()方法定義: PhotoAlbum.prototype.prev=function(){ this.showPhotoAt(this.index-1); };
PhotoAlbum的使用: this.createEmptyMovieClip("holder_mc",1);
photos_arr=new Array["1.jpg","2.jpg","3,jpg"];
album=new PhotoAlbum(holder_mc,photos_arr); 加入翻頁: 在按鈕1內(nèi):
on(release) {
album.prev();
}; 在按鈕2內(nèi):
on(release){
album.next();
};
分享:Class結構教程1.最基本的Class定義方面我不多說了,就舉個例子直接開始:classFlash8{privatevaruser:String;//定義變量privatevarpass:String;privatevarage:N
相關Flash教程:
。