Echo Px Web Technologies Pvt. Ltd.

Flash Pixel Transition Effect Tutorial

  1. Open a new flash 8 professional document & set the desired background color, width and height of the document. Keep the frame rate at 12fps.
  2. 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'.
  3. 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'.
  4. 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.
  5. 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.

  1. import flash.display.*
  2. import flash.geom.*
  3. var effects:Array = new Array({label:"Pixels", data:"pixels"})
  4. myCombo.dataProvider = effects
  5. effectListener = {}
  6. effectListener.ref = this
  7. effectListener.change = function(evt:Object){
  8. var action:String = evt.target.selectedItem.data
  9. this.ref.transition = action //set transition
  10. clearInterval(run) //re-create set Interval
  11. }
  12. myCombo.addEventListener("change", effectListener)
  13. //Gallery array, bitmaps on library
  14. var images:Array = new Array("img1", "img2", "img3")
  15. var current:Number = 0 //image counter
  16. //general holder
  17. a = BitmapData.loadBitmap(images[current])
  18. w = a.width
  19. h = a.height
  20. container = this.createEmptyMovieClip("container", 1)
  21. container.createEmptyMovieClip("holder", 1)
  22. container.holder.attachBitmap(a, new Matrix())
  23. container.holder._x = 0
  24. container.holder._y = 0
  25. //default transition
  26. transition = "pixels";
  27. //Begin gallery showcase
  28. run = setInterval(nextImg, 3000, this)
  29. function nextImg(where){
  30. where.current = ((where.current+1)>where.images.length-1)?0 : where.current+1
  31. where[where.transition](where.current)
  32. }
  33.  
  34. //Transition **************************************************************
  35.  
  36. function pixels(nr){
  37. //Bitmap data for next image
  38. trans = BitmapData.loadBitmap(images[nr])
  39. //capture data for pixelDisolve method
  40. var area = trans.rectangle
  41. var p = area.topLeft
  42. percent = 0
  43. transarea = w*h
  44. //change mixing pixels
  45. this.onEnterFrame = function(){
  46. //percentage of pixels to mix
  47. var numPixels=( ( w * h ) / 100 ) * percent;
  48. percent+=5 //increment percentage
  49. a.pixelDissolve(trans , area , p , 0, numPixels);
  50. //clear onEnterFrame when finish
  51. if(numPixels>=(w*h)) {
  52. delete this.onEnterFrame
  53. //copy next image
  54. a.draw(container.holder)
  55. //release memory
  56. trans.dispose()
  57. }
  58. }
  59. }

  1. Create a new layer above 'functions' layer & name it as 'prototypes'. Enter the following code at frame1 in this layer in the actions panel.

  1. stop()
  2. MovieClip.prototype.linearMove = function(dist:Number){
  3. this.walked = 0
  4. this.onEnterFrame = function(){
  5. this._x+=this.velx
  6. this._y+=this.vely
  7. this.walked+=int(this.vel)
  8. if(this.walked>dist) {
  9. delete this.onEnterFrame
  10. this.removeMovieClip()
  11. }
  12. }
  13. }
  14. MovieClip.prototype.turnOut = function(dir){
  15. this.counter = 0
  16. this.onEnterFrame = function(){
  17. this._rotation+=dir
  18. this.counter+=Math.abs(dir)
  19. if(this.counter>=100) {
  20. delete this.onEnterFrame
  21. this.removeMovieClip()
  22. }
  23. }
  24. }

  1. Save and test the movie.