Flash

Flash Action script Menu

1. Open a new document in flash.
2. Draw a cube as like below using pen tool or line tool.

flash-action-pen-or-line-tool
image-947

3. Convert the cube into movieclip and name it as “cube1” as instance name.
4. On roll over on cube some animation has to happen. So right click on it, select “edit in place”.
5. Separate cube outline and top in different layers (inside the movieclip).
6. Convert cube top into movieclip, press f6 on 3rd key frame and give classic tween, like that give f6 on 6th frame and apply classic tween. On the 3rd key frame movieclip apply some color effect. Here I gave tint.
7. Fill side faces of cube on both side in different layers and repeat step 6 for both side faces.
flash-action-side-faces
image-948

8. For menu animation, draw on arrow edged rectangle in new layer and convert it into movieclip. Give flip effect by using classic tween.

flash-action-arrow-edged-rectangle
image-949

9. For text, create another layer. So inside the cube1 movieclip your layers should be like below.
flash-action-another-layer
image-950

10. Similarly create remaining 5 cubes in same layer as like above. Give cube instance name as cube1, cube2, cube3 …. Cube6.
11. Create layer-2. Draw a cube again with stroke. Convert it to button and right click on it, select “edit in place”. Give blank key frame in “up, over, down”. On hit frame, place the cube.
flash-action-frame
image-951

12. Come to the main scene, select button then press F9 to write the following actionscript:
on (rollOver) {
_root.mouse_over_cube1 = true;
}
on (rollOut) {
_root.mouse_over_cube1 = fstartlse;
}
13. Repeat the step 11 and 12 for all cubes. Make sure that each cube is in different layer.
14. So totally you will have seven layers in main scene.
15. Create one layer-8 to write the following action script on key frame:
_root.cube1.onEnterFrame = function() {
if (mouse_over_cube1) {
_root.cube1.nextFrame();
} else {
_root.cube1.prevFrame();
}
};
_root.cube2.onEnterFrame = function() {
if (mouse_over_cube2) {
_root.cube2.nextFrame();
} else {
_root.cube2.prevFrame();
}
};
_root.cube3.onEnterFrame = function() {
if (mouse_over_cube3) {
_root.cube3.nextFrame();
} else {
_root.cube3.prevFrame();
}
};
_root.cube4.onEnterFrame = function() {
if (mouse_over_cube4) {
_root.cube4.nextFrame();
} else {
_root.cube4.prevFrame();
}
};
_root.cube5.onEnterFrame = function() {
if (mouse_over_cube5) {
_root.cube5.nextFrame();
} else {
_root.cube5.prevFrame();
}
};
_root.cube6.onEnterFrame = function() {
if (mouse_over_cube6) {
_root.cube6.nextFrame();
} else {
_root.cube6.prevFrame();
}
};

Ctrl + Enter to run the program.

Tags: , , , ,

Create Spot Light Effect Using Flash

1.Open a new document in flash.

2.Import a picture (Ctrl+R) in layer one.

water-falling-image
image-895

3.Change it to movieclip. Go to Properties Panel (Ctrl + F3) and adjust the color as given below.

water-falling-movieclip
image-896

4.Paste the same picture in layer two then convert it to movieclip and give the instance name as top_picture.

water-falling-and-torch-light-effect-convert
image-897

5.Using Photoshop cut the water fall portion and save it in the png format. Import that water fall portion in layer three, change it to movieclip and name it as waterfall.

water-falling-and-torch-light-effect-water-fall-portion
image-898

6.In layer four draw a circle gradient as shown below and convert to movieclip then name it as GradientCircle.

water-falling-circle-gradient
image-899

7.Create a layer five to write the following actionscript:

/**  code for water fall effect   **/
var pt1:Point = new Point(0,0);
var pt2:Point = new Point(0,0);
var perlinOffset:Array = [pt1, pt2];
var bm2:BitmapData=new BitmapData(waterfall.width, waterfall.height);
var disp2:DisplacementMapFilter = new DisplacementMapFilter(bm2,new Point(0,0),1,2,10,0);
var pt3:Point = new Point(0,0);
var pt4:Point = new Point(0,0);
var perlinOffsetFall:Array = [pt3, pt3];
addEventListener(Event.ENTER_FRAME,onFrame);
function onFrame(evt:Event):void {
perlinOffsetFall[0].y -=1;
perlinOffsetFall[1].x -=0.1;
bm2.perlinNoise(20,20,1,99,true,false, 7,false,perlinOffsetFall);
waterfall.filters=[disp2]
}
/**  code for spot light effect   **/
top_picture.cacheAsBitmap = true;
GradientCircle.cacheAsBitmap = true;
top_picture.mask=GradientCircle;
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, mds);
function mds(evt:MouseEvent)
{
GradientCircle.x = mouseX;
GradientCircle.y = mouseY;
}
stage.addEventListener(MouseEvent.MOUSE_DOWN, mss);
function mss(evt:MouseEvent){
top_picture.cacheAsBitmap = false;
}
stage.addEventListener(MouseEvent.MOUSE_UP, mas);
function mas(evt:MouseEvent){
top_picture.cacheAsBitmap = true;
}

Tags: , , , ,

Flash Rotating Globular Photo Gallery

Step-1 Open a new document in flash. Set the background color as black.

Step-2 Create an empty dynamic text box in layer-1 and give the instance name as “box1”. Like that create another empty dynamic text box in the same layer and give instance name as “box2”.

flash-rotating-globular-gallery-1
image-813

Step-3 Collect pictures which you want to put in gallery. Here I have chosen 46 pics. Each image should be in 400X300 pixels for large image and 70X53 for small image.

Step-4 Save large image as pic1, pic2, pic3 …… pic46 and small image as small1, small2 ….. small46.

Note that all your flash documents and images should be in same folder.

Step-5 Import small images to library by File à import à import to library.

Step-6 To view your imported image press Ctrl+L. Library panel will appear on the right hand side. Make a right click on image then go to properties. It will look like below.

	Rotating Globular Gallery
image-814

Step-7 Properties panel box will appear. Check on Linkage à Export for actionscript and give class name as image name without .jpg extension.

Rotating Globular Gallery
image-815

Step-8 Like that do for all 46 images.

Step-9 Create a new layer then select key frame-1 and press F9 to open the actionscript panel and download the  code here then paste inside the panel.

Ctrl+ Enter to run the program.

 

Tags: , ,

Flash Guitar

Let see how to do guitar in flash. You can use this in music instruments websites banner and so on.

Step-1: Open a new document in flash is about 600 X 350 pixels.
Note:  The document properties should be in Flash player 5 and action script 1.0.

Step-2: Import a guitar into the stage.

flash-guitar-1
image-785

Step-3: Draw a line on guitar as like its strings and change it to Button (F8).

flash-guitar-2
image-786

Step-4: Select the string and press F to write the following action script.
on (rollOver) {
g = new Sound(this);
g.attachSound(“st1”);       // st1 is the identifier name. You can change it as by your convenient.
g.start(0,1);
}

Step-5: Make a double click on button to edit. Now give F6 to copy the up key frame in over key frame. Now change it to movie clip and edit it. Then give F6 to copy the first key frame in second key frame. In the second key frame change the color of the line and make another two copies of it as like below. So it will give vibrating effect on mouse over the strings.

flash-guitar-3
image-787

Step-6: Like that do the same for remaining 5 strings in different layers. The only changes have to do is to change the identifier name.

Step-7: Now import the tone to library by File –> Import –> Import to library. I have imported 6 string tones. Rename it to string1, string2 ….. String6.

Step-8: open library by Ctrl+L. Right click on string1 tone and go to properties. You will get one dialog box like below. Check the linkage box and give identifier name of the string1 tone. Here I gave st1 for string1 tone, st2 for string2 tone etc.

image-788

Step-9: Run the program.

Tags: ,

Rendering of 3d colorful sphere rotation using Flash:

Step-1: Open a new document in flash is about the size of 400 X 410.

Step-2:In layer-1 type the text which ever you want. Here I gave “Move the Mouse over the surface  to rotate the sphere”.


Step-3:Create layer-2 and write the following action script in keyframe-1(F9).

var boardSize:Number=350;
var cubeSize:Number=Math.round(boardSize/3);
var rotateFactor:Number=1.2*320/boardSize;
var fLen:Number=2000;
var spBoard:Sprite=new Sprite();
this.addChild(spBoard);
spBoard.x=200;
spBoard.y=200;
var shBack:Shape=new Shape();
spBoard.addChild(shBack);
drawBack();
var shCube:Shape=new Shape();
spBoard.addChild(shCube);
var doRotate:Boolean = false;
var prevX:Number;
var prevY:Number;
var curTheta:Number=-10;
var curPhi:Number=60;
var examplesTot:uint=11;
var exampleNum:uint=3;
var nMesh:Number=40;
var tilesArray:Array=[];
var firstRun:Boolean=true;
var tilesColors:Array=[];
function drawBack():void {
shBack.graphics.lineStyle(2,0xFFFFFF);
shBack.graphics.beginFill(0x000000);
shBack.graphics.drawRect(-boardSize/2,-boardSize/2,boardSize,boardSize);
shBack.graphics.endFill();
}
setTilesArray();
renderView(curTheta,curPhi);
function setTilesArray():void {
var i:int;
var j:int;
var istep:Number;
var jstep:Number;
var tmin:Number;
var tmax:Number;
var smin:Number;
var smax:Number;
var curt:Number;
var curs:Number;
shCube.graphics.clear();
tilesArray=[];
tilesColors=[];
firstRun=true;
curTheta=-10;
curPhi=90;
if(exampleNum==3){
tmin=0;
tmax=1.5*Math.PI;
smin=0;
smax=2*Math.PI;
}
istep=(smax-smin)/nMesh;
jstep=(tmax-tmin)/nMesh;
for(i=0;i<=nMesh;i++){
curs=istep*i+smin;
tilesArray[i]=[];
for(j=0;j<=nMesh;j++){
curt=jstep*j+tmin;
if(exampleNum==3){
tilesArray[i][j]=[cubeSize/4.3*Math.cos(curs)*(2+Math.cos(curt)*2),cubeSize/4.3*Math.sin(curs)*(2+Math.cos(curt)*2),cubeSize/2.6*(3-curt)-0.3*cubeSize];
}
}
}
}
function renderView(t:Number,p:Number):void {
var i:int;
var j:int;
var n:int;
var distArray=[];
var dispArray=[];
var tilesNewArray=[];
var midPoint:Array=[];
var dist:Number;
var depLen:Number;
var coloFactor=100/cubeSize;
t=t*Math.PI/180;
p=p*Math.PI/90;
shCube.graphics.clear();
for(i=0;i<=nMesh;i++){
tilesNewArray[i]=[];
for(j=0;j<=nMesh;j++){
tilesNewArray[i][j]=pointNewView(tilesArray[i][j],t,p);
}
}
for(i=0;i<nMesh;i++){
if(firstRun){
tilesColors[i]=[];
}
for(j=0;j<nMesh;j++){
midPoint[0]=(tilesNewArray[i][j][0]+tilesNewArray[i+1][j][0]+tilesNewArray[i][j+1][0]+tilesNewArray[i+1][j+1][0])/4;
midPoint[1]=(tilesNewArray[i][j][1]+tilesNewArray[i+1][j][1]+tilesNewArray[i][j+1][1]+tilesNewArray[i+1][j+1][1])/4;
midPoint[2]=(tilesNewArray[i][j][2]+tilesNewArray[i+1][j][2]+tilesNewArray[i][j+1][2]+tilesNewArray[i+1][j+1][2])/4;
dist=Math.sqrt(Math.pow(fLen-midPoint[0],2)+Math.pow(midPoint[1],2)+Math.pow(midPoint[2],2));
distArray.push([dist,i,j]);
if(firstRun){
tilesColors[i][j]=combineRGB((2*coloFactor*midPoint[2]+100)*0.8+70,(2*coloFactor*midPoint[1]+100)*0.8+70,(2*coloFactor*midPoint[0]+100)*0.8+70);
}
}
}
distArray.sort(byDist);
for(i=0;i<=nMesh;i++){
dispArray[i]=[];
for(j=0;j<=nMesh;j++){
dispArray[i][j]=[fLen/(fLen-tilesNewArray[i][j][0])*tilesNewArray[i][j][1],-fLen/(fLen-tilesNewArray[i][j][0])*tilesNewArray[i][j][2]];
}
}
depLen=distArray.length;
shCube.graphics.lineStyle(1,0×111111);
for(n=0;n<depLen;n++){
i=distArray[n][1];
j=distArray[n][2];
shCube.graphics.moveTo(dispArray[i][j][0],dispArray[i][j][1]);
shCube.graphics.beginFill(tilesColors[i][j],1.0);
shCube.graphics.lineTo(dispArray[i][j+1][0],dispArray[i][j+1][1]);
shCube.graphics.lineTo(dispArray[i+1][j+1][0],dispArray[i+1][j+1][1]);
shCube.graphics.lineTo(dispArray[i+1][j][0],dispArray[i+1][j][1]);
shCube.graphics.lineTo(dispArray[i][j][0],dispArray[i][j][1]);
shCube.graphics.endFill();
}
firstRun=false;
}
function byDist(v:Array,w:Array):Number {
if (v[0]>w[0]){
return -1;
} else if (v[0]<w[0]){
return 1;
} else {
return 0;
}
}
function pointNewView(v:Array,theta:Number,phi:Number):Array {
var newCoords:Array=[];
newCoords[0]=v[0]*Math.cos(theta)*Math.sin(phi)+v[1]*Math.sin(theta)*Math.sin(phi)+v[2]*Math.cos(phi);
newCoords[1]=-v[0]*Math.sin(theta)+v[1]*Math.cos(theta);
newCoords[2]=-v[0]*Math.cos(theta)*Math.cos(phi)-v[1]*Math.sin(theta)*Math.cos(phi)+v[2]*Math.sin(phi);
return newCoords;
}
function combineRGB(red:Number,green:Number,blue:Number):Number {
var RGB:Number;
if(red>255){red=255;}
if(green>255){green=255;}
if(blue>255){blue=255;}
if(red<0){red=0;}
if(green<0){green=0;}
if(blue<0){blue=0;}
RGB=(red<<16) | (green<<8) | (blue<<0);
return RGB;
}
spBoard.addEventListener(MouseEvent.ROLL_OUT,boardOut);
spBoard.addEventListener(MouseEvent.MOUSE_MOVE,boardMove);
spBoard.addEventListener(MouseEvent.ROLL_OVER,boardOver);
function boardOut(e:MouseEvent):void {
doRotate=false;
}
function boardOver(e:MouseEvent):void {
prevX=spBoard.mouseX;
prevY=spBoard.mouseY;
doRotate=true;
}
function boardMove(e:MouseEvent):void {
var locX:Number=prevX;
var locY:Number=prevY;
if(doRotate){
prevX=spBoard.mouseX;
prevY=spBoard.mouseY;
curTheta+=(prevX-locX)*rotateFactor;
curPhi+=(prevY-locY)*rotateFactor;
renderView(curTheta,curPhi);
e.updateAfterEvent();
}
}

Now run the program.

Tags: ,

Flash AS3 Tween Vibrating Gallery

Step 1: Open a new a document in flash Actionscript 3.0 in the size of 525X450 PX.

Step 2: Set up the BG color as black or needed color.

Step 3: Paste the following code in Layer-1, first Keyframe by giving F9 to open the actionacript panel:

import fl.transitions.*;
import fl.transitions.easing.*;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.display.Sprite;
import asfiles.ascript.objects.Tile;
import asfiles.ascript.loaders.GalleryLoader;
import asfiles.ascript.preloaders.LoadSpinner2;
import flash.display.Loader;
import flash.display.Shape;
import flash.events.MouseEvent;
import flash.text.TextFormat;
import flash.events.Event;
var dw:Number = 525;
var dh:Number = 450;
var galLoader:GalleryLoader;
var numPics:int;
var thumbsData:Vector.<BitmapData>
var largePiURLs:Vector.<String>;
var captions:Vector.<String>;
var spinner:LoadSpinner2;
var picWidth:Number;
var picHeight:Number;
var divisions:Number;
var gap:Number;
var tiles:Vector.<Tile>;
var tileWidth:Number;
var tileHeight:Number;
var galleryHolder:Sprite;
var parameterTween:Tween;
var variationX:Vector.<Number>;
var variationY:Vector.<Number>;
var variationMax:Number;
var collapsed:Boolean;
var currentPicIndex:int;
var captionBox:TextField;
var collapseTweenDuration:Number;
var separateTweenDuration:Number;
var closedPositionOffsetY:Number;
var thumbnails:Vector.<Bitmap>;
var pics:Vector.<Bitmap>;
var angles:Vector.<Number>;
var loader:Loader;
var isLoading:Boolean;
var scrollTweenDuration:Number;
var pageShift:int;
var numTiles:int;
var numPages:int;
var backSkip:int;
var navigationPanel:Sprite;
//////////
stage.scaleMode = StageScaleMode.NO_SCALE;
//this paramObject will be used for our tweened motion:
var paramObject:Object = {t:0};
//we create some instances of MovieClips from the library:
var btnNextImage:BtnNextImage = new BtnNextImage();
var btnPrevImage:BtnPrevImage = new BtnPrevImage();
var btnNextPage:BtnNextPage = new BtnNextPage();
var btnPrevPage:BtnPrevPage = new BtnPrevPage();
var btnReturn:BtnReturn = new BtnReturn();
var mcViewInstructions:McViewInstructions = new McViewInstructions();
init();
/////////
function init():void {
thumbsData = new Vector.<BitmapData>();
largePicURLs = new Vector.<String>();
captions = new Vector.<String>();
loader = new Loader();
isLoading = false; //boolean flag for image loading after thumbnail click
infoBox.text = “Loading thumbnails, please wait…”;
galleryHolder = new Sprite();
galleryHolder.x = dw/2 – 30;
galleryHolder.y = dh/2 + 10;
this.addChild(galleryHolder);
btnPrevImage.mouseEnabled = false;
btnNextImage.mouseEnabled = false;
btnReturn.mouseEnabled = false;
spinner = new LoadSpinner2(100,100);
spinner.setColors(0x000762C5, 0xFF0762C5);
spinner.bgAlpha = 20;
spinner.x = galleryHolder.x;
spinner.y = galleryHolder.y;
this.addChild(spinner);
spinner.startSpinner();
galLoader = new GalleryLoader(“gallery.xml”);
galLoader.addEventListener(GalleryLoader.XMLLOAD_ERROR, xmlError);
galLoader.addEventListener(GalleryLoader.IMGSLOAD_ERROR, imgsError);
galLoader.addEventListener(GalleryLoader.ALL_LOADED, loadEnded);
galLoader.loadXML();
}
function xmlError(e:Event):void {
galLoader.removeEventListener(GalleryLoader.XMLLOAD_ERROR, xmlError);
galLoader.removeEventListener(GalleryLoader.ALL_LOADED, loadEnded);
galLoader.removeEventListener(GalleryLoader.IMGSLOAD_ERROR, imgsError);
infoBox.text=”There has been an error loading the XML file. The server may be busy. Try refreshing the page.”;
spinner.stopSpinner();
spinner.visible=false;
}
function imgsError(e:Event):void {
galLoader.removeEventListener(GalleryLoader.XMLLOAD_ERROR, xmlError);
galLoader.removeEventListener(GalleryLoader.ALL_LOADED, loadEnded);
galLoader.removeEventListener(GalleryLoader.IMGSLOAD_ERROR, imgsError);
infoBox.text=”There has been an error loading thumbnails. The server may be busy. Try refreshing the page.”;
spinner.stopSpinner();
spinner.visible=false;
}
function loadEnded(e:Event):void {
galLoader.removeEventListener(GalleryLoader.XMLLOAD_ERROR, xmlError);
galLoader.removeEventListener(GalleryLoader.ALL_LOADED, loadEnded);
galLoader.removeEventListener(GalleryLoader.IMGSLOAD_ERROR, imgsError);
infoBox.text=””;
spinner.stopSpinner();
spinner.visible=false;
initApp();
}
function populateVecs():void {
var j:int;
for(j=0;j<numPics;j++){
thumbsData[j]=galLoader.bmpDataVec[j];
largePicURLs[j]=galLoader.picsVec[j];
captions[j]=galLoader.capsVec[j];
}
}
function initApp():void {
numPics = galLoader.numPics;
populateVecs();
thumbnails = new Vector.<Bitmap>();
createThumbnailBitmaps();
picWidth = 400;
picHeight = 300;
gap = 10;
divisions = 4;
numTiles = divisions*divisions;
variationMax = 12;
numPages = Math.ceil(Number(numPics)/Number(numTiles));
backSkip = numPages*numTiles – numPics;
collapseTweenDuration = 75;
separateTweenDuration = 30;
scrollTweenDuration = 40;
closedPositionOffsetY = 0;
pageShift = 0;
navigationPanel = new Sprite();
this.addChild(navigationPanel);
navigationPanel.mouseEnabled = false;
navigationPanel.y = galleryHolder.y + closedPositionOffsetY – picHeight/2 – 40;
navigationPanel.x = galleryHolder.x + 2;
navigationPanel.addChild(btnNextImage);
btnNextImage.y = 0;
btnNextImage.x = btnReturn.width/2 + 20;
navigationPanel.addChild(btnPrevImage);
btnPrevImage.y = 0;
btnPrevImage.x = -btnReturn.width/2 – 20;
navigationPanel.addChild(btnReturn);
btnReturn.y = 0;
btnReturn.x = 0;
this.addChild(mcViewInstructions);
mcViewInstructions.y = galleryHolder.y – (picHeight + gap*(divisions-1))/2 – 30;
mcViewInstructions.x = galleryHolder.x + 3;
mcViewInstructions.mouseEnabled = false;
this.addChild(btnPrevPage);
btnPrevPage.x = galleryHolder.x + (picWidth + gap*(divisions-1))/2 + 30;
btnPrevPage.y = galleryHolder.y – 8;
this.addChild(btnNextPage);
btnNextPage.x = galleryHolder.x + (picWidth + gap*(divisions-1))/2 + 30;
btnNextPage.y = galleryHolder.y + 12;
btnPrevImage.addEventListener(MouseEvent.CLICK, prevImage);
btnNextImage.addEventListener(MouseEvent.CLICK, nextImage);
btnReturn.addEventListener(MouseEvent.CLICK, returnToThumbs);
btnNextPage.addEventListener(MouseEvent.CLICK, btnNextPageHandler);
btnPrevPage.addEventListener(MouseEvent.CLICK, btnPrevPageHandler);
setPagingVisibility();
navigationPanel.alpha = 0;
tiles = new Vector.<Tile>();
variationX = new Vector.<Number>();
variationY = new Vector.<Number>();
angles = new Vector.<Number>();
tileWidth = picWidth/divisions;
tileHeight = picHeight/divisions;
var dsf:DropShadowFilter = new DropShadowFilter(6,45,0×000000,2,6,6,1);
galleryHolder.filters = [dsf];
var format:TextFormat = new TextFormat(“arial”,12,0xffffff,false,true);
format.align = TextFormatAlign.CENTER;
captionBox = new TextField();
captionBox.defaultTextFormat = format;
captionBox.autoSize = TextFieldAutoSize.CENTER;
captionBox.text = “”;
captionBox.x = galleryHolder.x – captionBox.width/2;
captionBox.y = 20+galleryHolder.y + 0.5*picHeight + closedPositionOffsetY;
this.addChildAt(captionBox,0);
captionBox.mouseEnabled = false;
setUpThumbnails();
setUpTiles();
collapsed = false;
}
function createThumbnailBitmaps():void {
var i:int;
for (i = 0; i < galLoader.numPics; i++) {
thumbnails.push(new Bitmap(galLoader.bmpDataVec[i]));
}
}
function setUpThumbnails():void {
var k:int;
var scaleFactor:Number;
for (k = 0; k < numPics; k++) {
scaleFactor = tileWidth/thumbnails[k].width;
thumbnails[k].x = -scaleFactor*thumbnails[k].width/2;
thumbnails[k].y = -scaleFactor*thumbnails[k].height/2;
thumbnails[k].scaleX = thumbnails[k].scaleY = scaleFactor;
}
}
function setUpTiles():void {
for (var i=0; i<= divisions-1; i++) {
for (var j=0; j<= divisions-1; j++) {
var thisTile:Tile = new Tile();
thisTile.thumbnailHolder.addChild(thumbnails[i*divisions + j]);
galleryHolder.addChild(thisTile);
thisTile.openPosition.x = -(picWidth + gap*(divisions-1))/2 + tileWidth/2+(tileWidth+gap)*j;// + (2*Math.random()-1)*gap*0.5;
thisTile.openPosition.y = -(picHeight + gap*(divisions-1))/2 + tileHeight/2+(tileHeight+gap)*i;// + (2*Math.random()-1)*gap*0.5;
thisTile.closedPosition.x = -picWidth/2 + tileWidth/2 + tileWidth*j;
thisTile.closedPosition.y = closedPositionOffsetY – picHeight/2 + tileHeight/2 + tileHeight*i;
thisTile.x = thisTile.openPosition.x;
thisTile.y = thisTile.openPosition.y;
thisTile.which = i*divisions+j;
thisTile.buttonMode = true;
tiles.push(thisTile);
variationX.push(4*variationMax*(2*Math.random()-1));
variationY.push(4*variationMax*(2*Math.random()-1));
angles.push(0);
thisTile.addEventListener(MouseEvent.CLICK, onTileClick);
}}}
function onTileClick(evt:MouseEvent):void {
if(isLoading||collapsed){
return;
}
isLoading=true;
currentPicIndex = evt.target.which;
setFlipVisibility();
spinner.visible = true;
spinner.startSpinner();
//set up listeners for load complete or error, go to changeTilesBeforeCollapse on complete
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loadingError);
//load image
loader.load(new URLRequest(largePicURLs[currentPicIndex + pageShift]));
}
function setFlipVisibility():void {
btnPrevImage.visible = btnPrevImage.mouseEnabled = (currentPicIndex + pageShift > 0);
btnNextImage.visible = btnNextImage.mouseEnabled = (currentPicIndex + pageShift < (numPics – 1));
}
function loadingError(e:IOErrorEvent):void {
infoBox.text=”There has been an error loading the image. The server may be busy. Refresh the page and try again.”;
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadComplete);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,loadingError);
isLoading=false;
spinner.stopSpinner();
spinner.visible=false;
}
function onPicClick(evt:MouseEvent):void {
btnReturn.removeEventListener(MouseEvent.CLICK, returnToThumbs);
galleryHolder.removeEventListener(MouseEvent.CLICK, onPicClick);
separate();
}
function returnToThumbs(evt:MouseEvent):void {
galleryHolder.removeEventListener(MouseEvent.CLICK, onPicClick);
btnReturn.removeEventListener(MouseEvent.CLICK, returnToThumbs);
btnReturn.mouseEnabled = false;
separate();
}
function loadComplete(evt:Event):void {
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadComplete);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,loadingError);
spinner.stopSpinner();
spinner.visible=false;
isLoading=false;
//paint tiles with pic:
var matrix:Matrix = new Matrix(1,0,0,1);
var index:int;
var bd:BitmapData = Bitmap(loader.content).bitmapData;
for (var i=0; i<= divisions-1; i++) {
for (var j=0; j<= divisions-1; j++) {
index = i*divisions + j;
matrix.tx = (-j-0.5)*picWidth/divisions;
matrix.ty = (-i-0.5)*picHeight/divisions;
tiles[index].graphics.clear();
tiles[index].graphics.beginBitmapFill(bd,matrix,false,false);
tiles[index].graphics.drawRect(-tileWidth/2, -tileHeight/2, tileWidth, tileHeight);
tiles[index].graphics.endFill();
}
}
//change caption:
captionBox.text = ”  “+captions[currentPicIndex + pageShift]+”  “; //adding a little extra space to avoid cutoff
if (!collapsed) {
collapse();
}
}
function collapse():void {
collapsed = true;
//reset the randomization variables so it won’t look the same every time:
for (var i:int = 0; i < divisions*divisions; i++) {
variationX[i] = (4*variationMax*(2*Math.random()-1));
variationY[i] = (4*variationMax*(2*Math.random()-1));
angles[i] = 60-Math.random()*120;
}
parameterTween = new Tween(paramObject,”t”,Elastic.easeInOut,0,1,collapseTweenDuration);
parameterTween.addEventListener(TweenEvent.MOTION_FINISH, collapseComplete);
this.addEventListener(Event.ENTER_FRAME, onEnterCollapse);
}
function separate():void {
collapsed = false;
//reset the randomization variables so it won’t look the same every time:
for (var i:int = 0; i < divisions*divisions; i++) {
variationX[i] = (4*variationMax*(2*Math.random()-1));
variationY[i] = (4*variationMax*(2*Math.random()-1));
angles[i] = 60-Math.random()*120;
}
parameterTween = new Tween(paramObject,”t”,Elastic.easeInOut,0,1,separateTweenDuration);
parameterTween.addEventListener(TweenEvent.MOTION_FINISH, separateComplete);
this.adEventListener(Event.ENTER_FRAME, onEnterSeparate);
btnPrevImage.mouseEnabled = false;
btnNextImage.mouseEnabled = false;
}
function onEnterCollapse(evt:Event):void {
captionBox.alpha = paramObject.t;
navigationPanel.alpha = paramObject.t;
mcViewInstructions.alpha = 1 – paramObject.t;
btnPrevPage.alpha = 1 – paramObject.t;
btnNextPage.alpha = 1 – paramObject.t;
var quad:Number;
for (var i:int = 0; i< divisions*divisions; i++) {
quad = paramObject.t*(1-paramObject.t);
tiles[i].x = tiles[i].openPosition.x + paramObject.t*(tiles[i].closedPosition.x-tiles[i].openPosition.x)+variationX[i]*quad;
tiles[i].y = tiles[i].openPosition.y + paramObject.t*(tiles[i].closedPosition.y-tiles[i].openPosition.y)+variationY[i]*quad;
tiles[i].thumbnailHolder.alpha = 1-paramObject.t;
tiles[i].rotation = quad*angles[i];
}
}
function onEnterSeparate(evt:Event):void {
captionBox.alpha = 1-paramObject.t;
navigationPanel.alpha = 1-paramObject.t;
mcViewInstructions.alpha = paramObject.t;
btnPrevPage.alpha = paramObject.t;
btnNextPage.alpha = paramObject.t;
var quad:Number;
for (var i:int = 0; i< divisions*divisions; i++) {
quad = paramObject.t*(1-paramObject.t);
tiles[i].x = tiles[i].closedPosition.x + paramObject.t*(tiles[i].openPosition.x-tiles[i].closedPosition.x)+variationX[i]*quad;
tiles[i].y = tiles[i].closedPosition.y + paramObject.t*(tiles[i].openPosition.y-tiles[i].closedPosition.y)+variationY[i]*quad;
tiles[i].thumbnailHolder.alpha = paramObject.t;
tiles[i].rotation = quad*angles[i];
}
}
function collapseComplete(evt:Event):void {
captionBox.x = galleryHolder.x – captionBox.width/2;
this.removeEventListener(Event.ENTER_FRAME, onEnterCollapse);
galleryHolder.addEventListener(MouseEvent.CLICK, onPicClick);
btnReturn.addEventListener(MouseEvent.CLICK, returnToThumbs);
btnReturn.mouseEnabled = true;
}
function separateComplete(evt:Event):void {
this.removeEventListener(Event.ENTER_FRAME, onEnterSeparate);
}
function prevImage(evt:MouseEvent):void {
if(isLoading){
return;
}
isLoading=true;
currentPicIndex -= 1;
if (currentPicIndex < 0) {
//pageShift -= numTiles;
currentPicIndex = numTiles – 1
//have to do something special if we’re on the last page
if (Math.ceil(Number(pageShift)/Number(numTiles)) == numPages – 1) {
currentPicIndex -= backSkip;
}
prevPage();
}

setFlipVisibility();
spinner.visible = true;
spinner.startSpinner();
//set up listeners for load complete or error, go to changeTilesBeforeCollapse on complete
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loadingError);
//load image
loader.load(new URLRequest(largePicURLs[currentPicIndex + pageShift]));
}
function nextImage(evt:MouseEvent):void {
if(isLoading){
return;
}
isLoading=true;
currentPicIndex += 1;
if (currentPicIndex > numTiles – 1) {
//pageShift -= numTiles;
currentPicIndex = 0;
//have to do something special if we’re on the last page
if (Math.ceil(Number(pageShift + numTiles)/Number(numTiles)) == numPages – 1) {
currentPicIndex += backSkip;
}
nextPage();
}
setFlipVisibility();
spinner.visible = true;
spinner.startSpinner();
//set up listeners for load complete or error, go to changeTilesBeforeCollapse on complete
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loadingError);
//load image
loader.load(new URLRequest(largePicURLs[currentPicIndex + pageShift]));
}
function setPagingVisibility():void {
btnPrevPage.visible = false;
btnPrevPage.mouseEnabled = false;
btnNextPage.visible = false;
btnNextPage.mouseEnabled = false;
if (pageShift + numTiles < numPics – 1) {
btnNextPage.visible = true;
btnNextPage.mouseEnabled = true;
}
if (pageShift > 0) {
btnPrevPage.visible = true;
btnPrevPage.mouseEnabled = true;
}
}
function btnNextPageHandler(evt:MouseEvent):void {
nextPage();
}
function btnPrevPageHandler(evt:MouseEvent):void {
prevPage();
}
function nextPage():void {
var k:int;
pageShift += numTiles;
if (pageShift + numTiles > numPics) {
pageShift = numPics – numTiles;
}
for (k = 0; k < numTiles; k++) {
if (tiles[k].thumbnailHolder.numChildren > 0) {
tiles[k].thumbnailHolder.removeChildAt(0);
}
tiles[k].thumbnailHolder.addChild(thumbnails[k + pageShift]);
}
setPagingVisibility();
}
function prevPage():void {
var k:int;
pageShift -= numTiles;
if (pageShift < 0) {
pageShift = 0;
}
for (k = 0; k < numTiles; k++) {
if (tiles[k].thumbnailHolder.numChildren > 0) {
tiles[k].thumbnailHolder.removeChildAt(0);
}
tiles[k].thumbnailHolder.addChild(thumbnails[k + pageShift]);
}
setPagingVisibility();
}

Step 4: Create one folder in the name of gallery, inside of it create two folders in the name of asfiles and pictures. Inside of asfiles folder create ascript folder, and inside of it create three folders in the name of loader, object, and preloader. The folders chart is given below for reference:

image-607

Step 5: Create images in the size of 400X300 and also make the copy of images in thumbnail size inside the pictures folder. Here I have taken 30 images for gallery.

Step-6: Now have open four actionscript file in the name of LoadSpinner2, Tile, GalleryLoader, ThumbsLoader. Save GalleryLoader, ThumbsLoader in loader folder, and Tile in object and LoadSpinner2 in preloader folder.

Write the following code in LoadSpinner2.as file:

package asfiles.ascript.preloaders {
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.filters.BlurFilter;
public class LoadSpinner2 extends Sprite {
private var back:Shape;
private var spinner:Shape;
private var rectWidth:Number;
private var rectHeight:Number;
private var sticks:Vector.<Shape>;
private var numSticks:int;
private var count:int;
private var dimColor:uint;
private var brightColor:uint;
private var colors:Vector.<uint>;
private var alphas:Vector.<Number>;
private var sticksHolder:Sprite;
private var _bgAlpha:Number;
public function LoadSpinner2(w:Number,h:Number) {
rectWidth=w;
rectHeight=h;
numSticks=12;
count=0;
_bgAlpha = 0.1;
sticks= new Vector.<Shape>(numSticks);
sticksHolder = new Sprite();
this.addChild(sticksHolder);
sticksHolder.x=0;
sticksHolder.y=0;
var i:int;
for(i=0;i<numSticks;i++){
sticks[i]=new Shape();
sticksHolder.addChild(sticks[i]);
sticks[i].x=0;
sticks[i].y=0;
}
setColors(0x0088DDFF, 0xFF88DDFF);
drawBack();
}
public function set bgAlpha(n:Number):void {
_bgAlpha = n;
drawBack();
}
public function setColors(color1:uint, color2:uint):void {
var a1:uint = (color1 >> 24) & 0xFF;
var r1:uint = (color1 >> 16) & 0xFF;
var g1:uint = (color1 >> 8 ) & 0xFF;
var b1:uint = color1 & 0xFF;
var a2:uint = (color2 >> 24) & 0xFF;
var r2:uint = (color2 >> 16) & 0xFF;
var g2:uint = (color2 >> 8 ) & 0xFF;
var b2:uint = color2 & 0xFF;
var a,r,g,b:Number;
colors = new Vector.<uint>(numSticks);
alphas = new Vector.<Number>(numSticks);
var i:Number;
var t:Number;
for (i = 0; i < numSticks; i++) {
t = i/(numSticks-1);
t = t*t;
a = a1 + t*(a2-a1);
r = r1 + t*(r2-r1);
g = g1 + t*(g2-g1);
b = b1 + t*(b2-b1);
colors[i] = (r << 16) | (g << 8 ) | b;
alphas[i] = Number(a)/255;
}
drawSpinner(count);
}
private function drawBack():void {
this.graphics.clear();
this.graphics.lineStyle(2,0xFFFFFF,_bgAlpha);
this.graphics.beginFill(0xFFFFFF,_bgAlpha);
this.graphics.drawRoundRect(-rectWidth/2,-rectHeight/2,rectWidth,rectHeight,10,10);
this.graphics.endFill();
}
private function drawSpinner(k:int):void {
var minRad:Number=10;
var maxRad:Number=25;
var ang=Math.PI*2/numSticks;
var i:Number;
var t:Number;
for(i=0;i<numSticks;i++){
t = i/(numSticks-1);
t = t*t;
sticks[i].graphics.clear();
sticks[i].graphics.lineStyle(4,colors[i],alphas[i],false,”normal”,”round”);
sticks[i].graphics.moveTo(minRad*Math.cos(i*ang),minRad*Math.sin(i*ang));
sticks[i].graphics.lineTo(maxRad*Math.cos(i*ang),maxRad*Math.sin(i*ang));
}
}
public function stopSpinner():void {
this.removeEventListener(Event.ENTER_FRAME,doSpin);
count=0;
}
public function startSpinner():void {
this.addEventListener(Event.ENTER_FRAME,doSpin);
}
private function doSpin(e:Event):void {
count+=1;
count=count%numSticks;
sticksHolder.rotation = 360*count/numSticks;
}}}
Write the following code in Tile.as:
package asfiles.ascript.objects {
import flash.display.Sprite;
import flash.geom.Point;

public class Tile extends Sprite {
public var which:Number;
public var openPosition:Point;
public var closedPosition:Point;
public var color:uint;
public var thumbnailHolder:Sprite;
public function Tile() {
openPosition = new Point();
closedPosition = new Point();
thumbnailHolder = new Sprite();
thumbnailHolder.mouseEnabled = false;
this.addChild(thumbnailHolder);
}}}
Write the following code GalleryLoader.as:
package asfiles.ascript.loaders {
import flash.display.Loader;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.EventDispatcher;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
public class GalleryLoader extends EventDispatcher {
public static const ALL_LOADED:String = “allLoaded”;
public static const XMLLOAD_ERROR:String = “xmlLoadError”;
public static const IMGSLOAD_ERROR:String = “imgsLoadError”;
private var xmlRequest:URLRequest;
private var xmlLoader:URLLoader;
private var xmlContent:XML;
private var _numPics:int;
private var isError:Boolean;
private var _bmpDataVec:Vector.<BitmapData>;
private var _capsVec:Vector.<String>;
private var _picsVec:Vector.<String>;
private var thumbsToLoad:Array;
private var thumbsLoader:ThumbsLoader;
public function GalleryLoader(xml:String){
xmlRequest=new URLRequest(xml);
}
public function loadXML():void {
xmlLoader=new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, xmlError);
xmlLoader.load(xmlRequest);
}
private function xmlLoadComplete(e:Event):void {
xmlContent = new XML(xmlLoader.data);
xmlLoader.removeEventListener(Event.COMPLETE, xmlLoadComplete);
xmlLoader.removeEventListener(IOErrorEvent.IO_ERROR, xmlError);
procXML();
}
private function procXML():void {
var j:int;
_numPics=xmlContent.tile.length();
thumbsToLoad=[];
_bmpDataVec=new Vector.<BitmapData>(_numPics);
_picsVec=new Vector.<String>(_numPics);
_capsVec=new Vector.<String>(_numPics);
for(j=0;j<_numPics;j++){

thumbsToLoad.push(xmlContent.tile[j].thumb.toString());
_picsVec[j]=xmlContent.tile[j].pic.toString();
_capsVec[j]=xmlContent.tile[j].cap.toString();
}
thumbsLoader=new ThumbsLoader();
thumbsLoader.addEventListener(ThumbsLoader.IMGS_LOADED,imgsDone);
thumbsLoader.addEventListener(ThumbsLoader.LOAD_ERROR,imgsError);
thumbsLoader.loadImgs(thumbsToLoad);
}
private function imgsError(e:Event):void {
dispatchEvent(new Event(GalleryLoader.IMGSLOAD_ERROR));
}
private function imgsDone(e:Event):void {
var j:int;
thumbsLoader.removeEventListener(ThumbsLoader.IMGS_LOADED,imgsDone);
thumbsLoader.removeEventListener(ThumbsLoader.LOAD_ERROR,imgsError);
for(j=0;j<_numPics;j++){
_bmpDataVec[j]=thumbsLoader.bitmapsArray[j].clone();
thumbsLoader.bitmapsArray[j].dispose();
}
dispatchEvent(new Event(GalleryLoader.ALL_LOADED));
}
private function xmlError(e:IOErrorEvent):void {
dispatchEvent(new Event(GalleryLoader.XMLLOAD_ERROR));
}
public function get bmpDataVec():Vector.<BitmapData> {
return _bmpDataVec;
}
public function get picsVec():Vector.<String> {
return _picsVec;
}
public function get capsVec():Vector.<String> {
return _capsVec;
}
public function get numPics():int {
return _numPics;
}}}

Write the following code in ThumbLoader.as file:

package com.ascript.loaders {
import flash.display.Loader;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.net.URLRequest;
public  class ThumbsLoader extends EventDispatcher {
public static const IMGS_LOADED:String = “imgsLoaded”;
public static const LOAD_ERROR:String = “loadError”;
private var loadersArray:Array;
private var numImgs:int;
private var numLoaded:int;
private var isError:Boolean;
private var _bitmapsArray:Array;
private var loadCanRun:Boolean;
public function ThumbsLoader(){
this.loadCanRun=true;
}
public function loadImgs(imgsFiles:Array):void {
if(loadCanRun){
loadCanRun=false;
numLoaded=0;
isError=false;
numImgs=imgsFiles.length;
_bitmapsArray=[];
loadersArray=[];
for(var i:int=0;i<numImgs;i++){
loadersArray[i]=new Loader();
loadersArray[i].contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);

loadersArray[i].contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorOccured);
loadersArray[i].load(new URLRequest(imgsFiles[i]));
}
}
}
private function imgLoaded(e:Event):void {
numLoaded+=1;
checkLoadStatus();
}
private function errorOccured(e:IOErrorEvent):void {
isError=true;
dispatchEvent(new Event(ThumbsLoader.LOAD_ERROR));
}
private function checkLoadStatus():void {
var i:int;
if(numLoaded==numImgs && isError==false){
for(i=0;i<numImgs;i++){
_bitmapsArray[i]=Bitmap(loadersArray[i].content).bitmapData;
}
for(i=0;i<numImgs;i++){                   loadersArray[i].contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorOccured);
loadersArray[i].contentLoaderInfo.removeEventListener(Event.COMPLETE, imgLoaded);
loadersArray[i]=null;
}

loadersArray=[];
loadCanRun=true;
dispatchEvent(new Event(ThumbsLoader.IMGS_LOADED));
}
}
public function get bitmapsArray():Array {
return _bitmapsArray;
}
}
}

Step 7: Open a xml file, save it as gallery and write the following code:

<gallery>
<tile>
<thumb>Pictures/Image1_thumbnail.jpg</thumb>
<pic>Pictures/Image1.jpg</pic>
<cap>Natural Beauty</cap>
</tile>
<tile>
<thumb>Pictures/Image2_thumbnail.jpg</thumb>
<pic>Pictures/Image2.jpg</pic>
<cap>Seashore in the dusk</cap>
</tile>
<tile>
<thumb>Pictures/Image3_thumbnail.jpg</thumb>
<pic>Pictures/Image3.jpg</pic>
<cap>Seashore</cap>
</tile>
<tile>
<thumb>Pictures/Image4_thumbnail.jpg</thumb>
<pic>Pictures/Image4.jpg</pic>
<cap>Green way</cap>
</tile>
<tile>
<thumb>Pictures/Image5_thumbnail.jpg</thumb>
<pic>Pictures/Image5.jpg</pic>
<cap>Grass Bed</cap>
</tile><tile>
<thumb>Pictures/Image6_thumbnail.jpg</thumb>
<pic>Pictures/Image6.jpg</pic>
<cap>Umbrella Tree</cap>
</tile><tile>
<thumb>Pictures/Image7_thumbnail.jpg</thumb>
<pic>Pictures/Image7.jpg</pic>
<cap>Moon at night</cap>
</tile><tile>
<thumb>Pictures/Image8_thumbnail.jpg</thumb>
<pic>Pictures/Image8.jpg</pic>
<cap>winter sun</cap>
</tile><tile>
<thumb>Pictures/Image9_thumbnail.jpg</thumb>
<pic>Pictures/Image9.jpg</pic>
<cap>Mountain</cap>
</tile><tile>
<thumb>Pictures/Image10_thumbnail.jpg</thumb>
<pic>Pictures/Image10.jpg</pic>
<cap>Root House</cap>
</tile><tile>
<thumb>Pictures/Image11_thumbnail.jpg</thumb>
<pic>Pictures/Image11.jpg</pic>
<cap>Amazing House</cap>
</tile><tile>
<thumb>Pictures/Image12_thumbnail.jpg</thumb>
<pic>Pictures/Image12.jpg</pic>
<cap>Spring</cap>
</tile><tile>
<thumb>Pictures/Image13_thumbnail.jpg</thumb>
<pic>Pictures/Image13.jpg</pic>
<cap>Sea Rock</cap>
</tile><tile>
<thumb>Pictures/Image14_thumbnail.jpg</thumb>
<pic>Pictures/Image14.jpg</pic>
<cap>Mountain View</cap>
</tile><tile>
<thumb>Pictures/Image15_thumbnail.jpg</thumb>
<pic>Pictures/Image15.jpg</pic>
<cap>Blue Sea</cap>
</tile><tile>
<thumb>Pictures/Image16_thumbnail.jpg</thumb>
<pic>Pictures/Image16.jpg</pic>
<cap>Desert</cap>
</tile><tile>
<thumb>Pictures/Image17_thumbnail.jpg</thumb>
<pic>Pictures/Image17.jpg</pic>
<cap>Thunder</cap>
</tile><tile>
<thumb>Pictures/Image18_thumbnail.jpg</thumb>
<pic>Pictures/Image18.jpg</pic>
<cap>Greeny Island</cap>
</tile><tile>
<thumb>Pictures/Image19_thumbnail.jpg</thumb>
<pic>Pictures/Image19.jpg</pic>
<cap>Squirrel</cap>
</tile><tile>
<thumb>Pictures/Image20_thumbnail.jpg</thumb>
<pic>Pictures/Image20.jpg</pic>
<cap>Mountain House</cap>
</tile>
<tile>
<thumb>Pictures/Image21_thumbnail.jpg</thumb>
<pic>Pictures/Image21.jpg</pic>
<cap>Sea heart</cap>
</tile><tile>
<thumb>Pictures/Image22_thumbnail.jpg</thumb>
<pic>Pictures/Image22.jpg</pic>
<cap>Mountain</cap>
</tile>
<tile>
<thumb>Pictures/Image23_thumbnail.jpg</thumb>
<pic>Pictures/Image23.jpg</pic>
<cap>Sunset</cap>
</tile><tile>
<thumb>Pictures/Image24_thumbnail.jpg</thumb>
<pic>Pictures/Image24.jpg</pic>
<cap>Lavender Flower</cap>
</tile><tile>
<thumb>Pictures/Image25_thumbnail.jpg</thumb>
<pic>Pictures/Image25.jpg</pic>
<cap>Village Life</cap>
</tile><tile>
<thumb>Pictures/Image26_thumbnail.jpg</thumb>
<pic>Pictures/Image26.jpg</pic>
<cap>Grass Tree</cap>
</tile><tile>
<thumb>Pictures/Image27_thumbnail.jpg</thumb>
<pic>Pictures/Image27.jpg</pic>
<cap>Golden Grass</cap>
</tile><tile>
<thumb>Pictures/Image28_thumbnail.jpg</thumb>
<pic>Pictures/Image28.jpg</pic>
<cap>Evening Sky</cap>
</tile><tile>
<thumb>Pictures/Image29_thumbnail.jpg</thumb>
<pic>Pictures/Image29.jpg</pic>
<cap>Cloud Formation</cap>
</tile><tile>
<thumb>Pictures/Image30_thumbnail.jpg</thumb>
<pic>Pictures/Image30.jpg</pic>
<cap>Bacterial Flower</cap>
</tile><tile>
<thumb>Pictures/Image31_thumbnail.jpg</thumb>
<pic>Pictures/Image31.jpg</pic>
<cap>Rainbow Sky</cap>
</tile>
</gallery>

Now run the program.

Tags: ,

Create a Magnifying Effect using Flash actionscript 3.0

Final View:

Step-1: Open a new document in flash in the size of 690X390px.

Step-2: Import (ctrl+r) an image in the same size of document size to the stage in layer-1.

magnifying-effect-using-Flash-a
image-567

Step-3: Select the image and convert it into movieclip (F8) and name it as “bg_mc”.

Step-4: create a layer-2 and draw a square fill it with gradient as below. Convert it into movieclip and name it as “map_mc”.

magnifying-effect-using-Flash-b
image-568

Make a double click on map_mc and inside the map_mc symbol create layer-2. Draw the gradient rectangle in green as like below and change it to movieclip.

magnifying-effect-using-Flash-c
image-569

Step-5: In layer-3 import one image like magnifying lens (I created this lens in Photoshop).. Convert it into movieclip and name it as “lens_mc”.

magnifying-effect-using-Flash-d
image-570

Step-6: In layer-4, select key frame one and press F9 to write the following actionscript:

var dPoint:Point = new Point(0, 0);

var dMap:BitmapData = new BitmapData(map_mc.width, map_mc.height, true, 0x808080)

dMap.draw(map_mc);

removeChild(map_mc);

var dFilter:DisplacementMapFilter = new DisplacementMapFilter ();

dFilter.scaleX         = 60        // pixel displacement force on X
dFilter.scaleY         = 50        // pixel displacement force on Y
dFilter.componentX     = 2            // or BitmapDataChannel.RED
dFilter.componentY     = 4            // or BitmapDataChannel.GREEN
dFilter.mode        = “color”    // or DisplacementMapFilterMode.COLOR / WRAP / CLAMP / IGNORE
dFilter.color        = 0x000000    // color of pixels when source is empty
dFilter.alpha         = 0            // alpha of colored pixels when source is empty
dFilter.mapPoint    = dPoint;    // position of the filters effect area
dFilter.mapBitmap    = dMap;        // map of colored pixels that controls the displacement

bg_mc.filters = [dFilter]

bg_mc.addEventListener(Event.ENTER_FRAME, onFrame)

function onFrame(e:Event){
dPoint.x += ((mouseX-map_mc.width/3)-dPoint.x)*0.4
dPoint.y += ((mouseY-map_mc.height/3)-dPoint.y)*0.4
lens_mc.x = dPoint.x-8
lens_mc.y = dPoint.y-8
dFilter.mapPoint = dPoint
bg_mc.filters = [dFilter]
}

Now run the program.

Tags: , ,

3D Particles rotation in flash

1. Open a new document and set background color as black.

2. Select Layer-1, Keyframe 1. Press F9 to write the following action script. I have explained the code in the comments.
import fl.motion.easing.Quartic;
import fl.motion.easing.Bounce;
import fl.motion.Animator3D;
import main.submain.loaders.*;
import main.submain.bitmapUtilities.PictureAtomizer;
import main.submain.objects.Particle3D;
import main.submain.geom3D.*;
import main.submain.display.*;
var picURLString:Array; // var is a variables, picURLString is a type and array is an atrribute
var picLoader:PictureLoader;
var pic:Array;
var atomizer:PictureAtomizer;
var particles:Array;
var blur:BlurFilter;
var darken:ColorTransform;
var board:RotatingParticleBoard;
var boardRect:Rectangle;
var filterPoint:Point;
var p:Particle3D;
var param:Number;

//////////////////////////////////////////////////
init(); // function name
//////////////////////////////////////////////////
function init():void {
picURLString= [“image/violet.jpg”]; //path of image
picLoader = new PictureLoader();
board = new RotatingParticleBoard(500,340,true, 0x00000000, 500); //set the width and height of rectangle box
board.setDepthDarken(-10,-80,1.5); // brightens and darken the image
board.makeFrame(1,0xffffff,5); // stroke and color of rectangle box
board.holder.x = stage.stageWidth/2 – board.width/2; // position of rectangle box in x-axis
board.holder.y = stage.stageHeight/2 – board.height/2; //position of rectangle box in y-axis
//set the starting rotation:
board.currentQ = new Quaternion(Math.cos(Math.PI/12), Math.sin(Math.PI/2)/Math.sqrt(2),0,-Math.sin(Math.PI/5)/Math.sqrt(2));
//set the automatic rotation to use while mouse is not dragging:
board.autoQuaternion = new Quaternion(Math.cos(Math.PI/300),0,Math.sin(Math.PI/300),0);
blur = new BlurFilter(50,50);
darken = new ColorTransform(500,1,1,0.9); // RGB colors and 0.9 gives the smoke effect
boardRect = new Rectangle(0,0,board.width,board.height);
filterPoint = new Point(0,0);
//add following code to see arcball silhouette:
/*
var ballOutline:Shape = new Shape();
ballOutline.graphics.lineStyle(1,0×888888);
ballOutline.graphics.drawCircle(0,0,board.arcballRad);
ballOutline.x = board.width/2;
ballOutline.y = board.height/2;
board.holder.addChild(ballOutline);
*/
picLoader.addEventListener(PictureLoader.ALL_PICS_LOADED, createParticles);
picLoader.loadPics(picURLString);
}
function createTextLabels():void {
var box:TextField = new TextField();
var format:TextFormat = new TextFormat(“Times New Roman”,16,0xffffff);
box.defaultTextFormat = format;
box.text = String(particles.length)+ ” particles.”;
box.x = board.holder.x+1;
box.y = board.holder.y+board.height+5;
stage.addChild(box);
var box2:TextField = new TextField();
box2.defaultTextFormat = format;
box2.multiline = false;
box2.autoSize = TextFieldAutoSize.RIGHT;
box2.x = board.holder.x+board.width-5-box2.width;
box2.y = board.holder.y+board.height+5;
stage.addChild(box2);
var box3:TextField = new TextField();
box3.defaultTextFormat = format;
box3.multiline = false;
box3.autoSize = TextFieldAutoSize.CENTER;
box3.text = “Drag the mouse to rotate”;
box3.x = board.holder.x+board.width/2-box3.width/2;
box3.y = board.holder.y-25;
stage.addChild(box3);
}
function createParticles(evt:Event):void {
pic = picLoader.picArray;
picLoader.removeEventListener(PictureLoader.ALL_PICS_LOADED, createParticles);
atomizer = new PictureAtomizer();
atomizer.sampling = 1;
atomizer.spread = 1.50;
atomizer.sampleFuzzX = 0;
atomizer.sampleFuzzY = 0;
atomizer.originX = Math.floor(pic[0].width/2);
atomizer.originY = Math.floor(pic[0].height/2);
atomizer.addEventListener(PictureAtomizer.PARTICLES_CREATED, go);
atomizer.createParticles(pic[0]);
}
function go(evt:Event):void {
particles = atomizer.particleArray;
atomizer.setPositionsByPic(0,0,0); //center position
stage.addChild(board.holder);
createTextLabels();
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}
function onEnter(evt:Event):void {
//Viewpoint-independent changes to particle positions. Here we present an example of each particle oscillating in the z direction, with amplitude related to the luminance of the particle. //
param = 0.65*Math.min(1.75,Math.max(0,(1-Math.cos(getTimer()*.0003)-0.25*Math.cos(getTimer()*.0006))));
for (var i:Number = 0; i<= particles.length – 1; i++) {
p = particles[i];
p.z = param*(p.lum-128);
}
//apply Filters to effect fade-out of old pixels
board.bitmapData.applyFilter(board.bitmapData, boardRect, filterPoint, blur);
board.bitmapData.colorTransform(boardRect,darken);
//draw particles
board.drawParticles(particles);
}

3. Here the path of folder name is very important. So give the proper name to your folder and files and give the same path name in actionscript too. Keep your fla file in separate folder name it as your wish like “3Dparticles” and inside this folder create one folder in the name of “Image”. Place all your required pictures in this folder.

4. Create one folder inside the “3Dparticles” folder in the name of “main”. Again create one “submain” folder within the “main”.

5. it’s time to create five folders inside the “submain”. Name it as bitmapUtilities, display, geom3D, loaders, and objects.

6. Open actionscript file by press ctrl+n. Copy and paste the following code and save it as “PictureAtomizer” in “bitmapUtilities”:

package main.submain.bitmapUtilities {
import flash.display.*;
import flash.events.*;
import main.submain.geom3D.*;
import main.submain.objects.Particle3D;
public class PictureAtomizer extends EventDispatcher {
public static const PARTICLES_CREATED:String=”particlesCreated”;
public var pic:Bitmap;
public var sampling:Number;
public var spread:Number;
public var originX:Number;
public var originY:Number;
public var sampleFuzzX:Number;
public var sampleFuzzY:Number;
private var _particleArray:Array;
public function PictureAtomizer(inputSampling=1, inputSpread=1, inputOriginX=0, inputOriginY=0, inputFuzzX=0, inputFuzzY=0):void {
this.sampling = inputSampling;
this.spread = inputSpread;
this.originX = inputOriginX;
this.originY = inputOriginY;
this.sampleFuzzX = inputFuzzX;
this.sampleFuzzY = inputFuzzY;
this._particleArray = [];
}
public function createParticles(inputPic:Bitmap):void {
var c:uint;
var m:Number;
var num:Number = 0;
var x0:Number;
var y0:Number;
this.pic = inputPic;
//separate picture pixels into layers
for (var i:Number=0; i<=pic.width-1; i = i + sampling) {
for (var j:Number=0; j<=pic.height-1; j = j + sampling) {
//read pixel (i,j)
x0 = i + sampleFuzzX*sampling*(2*Math.random()-1);
y0 = j + sampleFuzzY*sampling*(2*Math.random()-1);
//create particle
c = pic.bitmapData.getPixel32(x0,y0);
var p:Particle3D = new Particle3D(c);
//set picture-based coordinates
p.picX = spread*(x0 – originX);
p.picY = spread*(y0 – originY);
//add to array
this.particleArray.push(p);
}
}
dispatchEvent(new Event(PictureAtomizer.PARTICLES_CREATED));
}
public function setProjectionCoords(fLen:Number):void {
var m:Number;
var p:Particle3D;
for (var t=0; t<= _particleArray.length – 1; t++) {
p = _particleArray[t];
m = fLen/(fLen – p.w);
p.projX = p.u*m + originX;
p.projY = p.v*m + originY;
}
}
public function setPositionsByPic(offsetX:Number, offsetY:Number, z0:Number):void {
var p:Particle3D;
for (var t=0; t<= _particleArray.length – 1; t++) {
p = _particleArray[t];
p.x = p.picX + offsetX;
p.y = p.picY + offsetY;
p.z = z0;
}
}
public function setGlobalAlpha(globalAlpha:Number):void {
var c:uint;
var p:Particle3D;
trace(_particleArray.length);
for (var t=0; t<= _particleArray.length – 1; t++) {
p = _particleArray[t];
p.setColor((uint(255*globalAlpha) << 24) | (p.color & 0x00FFFFFF));
}
}

public function buildDestinationArrays(numDestinations:Number):void {
var p:Particle3D;
for (var t=0; t<= _particleArray.length – 1; t++) {
p = _particleArray[t];
for (var n:Number = 0; n <= numDestinations-1; n++) {
var thisPoint3D:Point3D = new Point3D();
p.dest.push(thisPoint3D);
}
}
}
public function get particleArray():Array {
return _particleArray;
}
}
}

7. Again open actionscript file by press ctrl+n. Copy and paste the following code and save it as “ParticleBoard” in “display”:
package main.submain.display {
import flash.display.*;
import main.submain.objects.Particle3D;
import main.submain.geom3D.*;
public class ParticleBoard extends Bitmap {
public var zBuffer:Array;
public var fLen:Number;
public var projOriginX:Number;
public var projOriginY:Number;
//darkening related variables
private var useDepthDarken:Boolean;
private var A:Number;
private var expRate:Number;
private var maxBrighten:Number;
private var bgColor;
//Vars used in functions
private var f:Number;
private var m:Number;
private var dColor:uint;
private var intX:int;
private var intY:int;
private var p:Particle3D;
private var X2:Number;
private var Y2:Number;
private var Z2:Number;
private var wX:Number;
private var wY:Number;
private var wZ:Number;
private var xX:Number;
private var xY:Number;
private var xZ:Number;
private var yY:Number;
private var yZ:Number;
private var zZ:Number;
public var frame:Shape;
public var holder:Sprite;
/*
frame = new Shape();
frame.graphics.lineStyle(2,0×444444);
frame.graphics.drawRect(0,0,board.width,board.height);
frame.x = 0;
frame.y = 0;
boardHolder = new Sprite();
boardHolder.x = stage.stageWidth/2 – board.width/2;
boardHolder.y = stage.stageHeight/2 – board.height/2;
stage.addChild(boardHolder);
boardHolder.addChild(board);
boardHolder.addChild(frame);
*/
public function ParticleBoard(w, h, transp=true, fillColor = 0x00000000, _fLen=200) {
var thisData:BitmapData = new BitmapData(w, h, transp, fillColor)
this.bitmapData = thisData;
this.zBuffer = [];
this.useDepthDarken = false; //changed to true in setDepthDarken
this.projOriginX = w/2;
this.projOriginY = h/2;
this.fLen = _fLen;
this.bgColor = fillColor;
this.holder = new Sprite();
this.holder.addChild(this);
this.x = 0;
this.y = 0;
}
public function makeFrame(thick:Number, c:uint, inputAlpha:Number):void {
this.frame = new Shape();
this.frame.graphics.lineStyle(thick, c, inputAlpha);
this.frame.graphics.drawRect(0,0,this.width,this.height);
this.frame.x = 0;
this.frame.y = 0;
this.holder.addChild(frame);
}
public function setDepthDarken(unityDepth:Number, halfDepth:Number, _maxBrighten):void {
this.useDepthDarken = true;
this.A = Math.pow(2, unityDepth/(halfDepth-unityDepth));
this.expRate = Math.LN2/(unityDepth-halfDepth);
this.maxBrighten = _maxBrighten;
}
public function clearBoard(particles:Array):void {
for (var i:Number = 0; i<=particles.length-1; i++) {
p = particles[i];
if (p.onScreen) {
intX = int(p.projX);
intY = int(p.projY);
zBuffer[intX+this.height*intY] = Number.NEGATIVE_INFINITY;
//could also insert the code below to erase pixels, but my method has been to use a blur filter and a colorTransform applied to whole bitmap, which creates “ghost” which fades out after a few frames. this.bitmapData.setPixel32(intX, intY, bgColor);
}
}
}//end of clearBoard
public function drawParticles(particles:Array, q:Quaternion):void {
//clear the zBuffer
clearBoard(particles);
for (var i:Number = 0; i<=particles.length-1; i++) {
p = particles[i];
//viewpoint-relative coordinates found by quaternion rotation. Quaternion has been converted to rotation matrix, using common subexpressions for efficiency. X2 = 2*q.x;
Y2 = 2*q.y;
Z2 = 2*q.z;
wX = q.w*X2;
wY = q.w*Y2;
wZ = q.w*Z2;
xX = q.x*X2;
xY = q.x*Y2;
xZ = q.x*Z2;
yY = q.y*Y2;
yZ = q.y*Z2;
zZ = q.z*Z2;
p.u = (1-(yY+zZ))*p.x + (xY-wZ)*p.y + (xZ+wY)*p.z;
p.v = (xY+wZ)*p.x + (1-(xX+zZ))*p.y + (yZ-wX)*p.z;
p.w = (xZ-wY)*p.x + (yZ+wX)*p.y + (1-(xX+yY))*p.z;
//Projection coordinates
m = fLen/(fLen – p.w);
p.projX = p.u*m + projOriginX;
p.projY = p.v*m + projOriginY;
//test if particle is in viewable region
if ((p.projX > this.width)||(p.projX<0)||(p.projY<0)||(p.projY>this.height)||(p.w>fLen-1)) {
p.onScreen = false;
}
else {
p.onScreen = true;
}
//drawing
intX = int(p.projX);
intY = int(p.projY);
if (p.onScreen) {
if (!(p.w < zBuffer[intX+this.height*intY])) {
if (this.useDepthDarken) {
//position-based darkening – exponential
f = A*Math.exp(expRate*p.w);
if (f>maxBrighten) {
f = maxBrighten;
}
dColor = (0xFF000000) |(Math.min(255,f*p.red) << 16) | (Math.min(255,f*p.green) << 8 ) | (Math.min(255,f*p.blue));
this.bitmapData.setPixel32(intX, intY, dColor);
}
else {
this.bitmapData.setPixel32(intX, intY, p.color);
}

this.zBuffer[intX+this.height*intY] = p.w;
}
}
}
}//end of drawParticles
}//end of class definition
}

8. Again open actionscript file by press ctrl+n. Copy and paste the following code and save it as “RotatingParticleBoard” in “display”:

package main.submain.display {
import flash.display.*;
import flash.events.*;
import main.submain.objects.Particle3D;
import main.submain.geom3D.*;
import flash.events.MouseEvent;
public class RotatingParticleBoard extends Bitmap {
public var zBuffer:Array;
public var fLen:Number;
public var projOriginX:Number;
public var projOriginY:Number;
//darkening related variables
private var useDepthDarken:Boolean;
private var A:Number;
private var expRate:Number;
private var maxBrighten:Number;
private var bgColor;
//Vars used in functions
private var f:Number;
private var m:Number;
private var dColor:uint;
private var intX:int;
private var intY:int;
private var p:Particle3D;
private var X2:Number;
private var Y2:Number;
private var Z2:Number;
private var wX:Number;
private var wY:Number;
private var wZ:Number;
private var xX:Number;
private var xY:Number;
private var xZ:Number;
private var yY:Number;
private var yZ:Number;
private var zZ:Number;
public var frame:Shape;
public var holder:Sprite;
private var v1:Point3D;
private var v2:Point3D;
private var rSquare:Number;
private var invR:Number;
private var mouseDragging:Boolean;
private var lastQ:Quaternion;
private var changeQ:Quaternion;
private var requestQ:Quaternion;
private var inside:Boolean;
private var numRadii:Number;
public var arcballRad:Number;
public var currentQ:Quaternion;
public var autoQuaternion:Quaternion;
public var easingRatio:Number;
private var s:Number;
public function RotatingParticleBoard(w, h, transp=true, fillColor = 0x00000000, _fLen=200) {
var thisData:BitmapData = new BitmapData(w, h, transp, fillColor)
this.bitmapData = thisData;
this.zBuffer = [];
this.useDepthDarken = false; //changed to true in setDepthDarken
this.projOriginX = w/2;
this.projOriginY = h/2;
this.fLen = _fLen;
this.bgColor = fillColor;
this.holder = new Sprite();
this.holder.addChild(this);
this.x = 0;
this.y = 0;
this.arcballRad = 0.5*Math.sqrt(Math.pow(w,2)+Math.pow(h,2));
this.lastQ = new Quaternion();
this.currentQ = new Quaternion(1,0,0,0);
this.autoQuaternion = new Quaternion(1,0,0,0);
this.lastQ = this.currentQ.clone();
this.requestQ = new Quaternion();
this.changeQ = new Quaternion(1,0,0,0);
this.v1 = new Point3D;
this.v2 = new Point3D;
this.mouseDragging = false;
this.easingRatio = 0.4;
this.holder.addEventListener(Event.ADDED_TO_STAGE, addListeners);
}
private function addListeners(evt:Event):void {
this.holder.removeEventListener(Event.ADDED_TO_STAGE, addListeners);
this.holder.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
this.holder.root.addEventListener(MouseEvent.MOUSE_UP, onUp);
}
public function makeFrame(thick:Number, c:uint, inputAlpha:Number):void {
this.frame = new Shape();
this.frame.graphics.lineStyle(thick, c, inputAlpha);
this.frame.graphics.drawRect(0,0,this.width,this.height);
this.frame.x = 0;
this.frame.y = 0;
this.holder.addChild(frame);
}
public function setDepthDarken(unityDepth:Number, halfDepth:Number, _maxBrighten):void {
this.useDepthDarken = true;
this.A = Math.pow(2, unityDepth/(halfDepth-unityDepth));
this.expRate = Math.LN2/(unityDepth-halfDepth);
this.maxBrighten = _maxBrighten;
}
public function clearBoard(particles:Array):void {
for (var i:Number = 0; i<=particles.length-1; i++) {
p = particles[i];
if (p.onScreen) {
intX = int(p.projX);
intY = int(p.projY);
zBuffer[intX+this.height*intY] = Number.NEGATIVE_INFINITY;
//could also insert the code below to erase pixels, but my method has been to use a blur filter and a colorTransform applied to whole bitmap, which creates “ghost” which fades out after a few frames. this.bitmapData.setPixel32(intX, intY, bgColor);
}
}
}//end of clearBoard
public function drawParticles(particles:Array):void {
clearBoard(particles);
///////////
//viewpoint change by mouse
if (mouseDragging) {
v2.x = (holder.mouseX-projOriginX)/arcballRad;
v2.y = (holder.mouseY-projOriginY)/arcballRad;
rSquare = v2.x*v2.x + v2.y*v2.y;
//for mouse position outside Arcball perimeter:
if (rSquare > 1) {
invR = 1/Math.sqrt(rSquare);
v2.x = v2.x*invR;
v2.y = v2.y*invR;
v2.z = 0;
}
//for mouse position inside Arcball perimeter:
else {
v2.z = Math.sqrt(1 – rSquare);
inside = true;
}
//interpret mouse movement as request for rotation change
requestQ.w = v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
requestQ.x = v1.y*v2.z – v2.y*v1.z;
requestQ.y = -v1.x*v2.z + v2.x*v1.z;
requestQ.z = v1.x*v2.y – v2.x*v1.y;
//smooth movement is accomplished by rotating only 40% towards the requested rotation in each frame. After about ten frames, the rotation will be within 1% of the requested rotation.
changeQ.w += easingRatio*(requestQ.w – changeQ.w);
changeQ.x += easingRatio*(requestQ.x – changeQ.x);
changeQ.y += easingRatio*(requestQ.y – changeQ.y);
changeQ.z += easingRatio*(requestQ.z – changeQ.z);
//ensure that the change quaternion is a unit quaternion:
s = 1/Math.sqrt(changeQ.w*changeQ.w +changeQ.x*changeQ.x+changeQ.y*changeQ.y+changeQ.z*changeQ.z);
changeQ.w *= s;
changeQ.x *= s;
changeQ.y *= s;
changeQ.z *= s;
}
else {
lastQ = currentQ.clone();
changeQ.w = autoQuaternion.w;
changeQ.x = autoQuaternion.x;
changeQ.y = autoQuaternion.y;
changeQ.z = autoQuaternion.z;
}
//find current resultant rotation by quaternion multiplication of
lastQ and changeQ
currentQ.w = changeQ.w*lastQ.w – changeQ.x*lastQ.x – changeQ.y*lastQ.y – changeQ.z*lastQ.z;
currentQ.x = changeQ.w*lastQ.x + lastQ.w*changeQ.x + changeQ.y*lastQ.z – lastQ.y*changeQ.z;
currentQ.y = changeQ.w*lastQ.y + lastQ.w*changeQ.y – changeQ.x*lastQ.z + lastQ.x*changeQ.z;
currentQ.z = changeQ.w*lastQ.z + lastQ.w*changeQ.z + changeQ.x*lastQ.y – lastQ.x*changeQ.y;
///////////
for (var i:Number = 0; i<=particles.length-1; i++) {
p = particles[i];
//viewpoint-relative coordinates found by quaternion rotation. Quaternion has been converted to rotation matrix, usingcommon subexpressions for efficiency.
X2 = 2*currentQ.x;
Y2 = 2*currentQ.y;
Z2 = 2*currentQ.z;
wX = currentQ.w*X2;
wY = currentQ.w*Y2;
wZ = currentQ.w*Z2;
xX = currentQ.x*X2;
xY = currentQ.x*Y2;
xZ = currentQ.x*Z2;
yY = currentQ.y*Y2;
yZ = currentQ.y*Z2;
zZ = currentQ.z*Z2;
p.u = (1-(yY+zZ))*p.x + (xY-wZ)*p.y + (xZ+wY)*p.z;
p.v = (xY+wZ)*p.x + (1-(xX+zZ))*p.y + (yZ-wX)*p.z;
p.w = (xZ-wY)*p.x + (yZ+wX)*p.y + (1-(xX+yY))*p.z;
//Projection coordinates
m = fLen/(fLen – p.w);
p.projX = p.u*m + projOriginX;
p.projY = p.v*m + projOriginY;
//test if particle is in viewable region
if ((p.projX > this.width)||(p.projX<0)||(p.projY<0)||(p.projY>this.height)||(p.w>fLen-1)) {
p.onScreen = false;
}
else {
p.onScreen = true;
}
//drawing
intX = int(p.projX);
intY = int(p.projY);
if (p.onScreen) {
if (!(p.w < zBuffer[intX+this.height*intY])) {
if (this.useDepthDarken) {
//position-based darkening – exponential
f = A*Math.exp(expRate*p.w);
if (f>maxBrighten) {
f = maxBrighten;
}
dColor = (0xFF000000) |(Math.min(255,f*p.red) << 16) | (Math.min(255,f*p.green) << 8) | (Math.min(255,f*p.blue));
this.bitmapData.setPixel32(intX, intY, dColor);
}
else {
this.bitmapData.setPixel32(intX, intY, p.color);
}
this.zBuffer[intX+this.height*intY] = p.w;
}
}
}
}//end of drawParticles
private function onDown(evt:MouseEvent):void {
mouseDragging = true;
changeQ = new Quaternion(1,0,0,0);
lastQ = currentQ.clone();
v1.x = (holder.mouseX-projOriginX)/arcballRad;
v1.y = (holder.mouseY-projOriginY)/arcballRad;
rSquare = v1.x*v1.x + v1.y*v1.y;
if (rSquare > 1) {
invR = 1/Math.sqrt(rSquare);
v1.x = v1.x*invR;
v1.y = v1.y*invR;
v1.z = 0;
inside = false;
}
else {
v1.z = Math.sqrt(1 – rSquare);
inside = true;
}
}
private function onUp(evt:MouseEvent):void {
mouseDragging = false;
}
}//end of class definition
}

9. Again open actionscript file by press ctrl+n. Copy and paste the following code and save it as “Point3D” in “geom3D”:

package main.submain.geom3D {
public class Point3D {
public var x:Number;
public var y:Number;
public var z:Number;
public function Point3D(x1=0,y1=0,z1=0):void {
this.x = x1;
this.y = y1;
this.z = z1;
}
}
}

10. Again open actionscript file by press ctrl+n. Copy and paste the following code and save it as “Quaternion” in “geom3D”:

package main.submain.geom3D {
public class Quaternion {
public var w;
public var x;
public var y;
public var z;
public function Quaternion(_w=0,_x=0, _y=0, _z=0) {
this.w = _w;
this.x = _x;
this.y = _y;
this.z = _z;
}
public function clone():Quaternion {
return new Quaternion(this.w, this.x, this.y, this.z);
}}}

11. Again open actionscript file by press ctrl+n. Copy and paste the following code and save it as “IndexedLoader” in “loaders”:

package main.submain.loaders {
import flash.display.Loader;
public class IndexedLoader extends Loader {
public var which:Number;
public var done:Boolean;
function IndexedLoader(inputIndex):void {
this.which = inputIndex;
this.done = false;
}}}

12. Again open actionscript file by press ctrl+n. Copy and paste the following code and save it as “PictureLoader” in “loaders”:

package main.submain.loaders {
import flash.display.*;
import flash.events.*;
import flash.net.URLRequest;
import main.submain.loaders.IndexedLoader;
public class PictureLoader extends EventDispatcher {
public static const ALL_PICS_LOADED:String=”allPicsLoaded”;
private function dispatch():void {
dispatchEvent(new Event(PictureLoader.ALL_PICS_LOADED));
}
public var picURLArray:Array = [];
private var picLoader:Array = [];
private var pic:Array=[];
private var loadCount:Number;
public var failPicSize:Number;
public var useFailPic:Boolean;
public function PictureLoader(_useFailPic = true, _failPicSize = 16) {
this.useFailPic = _useFailPic;
this.failPicSize = _failPicSize;
}
public function loadPics(inputURLArray:Array):void {
picURLArray = inputURLArray;
pic = [];
loadCount = 0;
setUpLoaders();
}
private function failPic():Sprite {
var thisPic:Sprite = new Sprite();
thisPic.graphics.lineStyle(2,0xdddddd);
thisPic.graphics.beginFill(0x000000);
thisPic.graphics.drawRect(0,0,failPicSize,failPicSize);
thisPic.graphics.endFill();
thisPic.graphics.lineStyle(2,0xdd0000);
thisPic.graphics.moveTo(2,2);
thisPic.graphics.lineTo(failPicSize-2,failPicSize-2);
thisPic.graphics.moveTo(failPicSize-2,2);
thisPic.graphics.lineTo(2,failPicSize-2);
return thisPic;
}
private function cleanUp():void {
var errorPic:Array = [];
for (var n:Number=0; n<= picURLArray.length-1; n++) {
if (pic[n]==null) {
//trace(“Picture “+String(n)+” not loaded.”);
picLoader[n].contentLoaderInfo.removeEventListener(Event.INIT, initListener);
picLoader[n].contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
errorPic.push(n);
}
}
if (useFailPic) {
//place fail pic in bad spots
if (errorPic.length != 0) {
for (n = 0; n<= errorPic.length – 1; n++) {
var thisBitmapData:BitmapData = new BitmapData(failPicSize, failPicSize);
var thisBitmap:Bitmap = new Bitmap(thisBitmapData);
thisBitmapData.draw(failPic());
pic[errorPic[n]] = thisBitmap;
}
}
}
else {
//remove error pics from pic array
if (errorPic.length != 0) {
for (n = 0; n<= errorPic.length – 1; n++) {
pic.splice(errorPic[n],1);
}
}
}
}
private function setUpLoaders():void {
var thisURL:URLRequest; //create a loader for each picture, to load simultaneously.
for (var n:Number=0; n<= picURLArray.length-1; n++) {
var thisLoader:IndexedLoader = new IndexedLoader(n);
picLoader.push(thisLoader);
picLoader[n].load(new URLRequest(picURLArray[n]));
picLoader[n].contentLoaderInfo.addEventListener(Event.INIT, initListener);
picLoader[n].contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
}
}
private function errorHandler(evt:ErrorEvent):void {
loadCount++;
if (loadCount == picURLArray.length) {
cleanUp();
dispatch();
}
}
private function initListener(evt:Event):void {
//copy loaded picture to pic array
try {
var n:Number = evt.currentTarget.loader.which;
//trace(“picture “+String(n)+” loaded.”);
pic[n] = Bitmap(picLoader[n].content);
}
catch (err:Error) {
//trace(“picture “+String(n)+” unsuccessful.”);
}
//remove event listener
picLoader[n].contentLoaderInfo.removeEventListener(Event.INIT, initListener);
loadCount++;
if (loadCount == picURLArray.length) {
cleanUp();
dispatch();
}
}
public function get picArray():Array {
return pic;
}
}
}

12. Again open actionscript file by press ctrl+n. Copy and paste the following code and save it as “Particle3D” in “objects”:

package main.submain.objects {
import flash.display.*;
import main.submain.geom3D.*;
public class Particle3D extends Point3D {
//links, for creating linked lists
public var next:Particle3D;
public var prev:Particle3D;
public var onScreen:Boolean;
//velocity and acceleration vectors
public var vel:Point3D = new Point3D();
public var accel:Point3D = new Point3D();
public var lastX:Number;
public var lastY:Number;
public var lastZ:Number;
//projected coordinates
public var projX:Number;
public var projY:Number;
//coords WRT viewpoint axes
public var u:Number;
public var v:Number;
public var w:Number;
//location in source picture
public var picX:Number;
public var picY:Number;
//destination array
public var dest:Array;
//attributes
public var color:uint;
public var red:Number;
public var green:Number;
public var blue:Number;
public var lum:Number;
public var alpha:Number;
public var initColor:uint;
public var initRed:Number;
public var initGreen:Number;
public var initBlue:Number;
public var initLum:Number;
public var destColor:uint;
public var destRed:Number;
public var destGreen:Number;
public var destBlue:Number;
public var destLum:Number;
public var colorChanging:Boolean;
function Particle3D(thisColor=0xFFFFFFFF):void {
this.dest = [];
this.color = thisColor;
this.red = getRed(thisColor);
this.green = getGreen(thisColor);
this.blue = getBlue(thisColor);
this.alpha = getAlpha(thisColor);
this.lum = 0.2126*this.red + 0.7152*this.green + 0.0722*this.blue;
this.colorChanging = false;
this.onScreen = true;
}
public function setColor(thisColor):void {
this.color = thisColor;
this.red = getRed(thisColor);
this.green = getGreen(thisColor);
this.blue = getBlue(thisColor);
this.alpha = getAlpha(thisColor);
this.lum = 0.2126*this.red + 0.7152*this.green + 0.0722*this.blue;
}
public function getAlpha(c):Number {
return Number((c >> 24) & 0xFF);
}
public function getRed(c):Number {
return Number((c >> 16) & 0xFF);
}
public function getGreen(c):Number {
return Number((c >> 8) & 0xFF);
}
public function getBlue(c):Number {
return Number(c & 0xFF);
}
}
}

Run the program.

Tags:

3D Views of earth using flash

1. Open a new document in flash in the size of 700X500 pixels.

Views-of-earth-using-flash-1
image-494
10. In layer-6,  key-frame-1 write the following action-script. targetSpeed=0; speed=0; zoom=0;v mc_movie._Xscale=78; mc_movie._Yscale=78; mc_movie._x=mc_movie._width; startX=mc_movie._x; startScale=mc_movie._Xscale; guides._visible=false; 11. Select the layer-1 image and convert to movieclip then name it as mc_movie. Select the mc_movie and press F9 to write the following script. onClipEvent (keyDown) { keyPressed=Key.getCode(); if (keyPressed == Key.SHIFT) { _parent.zoom=1; } else if (keyPressed = Key.CONTROL) { _parent.zoom=-1; } } onClipEvent (keyUp) { if (_parent.zoom <>0)                   _parent.zoom=0; } onClipEvent (enterFrame) { zoom=_parent.zoom; if (zoom<>0) { if ( (zoom==1 and this._xScale<100 ) or (zoom==-1 and this._xScale>78) ) { saveWidth=_width; _xScale += zoom; _yScale += zoom; delta=(_width-saveWidth); } } } 12. select mc_movie and give edit in place option, again change it to movieclip, and name it as line_mc 13. Now create one layer above the line_mc and press F9 then write the following: line_mc._x=-line_mc._width+0.1; duplicateMovieClip (line_mc, “strip2”,1); strip2._x=0; strip2._y=line_mc._y; Press Ctrl+Enter to run the program.

Tags:

Flash Number Jumbler Game

Step-1 Open a new document in flash. Set the width and height across 300 pixels.

number-jumbler-game
image-473

Step-2 Set the background as you like. Create box like below in layer-1 and convert it into movieclip (f8) then name it as box1. Like that create 20 boxes in separate layers and name it as like box2, box3, ….. , box20. Now you have 20 layers in your document.

number-jumbler-game
image-474

Step-3 Create layer-21 and type 1 on box1 as like below. Remember that your text type should be dynamic and name it as s1 as variable in variable box (see the properties dialog box).

number-jumbler-game
image-475

number-jumbler-game
image-476

Step-4 Likewise creates 20 dynamic texts in 20 different layers and name it as s2, s3, …. , s20. Finally you have 40 layers. Now lock  layer-21 to layer-40.

Step-5 Select box1 and write the following code by press F9 to open the actionscript window:

onClipEvent (enterFrame)

{

this.onPress = function ()

{

var _loc1 = _root;

if (_loc1.s2 == ” ” || _loc1.s6 == ” ” || _loc1.s7 == ” “)

{

if (_loc1.s2 == ” “)

{

_loc1.s2 = _loc1.s1;

_loc1.box2._alpha = 100;

} // end if

if (_loc1.s6 == ” “)

{

_loc1.s6 = _loc1.s1;

_loc1.box6._alpha = 100;

} // end if

if (_loc1.s7 == ” “)

{

_loc1.s7 = _loc1.s1;

_loc1.box7._alpha = 100;

} // end if

_loc1.s1 = ” “;

this._alpha = 50;

} // end if

};

}

Code Explanation:

In line 6 if (_loc1.s2 == ” ” || _loc1.s6 == ” ” || _loc1.s7 == ” “)

_loc1 is a variable

s2, s6, s7 are represents dynamic text boxes and are adjacent to s1.

Step-6 Repeat step-5 for all boxes. The above code will change for each boxes. The changes you have make on variables and movieclip names according to adjacent boxes..

For example code for box12 will change as like follows (changes are highlighted):

onClipEvent (enterFrame)

{

this.onPress = function ()

{

var _loc1 = _root;

if (_loc1.s7 == ” ” || _loc1.s11 == ” ” || _loc1.s13 == ” ” || _loc1.s17 == ” “)

{

if (_loc1.s7 == ” “)

{

_loc1.s7 = _loc1.s12;

_loc1.box7._alpha = 100;

} // end if

if (_loc1.s11 == ” “)

{

_loc1.s11 = _loc1.s12; //comment:  _loc1.s12 denotes current box12

_loc1.box11._alpha = 100;

} // end if

if (_loc1.s13 == ” “)

{

_loc1.s13 = _loc1.s12; //comment:  _loc1.s12 denotes current box12

_loc1.box13._alpha = 100;

} // end if

if (_loc1.s17 == ” “)

{

_loc1.s17 = _loc1.s12; //comment:  _loc1.s12 denotes current box12

_loc1.box17._alpha = 100;

} // end if

_loc1.s12 = ” “;

this._alpha = 50;

} // end if

};

}

Note: Box 7 (6, 2, 8, 12), 8 (3, 7, 9, 13), 9(4, 8, 10, 14), 12 (7, 11, 13, 17), 13 (8, 12, 14, 18), 14(9, 13, 15, 19) will have four adjacent boxes

Step-8: Create layer-41 and type Collapse. Convert it into movieclip(F8) and name it as randomize (to change the numbers randomly). Write the following code on randomize movieclip by press F9 to open the actionscript window

number-jumbler-game
image-477

onClipEvent (load) {

_root.box20._alpha = 50;

_root.s1 = 12;

_root.s2 = 3;

_root.s3 = 9;

_root.s4 = 16;

_root.s5 = 1;

_root.s6 = 2;

_root.s7 = 8;

_root.s8 = 10;

_root.s9 = 11;

_root.s10 = 15;

_root.s11 = 4;

_root.s12 = 17;

_root.s13 = 13;

_root.s14 = 5;

_root.s15 = 14;

_root.s16 = 16;

_root.s17 = 6;

_root.s18 = 18;

_root.s19 = 7;

_root.s20 = ” “;

}

onClipEvent (load) {

getURL(“FSCommand:allowscale”, 0);

getURL(“FSCommand:showmenu”, 0);

getURL(“FSCommand:fullscreen”, 0);

}

onClipEvent (enterFrame) {

_root.randomize.onPress = function() {

var _loc1 = _root;

var _loc2 = this;

for (i=0; i<500; i++) {

s = random(20)+1;

switch (s) {

case 1 :

if (_loc1.s2 == ” ” || _loc1.s6 == ” ” || _loc1.s7 == ” “) {

if (_loc1.s2 == ” “) {

_loc1.s2 = _loc1.s1;

_loc1.box2._alpha = 100;

} // end if

if (_loc1.s6 == ” “) {

_loc1.s6 = _loc1.s1;

_loc1.box6._alpha = 100;

} // end if

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s1;

_loc1.box7._alpha = 100;

} // end if

_loc1.s1 = ” “;

this._alpha = 50;

} // end if

break;

case 2 :

if (_loc1.s1 == ” ” || _loc1.s3 == ” ” || _loc1.s7 == ” “) {

if (_loc1.s1 == ” “) {

_loc1.s1 = _loc1.s2;

_loc1.box1._alpha = 100;

} // end if

if (_loc1.s3 == ” “) {

_loc1.s3 = _loc1.s2;

_loc1.box3._alpha = 100;

} // end if

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s2;

_loc1.box7._alpha = 100;

} // end if

_loc1.s2 = ” “;

this._alpha = 50;

} // end if

break;

case 3 :

if (_loc1.s2 == ” ” || _loc1.s8 == ” ” || _loc1.s4 == ” “) {

if (_loc1.s2 == ” “) {

_loc1.s2 = _loc1.s3;

_loc1.box2._alpha = 100;

} // end if

if (_loc1.s8 == ” “) {

_loc1.s8 = _loc1.s3;

_loc1.box8._alpha = 100;

} // end if

if (_loc1.s4 == ” “) {

_loc1.s4 = _loc1.s3;

_loc1.box4._alpha = 100;

} // end if

_loc1.s3 = ” “;

this._alpha = 50;

} // end if

break;

case 4 :

if (_loc1.s3 == ” ” || _loc1.s9 == ” ” || _loc1.s5 == ” “) {

if (_loc1.s3 == ” “) {

_loc1.s3 = _loc1.s4;

_loc1.box3._alpha = 100;

} // end if

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s4;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s5 == ” “) {

_loc1.s5 = _loc1.s4;

_loc1.box5._alpha = 100;

} // end if

_loc1.s4 = ” “;

this._alpha = 50;

} // end if

break;

case 5 :

if (_loc1.s4 == ” ” || _loc1.s9 == ” ” || _loc1.s10 == ” “) {

if (_loc1.s4 == ” “) {

_loc1.s4 = _loc1.s5;

_loc1.box4._alpha = 100;

} // end if

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s5;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s10 == ” “) {

_loc1.s10 = _loc1.s5;

_loc1.box10._alpha = 100;

} // end if

_loc1.s5 = ” “;

this._alpha = 50;

} // end if

break;

case 6 :

if (_loc1.s1 == ” ” || _loc1.s11 == ” ” || _loc1.s7 == ” “) {

if (_loc1.s1 == ” “) {

_loc1.s1 = _loc1.s6;

_loc1.box1._alpha = 100;

} // end if

if (_loc1.s11 == ” “) {

_loc1.s11 = _loc1.s6;

_loc1.box11._alpha = 100;

} // end if

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s6;

_loc1.box7._alpha = 100;

} // end if

_loc1.s6 = ” “;

this._alpha = 50;

} // end if

break;

case 7 :

if (_loc1.s2 == ” ” || _loc1.s12 == ” ” || _loc1.s6 == ” ” || _loc1.s8 == ” “) {

if (_loc1.s2 == ” “) {

_loc1.s2 = _loc1.s7;

_loc1.box2._alpha = 100;

} // end if

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s7;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s6 == ” “) {

_loc1.s6 = _loc1.s7;

_loc1.box6._alpha = 100;

} // end if

if (_loc1.s8 == ” “) {

_loc1.s8 = _loc1.s7;

_loc1.box8._alpha = 100;

} // end if

_loc1.s7 = ” “;

this._alpha = 50;

} // end if

break;

case 8 :

if (_loc1.s3 == ” ” || _loc1.s7 == ” ” || _loc1.s9 == ” ” || _loc1.s13 == ” “) {

if (_loc1.s3 == ” “) {

_loc1.s3 = _loc1.s8;

_loc1.box3._alpha = 100;

} // end if

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s8;

_loc1.box7._alpha = 100;

} // end if

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s8;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s13 == ” “) {

_loc1.s13 = _loc1.s8;

_loc1.box13._alpha = 100;

} // end if

_loc1.s8 = ” “;

this._alpha = 50;

} // end if

break;

case 9 :

if (_loc1.s4 == ” ” || _loc1.s8 == ” ” || _loc1.s10 == ” ” || _loc1.s14 == ” “) {

if (_loc1.s4 == ” “) {

_loc1.s4 = _loc1.s9;

_loc1.box4._alpha = 100;

} // end if

if (_loc1.s8 == ” “) {

_loc1.s8 = _loc1.s9;

_loc1.box8._alpha = 100;

} // end if

if (_loc1.s10 == ” “) {

_loc1.s10 = _loc1.s9;

_loc1.box10._alpha = 100;

} // end if

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s9;

_loc1.box14._alpha = 100;

} // end if

_loc1.s9 = ” “;

this._alpha = 50;

} // end if

break;

case 10 :

if (_loc1.s15 == ” ” || _loc1.s9 == ” ” || _loc1.s5 == ” “) {

if (_loc1.s15 == ” “) {

_loc1.s15 = _loc1.s10;

_loc1.box15._alpha = 100;

} // end if

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s10;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s5 == ” “) {

_loc1.s5 = _loc1.s10;

_loc1.box5._alpha = 100;

} // end if

_loc1.s10 = ” “;

this._alpha = 50;

} // end if

break;

case 11 :

if (_loc1.s6 == ” ” || _loc1.s12 == ” ” || _loc1.s16 == ” “) {

if (_loc1.s6 == ” “) {

_loc1.s6 = _loc1.s11;

_loc1.box6._alpha = 100;

} // end if

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s11;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s16 == ” “) {

_loc1.s16 = _loc1.s11;

_loc1.box16._alpha = 100;

} // end if

_loc1.s11 = ” “;

this._alpha = 50;

} // end if

break;

case 12 :

if (_loc1.s7 == ” ” || _loc1.s11 == ” ” || _loc1.s13 == ” ” || _loc1.s17 == ” “) {

if (_loc1.s7 == ” “) {

_loc1.s7 = _loc1.s12;

_loc1.box7._alpha = 100;

} // end if

if (_loc1.s11 == ” “) {

_loc1.s11 = _loc1.s12;

_loc1.box11._alpha = 100;

} // end if

if (_loc1.s13 == ” “) {

_loc1.s13 = _loc1.s12;

_loc1.box13._alpha = 100;

} // end if

if (_loc1.s17 == ” “) {

_loc1.s17 = _loc1.s12;

_loc1.box17._alpha = 100;

} // end if

_loc1.s12 = ” “;

this._alpha = 50;

} // end if

break;

case 13 :

if (_loc1.s14 == ” ” || _loc1.s12 == ” ” || _loc1.s8 == ” ” || _loc1.s18 == ” “) {

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s13;

_loc1.box14._alpha = 100;

} // end if

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s13;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s8 == ” “) {

_loc1.s8= _loc1.s13;

_loc1.box8._alpha = 100;

} // end if

if (_loc1.s18 == ” “) {

_loc1.s18 = _loc1.s13;

_loc1.box18._alpha = 100;

} // end if

_loc1.s13 = ” “;

this._alpha = 50;

break;

case 14 :

if (_loc1.s9 == ” ” || _loc1.s13 == ” ” || _loc1.s15 == ” ” || _loc1.s19 == ” “) {

if (_loc1.s9 == ” “) {

_loc1.s9 = _loc1.s14;

_loc1.box9._alpha = 100;

} // end if

if (_loc1.s13 == ” “) {

_loc1.s13 = _loc1.s14;

_loc1.box13._alpha = 100;

} // end if

if (_loc1.s15 == ” “) {

_loc1.s15 = _loc1.s14;

_loc1.box15._alpha = 100;

} // end if

if (_loc1.s19 == ” “) {

_loc1.s19 = _loc1.s14;

_loc1.box19._alpha = 100;

} // end if

_loc1.s14 = ” “;

this._alpha = 50;

} // end if

break;

case 15 :

if (_loc1.s10 == ” ” || _loc1.s14 == ” ” || _loc1.s20 == ” “) {

if (_loc1.s10 == ” “) {

_loc1.s10 = _loc1.s15;

_loc1.box10._alpha = 100;

} // end if

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s15;

_loc1.box14._alpha = 100;

} // end if

if (_loc1.s20 == ” “) {

_loc1.s20 = _loc1.s15;

_loc1.box20._alpha = 100;

} // end if

_loc1.s15 = ” “;

this._alpha = 50;

} // end if

break;

case 16 :

if (_loc1.s11 == ” ” || _loc1.s12 == ” ” || _loc1.s17 == ” “) {

if (_loc1.s11 == ” “) {

_loc1.s11 = _loc1.s16;

_loc1.box11._alpha = 100;

} // end if

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s16;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s17 == ” “) {

_loc1.s17 = _loc1.s16;

_loc1.box17._alpha = 100;

} // end if

_loc1.s16 = ” “;

this._alpha = 50;

} // end if

break;

case 17 :

if (_loc1.s12 == ” ” || _loc1.s16 == ” ” || _loc1.s18 == ” “) {

if (_loc1.s12 == ” “) {

_loc1.s12 = _loc1.s17;

_loc1.box12._alpha = 100;

} // end if

if (_loc1.s16 == ” “) {

_loc1.s16 = _loc1.s17;

_loc1.box16._alpha = 100;

} // end if

if (_loc1.s18 == ” “) {

_loc1.s18 = _loc1.s17;

_loc1.box18._alpha = 100;

} // end if

_loc1.s17 = ” “;

this._alpha = 50;

} // end if

break;

case 18 :

if (_loc1.s13 == ” ” || _loc1.s17 == ” ” || _loc1.s19 == ” “) {

if (_loc1.s13 == ” “) {

_loc1.s13 = _loc1.s18;

_loc1.box13._alpha = 100;

} // end if

if (_loc1.s17 == ” “) {

_loc1.s17 = _loc1.s18;

_loc1.box17._alpha = 100;

} // end if

if (_loc1.s19 == ” “) {

_loc1.s19 = _loc1.s18;

_loc1.box19._alpha = 100;

} // end if

_loc1.s18 = ” “;

this._alpha = 50;

} // end if

break;

case 19:

if (_loc1.s14 == ” ” || _loc1.s18 == ” ” || _loc1.s20 == ” “) {

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s19;

_loc1.box14._alpha = 100;

} // end if

if (_loc1.s18 == ” “) {

_loc1.s18 = _loc1.s19;

_loc1.box18._alpha = 100;

} // end if

if (_loc1.s20 == ” “) {

_loc1.s20 = _loc1.s19;

_loc1.box20._alpha = 100;

} // end if

_loc1.s19 = ” “;

this._alpha = 50;

} // end if

break;

case 20 :

if (_loc1.s15 == ” ” || _loc1.s14 == ” ” || _loc1.s19 == ” “) {

if (_loc1.s15 == ” “) {

_loc1.s15 = _loc1.s20;

_loc1.box15._alpha = 100;

} // end if

if (_loc1.s14 == ” “) {

_loc1.s14 = _loc1.s20;

_loc1.box14._alpha = 100;

} // end if

if (_loc1.s19 == ” “) {

_loc1.s19 = _loc1.s20;

_loc1.box19._alpha = 100;

} // end if

_loc1.s20 = ” “;

this._alpha = 50;

} // end if

break;

}

// End of switch

}

// end of for

};

};

}

Now run the program.

Click to download the source file Number jumbler

Tags: , , ,

Request a Free SEO Quote