- Open a new flash 8 professional document & set the desired background color, width and height of the document. Keep the frame rate at 12fps.
- Import all the images (I have considered only 3 images for this tutorial) required for animation to the library.(Library panel shortcut key => ctrl+l) Let all the images be of the same dimensions. Right click on the 1st image in library panel and click on 'linkage…'. In the linkage properties window enter the 'Identifier' as 'img1' and check the 'Export for ActionScript' & 'Export in first frame' boxes. Similarly enter the linkage properties for 2nd image as 'img2' and for 3rd image as 'img3'.
- Drag the 1st image to the stage at frame1 and align it to the left and top edge. This can be done by pressing ctrl+alt+1 and ctrl+alt+4. Rename this layer to 'stage'.
- While the playhead is still at frame1 press F8. This opens a 'Convert to Symbol' window. Enter the name as 'Photo' and select Type as 'Movie clip'. Choose the top left corner point for Registration. Click on OK.
- Create a new layer above the 'stage' layer and name it 'functions'. Enter the following code in this layer at frame1 in the actions panel.
import flash.display.*
import flash.geom.*
var effects:Array = new Array({label:"Pixels", data:"pixels"})
myCombo.dataProvider = effects
effectListener = {}
effectListener.ref = this
effectListener.change = function(evt:Object){
var action:String = evt.target.selectedItem.data
this.ref.transition = action //set transition
clearInterval(run) //re-create set Interval
}
myCombo.addEventListener("change", effectListener)
//Gallery array, bitmaps on library
var images:Array = new Array("img1", "img2", "img3")
var current:Number = 0 //image counter
//general holder
a = BitmapData.loadBitmap(images[current])
w = a.width
h = a.height
container = this.createEmptyMovieClip("container", 1)
container.createEmptyMovieClip("holder", 1)
container.holder.attachBitmap(a, new Matrix())
container.holder._x = 0
container.holder._y = 0
//default transition
transition = "pixels";
//Begin gallery showcase
run = setInterval(nextImg, 3000, this)
function nextImg(where){
where.current = ((where.current+1)>where.images.length-1)?0 : where.current+1
where[where.transition](where.current)
}
//Transition **************************************************************
function pixels(nr){
//Bitmap data for next image
trans = BitmapData.loadBitmap(images[nr])
//capture data for pixelDisolve method
var area = trans.rectangle
var p = area.topLeft
percent = 0
transarea = w*h
//change mixing pixels
this.onEnterFrame = function(){
//percentage of pixels to mix
var numPixels=( ( w * h ) / 100 ) * percent;
percent+=5 //increment percentage
a.pixelDissolve(trans , area , p , 0, numPixels);
//clear onEnterFrame when finish
if(numPixels>=(w*h)) {
delete this.onEnterFrame
//copy next image
a.draw(container.holder)
//release memory
trans.dispose()
}
}
}
- Create a new layer above 'functions' layer & name it as 'prototypes'. Enter the following code at frame1 in this layer in the actions panel.
stop()
MovieClip.prototype.linearMove = function(dist:Number){
this.walked = 0
this.onEnterFrame = function(){
this._x+=this.velx
this._y+=this.vely
this.walked+=int(this.vel)
if(this.walked>dist) {
delete this.onEnterFrame
this.removeMovieClip()
}
}
}
MovieClip.prototype.turnOut = function(dir){
this.counter = 0
this.onEnterFrame = function(){
this._rotation+=dir
this.counter+=Math.abs(dir)
if(this.counter>=100) {
delete this.onEnterFrame
this.removeMovieClip()
}
}
}
- Save and test the movie.