Monday, December 20, 2010

Adobe flash CS5 -actionscript 3.0 -- Simple photo Album


1) Open Flash Professional CS5 :ActionScript3.0
2) File ->New->Template->Media Playback->Simple Photo Album
 3) There are four frames available, default picture 1, 2 3, 4, you can see four black dots in Image/Titles
4) click each dot
click File->import-> Import to stage
if you have more than four pictures, click insert->timeline->frame, click File->import->import to stage
5) click Control->Test Movie->In Flash Professional
6) click F9
you can see the source code, default:
Learn HTML

// USER CONFIG SETTINGS =====
var autoStart:Boolean = false; //true, false
var secondsDelay:Number = 2; // 1-60
// END USER CONFIG SETTINGS
// EVENTS =====
playPauseToggle_mc.addEventListener(MouseEvent.CLICK, fl_togglePlayPause);
function fl_togglePlayPause(evt:MouseEvent):void
{
if(playPauseToggle_mc.currentLabel == "play")
{
  fl_startSlideShow();
  playPauseToggle_mc.gotoAndStop("pause");
}
else if(playPauseToggle_mc.currentLabel == "pause")
{
  fl_pauseSlideShow();
  playPauseToggle_mc.gotoAndStop("play");
}
}
next_btn.addEventListener(MouseEvent.CLICK, fl_nextButtonClick);
prev_btn.addEventListener(MouseEvent.CLICK, fl_prevButtonClick);
function fl_nextButtonClick(evt:MouseEvent):void
{
if(playPauseToggle_mc.currentLabel == "pause")
{
  fl_pauseSlideShow();
  playPauseToggle_mc.gotoAndStop("play");
}
fl_nextSlide();
}
function fl_prevButtonClick(evt:MouseEvent):void
{
{
  fl_pauseSlideShow();
  playPauseToggle_mc.gotoAndStop("play");
}
fl_prevSlide();
}
var currentImageID:Number;
var slideshowTimer:Timer;
var appInit:Boolean;
function fl_slideShowNext(evt:TimerEvent):void
{
fl_nextSlide();
}
// END EVENTS

// FUNCTIONS AND LOGIC =====
function fl_pauseSlideShow():void
{
slideshowTimer.stop();
}
function fl_startSlideShow():void
{
slideshowTimer.start();
}
function fl_nextSlide():void
{
currentImageID++;
if(currentImageID > totalFrames)
{
  currentImageID = 1;
}
gotoAndStop(currentImageID);
}
function fl_prevSlide():void
{
currentImageID--;
if(currentImageID <= 0)
{
  currentImageID = totalFrames;
}
gotoAndStop(currentImageID);
}
if(autoStart == true)
{
   fl_startSlideShow();
   playPauseToggle_mc.gotoAndStop("pause");
} else {
  gotoAndStop(1);
}
function initApp(){
currentImageID = 0;
slideshowTimer = new Timer((secondsDelay*1000), 0);
slideshowTimer.addEventListener(TimerEvent.TIMER, fl_slideShowNext);
slideshowTimer.start();
    playPauseToggle_mc.gotoAndStop("pause");
}
if(appInit != true){
initApp();
appInit = true;
}
// END FUNCTIONS AND LOGIC

8.  File->export My flash  result: click >> to see next picture


No comments:

Post a Comment