View Full Version : Help with Fading Grid Tutorial
poet's tragedy
March 25th, 2005, 08:50 AM
hey everyone, i love this site & have learned alot from it so i decided to join the forums. keep up the good work. now onto my questions...
i've done the fading grid tutorial at: http://www.kirupa.com/developer/mx/fadegrid.htm , but i was wondering if someone knew how to make the grid fade in diagonally from the left or right top corners (or bottom corners too) like this site http://www.astaticlullaby.com (http://www.astaticlullaby.com/)
i also have another question with the fading grid, does anyone know how to make the grid fade in from random spots on the movie clip instead of the left to right, up to down, etc. way?? i'd really like to see that effect happen, if possible.
i'd really appreciate any help that is provided here, i hope someone can get back to me soon because i'd like to start implementing this right away. thanks!!
-Dantai
scotty
March 25th, 2005, 03:16 PM
Check this thread
http://www.kirupa.com/forum/showthread.php?t=87887
scotty(-:
poet's tragedy
March 25th, 2005, 09:19 PM
thanks scotty! the link to the other thread was very useful.
now for the 2nd question i addressed, would you happen to know how to make the mask of the circle/square appear on random points and eventually showing the picture??
-Dantai
scotty
March 26th, 2005, 02:59 AM
In the makeGrid function put all your duplicates in an array, shuffle that array so it's random and then call the activateGrid function:)
scotty(-:
poet's tragedy
March 26th, 2005, 04:32 AM
scotty, i've got a feeling i wont get it to work correctly (or even at all :ponder:) since the idea of shuffling an array isnt something i think i can figure out. if you knew what lines of code i'd need to add/change for that tutorial that would be helpful. thanks in advance.
-Dantai
2nd day
March 26th, 2005, 08:09 AM
i found this code when i was searching the forums for array shuffle:
array = new Array("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten");
//define shuffle function
function shuffle() {
return Math.round(Math.random());
}
//use the shuffle() function to randomise the order of the array
array.sort(shuffle);
//a var to count against
var i = 0;
//define showarray function
function showarray() {
//grab the next value in the array
randompick = array[i];
//incrument the count; this makes the next showarray(); the next value in the array
i++;
trace(randompick);
}
//you have to shuffle before you can execute the showarray();
shuffle();
when you execute showarray(); you get a randompick of array. i think it isn't so hard to implement this into the fading grid...
good luck :cowboy:!
poet's tragedy
March 27th, 2005, 01:17 AM
scotty & 2nd day, sorry to be a pain but i took both of your suggestionsand still couldnt get it to work using that array. would either of you know exactly how the code should look like, or have an .fla for this??
-Dantai
scotty
March 27th, 2005, 05:26 AM
Normally I would have used the shuffle function 2nd day gave you but that one gave (for some reason I can't find out a bug, one duplicate gets missing...)
So this will work
//Array prototypes from http://proto.layer51.com/
Array.prototype.shuffle = function() {
var i = this.length-1;
if (i) {
do {
this.exchange(i, Math.floor(Math.random()*(i+1)));
} while (--i);
}
};
Array.prototype.exchange = function(i, j) {
if (i != j) {
with (this[i]) {
this[i] = this[j];
this[j] = valueOf();
}
}
};
MovieClip.prototype.scale = function(sc) {
this._xscale = sc-(sc-this._xscale)/1.2;
this._yscale = this._xscale;
if (Math.abs(this._xscale-sc)<1) {
this._xscale = this._yscale=sc;
delete this.onEnterFrame;
}
};
var nr = 0, d = 0;
six._visible = 0;
itemArray = new Array();
function makeGrid() {
for (var i = 0; i<8; i++) {
for (var j = 0; j<8; j++) {
var item = six.duplicateMovieClip("six"+nr, 999+nr);
item._xscale = item._yscale=0;
item._x = i*52;
item._y = j*52;
itemArray.push(item);
nr++;
}
}
itemArray.shuffle();
activateGrid(d, 100);
}
function activateGrid(d, sc) {
clearInterval(delay);
var item = itemArray[d];
item.onEnterFrame = function() {
this.scale(sc);
};
nextGrid();
}
function nextGrid() {
d<itemArray.length-1 ? (d++, delay=setInterval(this, "activateGrid", 100, d, 100)) : clearInterval(delay);
}
makeGrid();
scotty(-:
poet's tragedy
March 27th, 2005, 03:41 PM
thanks so much scotty, it worked perfectly. i see in your code what i was doing wrong, i wasnt correctly putting the elements into the array (i didnt use .push() so perhaps i couldve had it working, if i did that when i tried). i appreciate the help :D
scotty
March 28th, 2005, 04:13 AM
you're welcome:thumb:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.