Tutorial maybe?

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…

<embed src=“http://www.livetoskateboard.com/flash/PomMoving.swf” height=200 width=400></embed>

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?

pom :asian:

yeah… pretty cool. I’ve seen it done in javascript… but I haven’t seen anyone do it in Flash. I’m sure someone has, but I haven’t seen it.

Post the code… post the code. :slight_smile:

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;
		}
	}
};

definitly I would love to see a tutorial for that…

cool!!!

Nice coding there sir.

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;
		}
	}
};

pom :asian:

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.

meant to put nText…I was in a rush :slight_smile:

Arghh!! I can’t access this board from my computer. Can you send me a mail at [email protected] and I’ll send you my file so that you can compare.

pom :asian:

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;
}
}
};

I never made the tutorial. I haven’t had time. The code is commented and its pretty self-explanitory…

http://www.flashkit.com/movies/Scripting/Physics/Artifici-Luis_Pab-5091/index.php

Fantastic example of this…

First: OLD THREAD OLD THREAD OLD THREAD!!! (just for those people that didn’t know that)

Second: Wow that example is awesome. Thanks for posting that Llyd. It is a bit different, but still cool.

I did a rendition of this from Jubbas code a while back, here was my version:

http://8ballcreations.com/lostinbeta/experimental/duptrailer.html