XML Image Gallery with Star Style

Category : Flash Views : 23074
Version : 8 Rating
3.7/5 (44 votes)
Type : Text Source File: xml-image-gallery-with-star-style.zip
Result: See the result


Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | Next

Now we need to code the MCs, paste this code:
//Create new MC, its where we create all other MCs this.createEmptyMovieClip("framesMC", 1); //Set the position to the middle of the //stage so all frames come from that point framesMC._x = Stage.width/2; framesMC._y = Stage.height/2; //current x, y and z position that we are looking at. //This on these variables like the coordinates of //a "camera" that is moving towards an MC var curX = 0; var curY = 0; var curZ = 0; //selected x, y and z position that we want to //go to or where we are moving the "camera" to. var selX = 0; var selY = 0; var selZ = 0; //We coded the MC to call this function every time the //user clicks on the MC function selectFrame() { //set these variables to the variable //inside the MC that called this function. _root.selX = this.x _root.selY = this.y _root.selZ = this.z } framesMC.onEnterFrame = function() { //ease the variable of the current position towards //the selected variables, that will brings us closer //to the destination at each frame _root.curX += (_root.selX - _root.curX)/5; _root.curY += (_root.selY - _root.curY)/5; _root.curZ += (_root.selZ - _root.curZ)/5; //Loop through each element of the "frames_array" for (i = 0; i < _root.frames_array.length; i++) { //Call the function "Move()" of every MC _root.frames_array[i].Move(); } } //The function Move() of each MC call this other function function moveFrames() { //Get the distance between the position of the MC //and the position of where we are looking var nX = this.x - _root.curX var nY = this.y - _root.curY var nZ = this.z - _root.curZ //if the difference of the z coordinates is less than 0 //then the MC passed through us and we no longer see it if (nZ < 0) { //Increase z by 10000, the MC will get a new position far away from us this.z += 10000; //Get random x and y values this.x = Math.random() * 2000 - 1000; this.y = Math.random() * 1600 - 800; //Get new differences now that we have new values nX = this.x - _root.curX nY = this.y - _root.curY nZ = this.z - _root.curZ } //Get a ration based on the z coordinate so every //position, scale and alpha will be proportional //with the distance of the MC from the user. var ratio = 400/(400 + nZ); //Get a alpha value proportional with the //distance of the MC this._alpha = ratio * 1000 //Set the position of the MC using the ratio and //the distance of the "camera" this._x = nX * ratio; this._y = nY * ratio; //Scale of the MC depending on its //distance from the "camera" this._xscale = this._yscale = 100 * ration; //swap depths so that MCs with bigger nZ, far from //the user, wont be seen above MCs that are closer this.swapDepths(Math.round(-nZ)); }

That's all, run your code and enjoy the nice effect.


del.icio.us digg it Reddit Stumble Upon Technorati

Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | Next




Supporters

Reseller Web Hosting