1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
load_gallery("flashmo_183_photo_list.xml");
// Copyright © flashmo.com
// Developed by Min Thu
// Tweener
// http://code.google.com/p/tweener/
import caurina.transitions.Tweener;
var auto_play:Boolean = false; // true (OR) false
var auto_play_duration:Number = 1000; // 1 second equals 1000
var folder:String = "photos/";
var timer:Timer;
var i:Number;
var tn:Number = 0;
var pic:Number = 0;
var previous_no:Number = 0;
var current_no:Number = 0;
var tween_duration:Number = 0.8; // seconds
var total:Number;
var flashmo_xml:XML;
var flashmo_photo_list = new Array();
var photo_group:MovieClip = new MovieClip();
this.addChild(photo_group);
this.addChild(photo_title);
this.addChild(photo_description);
this.addChild(photo_button);
this.addChild(flashmo_play);
this.addChild(flashmo_pause);
this.addChild(flashmo_previous);
this.addChild(flashmo_next);
photo_button.alpha = 0;
photo_button.buttonMode = true;
photo_group.x = flashmo_photo_area.x;
photo_group.y = flashmo_photo_area.y;
photo_group.mask = flashmo_photo_area;
photo_group_info.text = "";
photo_title.text = "";
photo_description.text = "";
if( auto_play == true )
{
flashmo_pause.visible = true;
flashmo_play.visible = false;
}
else
{
flashmo_pause.visible = false;
flashmo_play.visible = true;
}
function load_gallery(xml_file:String):void
{
var xml_loader:URLLoader = new URLLoader();
xml_loader.load( new URLRequest( xml_file ) );
xml_loader.addEventListener(Event.COMPLETE, create_photo_rotator);
}
function create_photo_rotator(e:Event):void
{
flashmo_xml = new XML(e.target.data);
total = flashmo_xml.photo.length();
for( i = 0; i < total; i++ )
{
flashmo_photo_list.push( {
filename: flashmo_xml.photo[i].filename.toString(),
title: flashmo_xml.photo[i].title.toString(),
description: flashmo_xml.photo[i].description.toString(),
url: flashmo_xml.photo[i].url.toString(),
target: flashmo_xml.photo[i].target.toString()
} );
}
load_photo();
photo_title.text = flashmo_xml.photo[0].title.toString();
photo_description.text = flashmo_xml.photo[0].description.toString();
}
function load_photo():void
{
var pic_request:URLRequest = new URLRequest( folder + flashmo_photo_list[pic].filename );
var pic_loader:Loader = new Loader();
pic_loader.load(pic_request);
pic_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, on_photo_progress);
pic_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_photo_loaded);
pic++;
}
function on_photo_progress(e:ProgressEvent):void
{
var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);
photo_group_info.text = "Loading image... " + pic + " of " + total + " (" + percent + "%)";
}
function on_photo_loaded(e:Event):void
{
if( pic < total )
{
load_photo();
}
else if( auto_play == true )
{
photo_group_info.text = "";
timer = new Timer(auto_play_duration);
timer.addEventListener(TimerEvent.TIMER, auto_play_timer);
timer.start();
}
else
{
photo_group_info.text = "";
}
var flashmo_pic_bm:Bitmap = new Bitmap();
var flashmo_pic_mc:MovieClip = new MovieClip();
flashmo_pic_bm = Bitmap(e.target.content);
flashmo_pic_bm.smoothing = true;
flashmo_pic_mc.addChild( flashmo_pic_bm );
flashmo_pic_mc.name = "flashmo_pic_" + photo_group.numChildren;
if( photo_group.numChildren > 0 )
flashmo_pic_mc.alpha = 0;
photo_group.addChild( flashmo_pic_mc );
}
function auto_play_timer(te:TimerEvent):void
{
current_no++;
change_photo();
}
function change_photo():void
{
if( current_no >= photo_group.numChildren )
current_no = 0;
if( current_no < 0 )
current_no = photo_group.numChildren - 1;
Tweener.addTween( photo_group.getChildAt(previous_no), { alpha: 0, time: tween_duration,
transition: "easeInOutQuart" } );
Tweener.addTween( photo_group.getChildAt(current_no), { alpha: 1, time: tween_duration,
transition: "easeInOutQuart" } );
previous_no = current_no;
photo_title.text = flashmo_photo_list[current_no].title;
photo_description.text = flashmo_photo_list[current_no].description;
}
photo_button.addEventListener( MouseEvent.MOUSE_OVER, pic_over );
photo_button.addEventListener( MouseEvent.MOUSE_OUT, pic_out );
photo_button.addEventListener( MouseEvent.CLICK, pic_click );
function pic_over(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
Tweener.addTween( mc, { alpha: 0.2, time: tween_duration, transition: "easeIn" } );
}
function pic_out(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
Tweener.addTween( mc, { alpha: 0, time: tween_duration, transition: "easeOut" } );
}
function pic_click(e:MouseEvent):void
{
navigateToURL( new URLRequest( flashmo_photo_list[current_no].url ),
flashmo_photo_list[current_no].target );
}
flashmo_play.addEventListener( MouseEvent.CLICK, pic_play );
flashmo_pause.addEventListener( MouseEvent.CLICK, pic_pause );
flashmo_previous.addEventListener( MouseEvent.CLICK, pic_previous );
flashmo_next.addEventListener( MouseEvent.CLICK, pic_next );
function pic_play(e:MouseEvent):void
{
flashmo_pause.visible = true;
flashmo_play.visible = false;
timer = new Timer(auto_play_duration);
timer.addEventListener(TimerEvent.TIMER, auto_play_timer);
timer.start();
}
function pic_pause(e:MouseEvent):void
{
flashmo_pause.visible = false;
flashmo_play.visible = true;
timer.removeEventListener(TimerEvent.TIMER, auto_play_timer);
}
function pic_previous(e:MouseEvent):void
{
current_no--;
change_photo();
}
function pic_next(e:MouseEvent):void
{
current_no++;
change_photo();
} |
Partager