Hey all, its been a while since I actually have written a tutorial, and I just figured out how to do an effect, its very basic, but if anyone would be interested in a tutorial, then I might as well write one up for it. Only takes about 10 minutes to actually achieve the effect…
Hey, do you know I’ve never done that? Duplicate trailers I did, no prob, but I’ve never done this one… It’s the one where the elements position depending on the previous element, right?. And, hue… can I have a sneak preview at the code you’re using?
The code uses MX elements, but it wouldn’t be that difficult to reproduce in Flash 5. My code is also pretty ghetto, i was wondering if anyone had a way of cleaning it up a bit…
_root.onLoad = function () {
//variables
nSpace = 10;
xStart = _root._xmouse;
yStart = _root._ymouse;
text = "Kirupa.com";
nFriction = 3;
//creates the balls
for (ii = 0; ii < length (text); ii++) {
//attach Movies from Library
attachMovie ('ball', 'copy' + ii, 1 - ii);
ext = _root['copy' + ii];
prt = _root['copy' + (ii - 1)];
//Use substr to call the text from the string
ext.text = text.substr (ii, 1);
if (ii == 0) {
ext._x = xStart;
ext._y = yStart;
} else {
ext._x = xStart + (30 * ii);
ext._y = _root['copy' + (ii - 1)]._y;
}
}
};
_root.onEnterFrame = function () {
//For Loop to move the balls
for (ii = 0; ii < length (text); ii++) {
//Defines ext and prt. Makes Code easier to write.
ext = _root['copy' + ii];
prt = _root['copy' + (ii - 1)];
//checks the extetion _root.copy(ii) then tells them what to do.
if (ii == 0) {
ext._x += (_root._xmouse - ext._x) / nFriction + nSpace;
ext._y += (_root._ymouse - ext._y) / nFriction;
} else {
ext._x += (prt._x - ext._x) / nFriction + nSpace;
ext._y += (prt._y - ext._y) / nFriction;
}
}
};
I don’t have much time to spend with my computer so I won’t be able to write the tutorial up until maybe next week sometime, but I’ll let you all know when its finished.
Yep, nice code. Actually, I came up with something quite different. I’ll post the code when I can access this site from my computer, it can be interesting.
A few remarks about your code though:
// No need to define _root.onLoad
//variables
nSpace = 10;
xStart = _root._xmouse;
yStart = _root._ymouse;
// text is a keyword. There won't be an error, but
// it's better to avoid that
sText = "Kirupa.com";
nFriction = 3;
//creates the balls
for (ii = 0; ii < sText.length; ii++) {
//attach Movies from Library
ext=attachMovie ('ball', 'copy' + ii, 1 - ii);
// Any reason why you attach at depth 1-ii?
prt = _root['copy' + (ii - 1)];
//Use substr to call the text from the string
ext.text = sText.substr (ii, 1);
if (!ii) {
ext._x = xStart;
ext._y = yStart;
} else {
ext._x = xStart + (30 * ii);
ext._y = prt._y;
}
}
_root.onEnterFrame = function () {
//For Loop to move the balls
for (ii = 0; ii < sText.length; ii++) {
//Defines ext and prt. Makes Code easier to write.
ext = _root['copy' + ii];
prt = _root['copy' + (ii - 1)];
//checks the extetion _root.copy(ii) then tells them what to do.
if (!ii) {
ext._x += (_root._xmouse - ext._x) / nFriction + nSpace;
ext._y += (_root._ymouse - ext._y) / nFriction;
} else {
ext._x += (prt._x - ext._x) / nFriction + nSpace;
ext._y += (prt._y - ext._y) / nFriction;
}
}
};
Yeah i knew there was no reason to use ‘_root.onLoad’ I just felt like throwing it in…
I meant to use (10-ii) because that way the first letter is always on top when you drag, because sometimes they overlap and the K would get sent to the bottom…if you use 10-ii then the K has the highest depth and it will stay on top.
where is exactly the tutorial for this one i need to learn how the codes work can someone explain me by detail please
// No need to define _root.onLoad
//variables
nSpace = 10;
xStart = _root._xmouse;
yStart = _root._ymouse;
// text is a keyword. There won’t be an error, but
// it’s better to avoid that
sText = “Kirupa.com”;
nFriction = 3;
//creates the balls
for (ii = 0; ii < sText.length; ii++) {
//attach Movies from Library
ext=attachMovie (‘ball’, ‘copy’ + ii, 1 - ii);
// Any reason why you attach at depth 1-ii?
prt = _root[‘copy’ + (ii - 1)];
//Use substr to call the text from the string
ext.text = sText.substr (ii, 1);
if (!ii) {
ext._x = xStart;
ext._y = yStart;
} else {
ext._x = xStart + (30 * ii);
ext._y = prt._y;
}
}
_root.onEnterFrame = function () {
//For Loop to move the balls
for (ii = 0; ii < sText.length; ii++) {
//Defines ext and prt. Makes Code easier to write.
ext = _root[‘copy’ + ii];
prt = _root[‘copy’ + (ii - 1)];
//checks the extetion _root.copy(ii) then tells them what to do.
if (!ii) {
ext._x += (_root._xmouse - ext._x) / nFriction + nSpace;
ext._y += (_root._ymouse - ext._y) / nFriction;
} else {
ext._x += (prt._x - ext._x) / nFriction + nSpace;
ext._y += (prt._y - ext._y) / nFriction;
}
}
};