Saturday, May 7, 2011

Make a Simple Slideshow in Flash IDE


Make a simple slideshow,we just need to use TimerEvent and TweenLite.
Features maybe not complete,but you can learn how to work with TweenLite.


Step 1: New File
Open Adobe Flash and create an ActionScript 3 Flash file.Save and name it "Main1.fla".



Step 2: Properties
Open the properties and set the FPS to 30 and the stage size to 500 x 375px



Step 3: Photos
Collect three photos and resize to 500 x 375 px.
Import them on the stage.



Step 4: Deploy insatces
Convert your pics to a MovieClip,name them "pic1_mc","pic2_mc","pic3_mc" then align them.
Select "pic1_mc","pic2_mc","pic3_mc" and hit F8 and create a new movieclip called “container_mc” and remember give it a instance name "container_mc"(It contains "pic1_mc","pic2_mc","pic3_mc" )


Deploy your pics in the container_mc


Step 5: Code
Coding on the timeline
//Import greensock tweenlite
import com.greensock.*;
import com.greensock.easing.*;

//Set the Timer,Trigger every every three seconds
var _timer:Timer=new Timer(3000,0);
_timer.addEventListener(TimerEvent.TIMER,onTimer);
_timer.start();

function onTimer(e:Event) {
    //Declare a Point class name it "targetPoint"
    var targetPoint:Point;
    //Set targetPoint according to container_mc.x
    switch (container_mc.x) {
        //when container_mc.x==0,pic1_mc slide to pic2_mc
        case 0:
            targetPoint=new Point(-500,0);
            break;
        //when container_mc.x==-500,pic2_mc slide to pic3_mc
        case -500:
            targetPoint=new Point(-1000,0);
            break;
        //when container_mc.x==-1000,pic3_mc slide to pic1_mc
        case -1000:
            targetPoint=new Point(0,0);
            break;
    }
    //Tween container_mc according to targetPoint
    TweenLite.to(container_mc, 1, 
        {
        x:targetPoint.x,
        y:targetPoint.y,
        ease:Quint.easeOut
        }
    );
}


Step 6: Another way
If you want to add photos in the container_mc,but you don't want to add any code for new photos.
You can change your code below:
import com.greensock.*;
import com.greensock.easing.*;

var allWidth:Number=container_mc.width;
var amount:int=container_mc.numChildren;
var moveX:Number=allWidth/amount;
var maxX:Number=moveX-allWidth;

var _timer:Timer=new Timer(3000,0);
_timer.addEventListener(TimerEvent.TIMER,onTimer);
_timer.start();

function onTimer(e:Event) {
    if(container_mc.x>maxX)
        TweenLite.to(container_mc, 1, {x:container_mc.x-moveX,ease:Quint.easeOut});
    else
        TweenLite.to(container_mc, 1, {x:0,ease:Quint.easeOut});
}


Conclusion
Thanks for reading!I hope you liked this simple tutorial.Here is cs4 versions up on the zip file.

CS4 version:
Simple_Slideshow_vol1.rar
Simple_Slideshow_vol2.rar


.

1 comment:

  1. vimax is a herbal medicine devoted to the men, who serves as the vimax canada permanent and extend appropriate in want, quickly and accurately without side effects and with permanent results, vimax asli has been the choice of international consumers. Vimax PiIls already well known parts of the world and is often used by men to increase male virility and maximize the size of the penis, in order to give satisfaction to their partners. obat pembesar penis Vimax has been recognized by scientists the world as an herbal remedy for pembesar penis and how this increase is no longer a secret mighty man, this is extraordinary usefulness fast, mutually agree and permanent.

    ReplyDelete