Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Helics 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
We are trying to creat a helics that continually runs...any suggestions would be fantastic!!

Thanks
 
Is this the kind of thing you mean?

http:
Here's the code that does it...

onClipEvent (load) {
// set up values for path of clips
yPos = new Array();
zPos = new Array();
// fill arrays with values
for (j=0; j<720; j++) {
yPos[j] = (Math.sin(j*Math.PI/180)*50)+180;
zPos[j] = (Math.cos(j*Math.PI/180)*50)+180;
}
// duplicate clips for the path
for (i=1; i<=72; i++) {
duplicateMovieClip (_root.target1, &quot;trail1&quot;+i, i+72);
duplicateMovieClip (_root.target1, &quot;trail2&quot;+i, i);
}
// initialise counter
count = 0;
}
onClipEvent (enterFrame) {
// place clips on helix path
for (i=1; i<=72; i++) {
_root[&quot;trail1&quot;+i]._x = (i*10)-count;
_root[&quot;trail1&quot;+i]._y = yPos[(i*10)];
_root[&quot;trail2&quot;+i]._x = (i*10)-count;
_root[&quot;trail2&quot;+i]._y = zPos[(i*10)];
}
// go to the next step on the path, loop if finished
count += 10;
if (count>=360) {
count = 0;
}
}


The code goes in a control clip and the &quot;target1&quot; clip is just a filled sphere.
 
wangbar,

Your above sample is pretty kool. I was trying to dicept your code, can you please help me out?

onClipEvent (load) {
// set up values for path of clips
yPos = new Array();
zPos = new Array();

OK, yPos and zPos are arrays (one dimensional) with 720 elements (depth)


// fill arrays with values
for (j=0; j<720; j++) {
yPos[j] = (Math.sin(j*Math.PI/180)*50)+180;
zPos[j] = (Math.cos(j*Math.PI/180)*50)+180;
}

Neat for/next loop! Math.sin, Math.PI and Math.cos gives the target away as a circle ... we are dealing we radius, area of a circle ???

Can you explain the fixed numbers (/180, *50 and +180)?


// duplicate clips for the path
for (i=1; i<=72; i++) {
duplicateMovieClip (_root.target1, &quot;trail1&quot;+i, i+72);
duplicateMovieClip (_root.target1, &quot;trail2&quot;+i, i);
}

Here is where the sphere chain is created, but what's &quot;trail1&quot; and &quot;trail2&quot;? I guess these are upper and lower paths ... where are they and how are they defined or declared?


// initialise counter
count = 0;
}
onClipEvent (enterFrame) {
// place clips on helix path
for (i=1; i<=72; i++) {
_root[&quot;trail1&quot;+i]._x = (i*10)-count;
_root[&quot;trail1&quot;+i]._y = yPos[(i*10)];
_root[&quot;trail2&quot;+i]._x = (i*10)-count;
_root[&quot;trail2&quot;+i]._y = zPos[(i*10)];
}

What's going on here? What is the result of concatenating _root[&quot;trailX&quot;+i]? Is trailX a litteral or number?


// go to the next step on the path, loop if finished
count += 10;

I don't think I've seen this in quite some time but I am guessing &quot;add 10 to count&quot; ... ? If incrementing count by 10, is that the size of the sphere in pixel? If not, why 10?

if (count>=360) {
count = 0;
}
}

What is a &quot;control clip&quot;? Are these blank MCs (nothing on their timeline)?

Are control clips the norm when altering or programming to monitor _x _y and/or properties?

Sorry to trouble you with this, hope you do not mind. One could always cut and paste code, but I rather write the code understanding what it does and why? :cool:

Thank you in advance for your time and assistand!


Regards;


josel

If you have the knowledge, consult and educate those who need it! - Jose Lerebours
 
Can you explain the fixed numbers (/180, *50 and +180)?

This code is plotting sin and cosine values for 720 degrees of rotation. Since Flash doesn't work in degrees you have to convert to radians which means multiplying by PI/180. The 50 is the radius of the wave and the second 180 is the vertical offset on the stage (halfway down the screen in this case so that the wave stays centred).

what's &quot;trail1&quot; and &quot;trail2&quot;?

They are the two chains of the helix - gotta call them something ;-). They're both just duplicates of a sphere graphic which is hidden offstage.

I am guessing &quot;add 10 to count&quot; ... ?

Yep - count is controlling the start position of the wave as it is drawn frame by frame creating the scrolling effect.

What's going on here? What is the result of concatenating _root[&quot;trailX&quot;+i]? Is trailX a litteral or number?

This is a quick way of referencing many clips. The part inside the brackets is concatenated to provide a reference to an individual clip, so you can run through several clips inside a loop by using the loop index to create new clip instance names. It's not a number, it's a dynamically generated instance name - very useful.

What is a &quot;control clip&quot;? Are these blank MCs (nothing on their timeline)?

That's exactly what it is - it's just a place to put code. I tend to fill them with a graphic so I can find them easily rather than leave them totally empty, I just position them offstage so that they don't show up in the movie. Most of my movies are one frame long with a central code holder which runs everything, it makes debugging much easier.
Slainte

 
wangbar,

Thank you very much for taking the time.

I was, this time around, able to make the relation between the for/next loops and the concatenating technique to reference intances dynamically.

While programming is not rocket science, it sure is beautiful when you know what you are doing!

Would it be too much to ask for a copy of the above posted FLA? I guess I want to feel seek once I find how simple it is ... or be troubled by its complex simplicity!

Thanks once again, I truly appreciate your efforts.


Regards;


Jose Lerebours If you have the knowledge, consult and educate those who need it! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top