Actionscript, Flash

Ken Burns effect With SlideShowPro

This is an implementation of the ken Burns effect into SSP component, the code is not strict at all and should be put on timeline, if you need a class version, let me know.
Take care this code is for FLASH8 and actionscript 2.
All comments are welcome

1) Tweening and bitmap classes
[as]
#include “lmc_tween.as”
import flash.display.BitmapData;
[/as]

2) Static variables initialisation
[as]
// taille de la photo d’origine
ORIGINSCALE = 100;
// redimensionnement maximum
DESTINATIONSCALE = 110;
// Durée totale du tweening
TWEENDURATION = my_ssp.imagePause + my_ssp.imageFade * 2;
// durée du fade
FADEDURATION = my_ssp.imagePause * 1000;
[/as]

3) Object and SSp events and listener
[as]
myListener = new Object ();
myListener.imageData = _imageData;
my_ssp.addEventListener (”imageData”, myListener);
[/as]

4) function called by ssp lisneter each time a new photo is loaded
[as]
function _imageData (eventObject)
{
if (my_ssp.displayMode == ‘Auto’)
{
kenBurnsEffect ();
}
}
[/as]

5) The Ken Burns function
[as]
function kenBurnsEffect ()
{
loader1 = _root.my_ssp.sspro_mc.cont_mc.loader1_mc;
loader2 = _root.my_ssp.sspro_mc.cont_mc.loader2_mc;
//
if (my_ssp.thisLoader == loader1)
{
bitmapize (loader1);
with (loader1)
{
_xscale = ORIGINSCALE;
_yscale = ORIGINSCALE;
tween (['_xscale', '_yscale'], [DESTINATIONSCALE, DESTINATIONSCALE], TWEENDURATION, ‘linear’);
}
}
else if (my_ssp.thisLoader == loader2)
{
bitmapize (loader2);
with (loader2)
{
_xscale = DESTINATIONSCALE;
_yscale = DESTINATIONSCALE;
tween (['_xscale', '_yscale'], [ORIGINSCALE, ORIGINSCALE], TWEENDURATION, ‘linear’);
}
}
}
[/as]

6) function to convert ach loaded photo into a bitmap object, it avoid pixilisation when tweening
[as]
function bitmapize (imgContainer)
{
myBitmap = new BitmapData (imgContainer._width, imgContainer._height, true, 0×00FFFFFF);
myBitmap.draw (imgContainer);
imgContainer.attachBitmap (myBitmap, 1, “auto”, true);
}
[/as]

et voilà


18 Comments

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*Required Fields