# Code

**URL:** <https://forum.kirupa.com/t/code/5040>\
**Category:** meta\
**Created:** [August 29, 2002, 5:38pm UTC](https://forum.kirupa.com/t/code/5040 "2002-08-29T17:38:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![DMX](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DMX](https://forum.kirupa.com/u/DMX)\
**Post date:** [August 29, 2002, 5:38pm UTC](https://forum.kirupa.com/t/code/5040/1 "2002-08-29T17:38:50Z")

</div>

Hi,I dont need help but can anyone who has any actions for mc’s to make them do an effect post them here plz.🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 4:26am UTC](https://forum.kirupa.com/t/code/5040/2 "2002-08-30T04:26:42Z")

</div>

onClipEvent(enterFrame){  
\_x++;  
}

😛

ok… I’m a smartass

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 4:40am UTC](https://forum.kirupa.com/t/code/5040/3 "2002-08-30T04:40:34Z")

</div>

onClipEvent (enterFrame) {  
\_rotation += 10;  
}

😛 Hey david, your a smartass, I am a smartass, we are all smartasses:P

Seriously though, all the really great effects require more than just simple code on an mC.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 4:54am UTC](https://forum.kirupa.com/t/code/5040/4 "2002-08-30T04:54:38Z")

</div>

ok… trying to be serious now. 🙂

```php

onClipEvent(load){
    yVelocity=5;
    xVelocity=-20;
    lossOfEnergy=.94;
    gravity=4;
}
onClipEvent(enterFrame){
    yVelocity+=gravity;
    yVleocity*=lossOfEnergy;
    xVelocity*=lossOfEnergy;
    _x+=xVelocity;
    _y+=yVelocity;
    if(_x<=0){
         _x=1;
         xVelocity=-xVelocity;
    }else if(_y<=0){
         _y=1;
         yVelocity=-yVelocity;
    }else if(_x+_width>=300){
         _x=299-_width;
         xVelocity=-xVelocity;
    }else if(_y+_height>=300){
         _y=299-_height;
         yVelocity=-yVelocity;
    }
}
onClipEvent(mouseDown){
    yVelocity-=Math.random()*100+1;
    xVelocity-=Math.random()*100-50;
}

```

I think that will work. 🙂 that’s second year stuff… haven’t worked with these in a while. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 4:59am UTC](https://forum.kirupa.com/t/code/5040/5 "2002-08-30T04:59:05Z")

</div>

That is pretty cool. I did something like that when I was learning elasticity:)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 5:05am UTC](https://forum.kirupa.com/t/code/5040/6 "2002-08-30T05:05:45Z")

</div>

that mixed with some scaling effects is the basis for most of my limited physics knowledge so far. I just worked off of that example.

If you add scaling you can create z movement… which is pretty cool too.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 10:39am UTC](https://forum.kirupa.com/t/code/5040/7 "2002-08-30T10:39:33Z")

</div>

Hi,

yourMc is an instance of a movie clip that will be multiplicated as many times as the value of ‘num’

f = 0.8;  
r = 0.1;  
f2 = 0.5;  
r2 = 0.1;  
num = 5;  
elasticMenuEnabled = true;  
function elasticMenu() {  
for (i=1; i\<=num; i++) {  
a = yourMc[“a”+i];  
a.xscale = a.xscale\*f+(a.s-a.\_xscale)_r;  
a.yscale = a.yscale_f+(a.s-a.\_yscale)_r;  
//a.\_y = a1.\_y+(a1.\_height_(i-1));  
a.\_xscale += a.xscale;  
a.\_yscale += a.yscale;  
}

```
tu = Number(yo)+1;
for (i=(tu); i&lt;=num; i++) {
	a = este["a"+i];
	b = este["a"+(i-1)];
	a.y = (b._y+(b._height));
	a.yvel = a.yvel*f2+(a.y-a._y)*r2;
	a._y += a.yvel;
}

el = Number(yo)-1;
for (i=(el); i&gt;=1; i--) {
	a = este["a"+i];
	b = este["a"+(i+1)];
	a.y = (b._y-(b._width/2)-(a._width/2));
	a.yvel = a.yvel*f2+(a.y-a._y)*r2;
	//if (a._y&gt;=minY*2) {
	a._y += a.yvel;
	//}
}

```

}

yourMc.onEnterFrame = function() {  
if (elasticMenuEnabled) {  
elasticMenu();  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 10:54am UTC](https://forum.kirupa.com/t/code/5040/8 "2002-08-30T10:54:40Z")

</div>

SWEEET!

very nice coding there.

is that your code or is it someone elses and you just copied it. The only reason I want to know is that if I use it, I’d put in comment tags giving credit to the creator. I think I’ll be playing around with that one a bit.

btw… the code I pasted above with velocity was taken from “Flash Game design” by friends of Ed books. If anyone is interested. I didn’t put in the comment tags but they really should be there.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 11:07am UTC](https://forum.kirupa.com/t/code/5040/9 "2002-08-30T11:07:49Z")

</div>

Hi,

Yes, I wrote this code long ago and am using it again in project I’m working on at the moment.

bye

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 12:29pm UTC](https://forum.kirupa.com/t/code/5040/10 "2002-08-30T12:29:58Z")

</div>

hmm… it doesnt’ do anything for me. Guess I’m not getting something…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2002, 1:48pm UTC](https://forum.kirupa.com/t/code/5040/11 "2002-08-30T13:48:14Z")

</div>

Hi,

Sorry David, there was something missing.

I’m posting a fla with everything on it

Thankx

SHO

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 31, 2002, 5:09pm UTC](https://forum.kirupa.com/t/code/5040/12 "2002-08-31T17:09:48Z")

</div>

thanks sir. I’ll open it up when I get a chance.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 1, 2002, 8:52am UTC](https://forum.kirupa.com/t/code/5040/13 "2002-09-01T08:52:53Z")

</div>

THANKS!  
THIS REALLY HELPS, HERES A COOL FLASH MOVIE. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2002, 4:54am UTC](https://forum.kirupa.com/t/code/5040/14 "2002-09-03T04:54:53Z")

</div>

\*\*\*\* it. I accidentaly stickied this thread and now I can’t unsticky it. Teach me to play around with the moderator options.

Well… I’ll talk to k and see what he knows about unsticking things.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2002, 5:02am UTC](https://forum.kirupa.com/t/code/5040/15 "2002-09-03T05:02:46Z")

</div>

Hey david, I unstuck it.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2002, 5:36am UTC](https://forum.kirupa.com/t/code/5040/16 "2002-09-03T05:36:38Z")

</div>

Thanks… that option didn’t seem to be doing it for me.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2002, 5:43am UTC](https://forum.kirupa.com/t/code/5040/17 "2002-09-03T05:43:08Z")

</div>

Odd, I had no problem. It is actually the first time I have ever used my mod capabilities. WOO HOO!🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2002, 6:04am UTC](https://forum.kirupa.com/t/code/5040/18 "2002-09-04T06:04:08Z")

</div>

🙂  
Create 2 circles,1 small and 1 big make them mc’s,give the big one an instance name of parent.Give the smaller one the instance name child1.Now Create a line from one mc to another and give it aninstance name:line.now right click on child1 actions and put in this code,

onClipEvent (load)

{

spring = false;

startX = \_x;

startY = \_y;

spX = 0;

spY = 0;

\_root.line.\_visible = 1;

parentx = \_root.parent.\_x;

parenty = \_root.parent.\_y;

\_root.line.\_x = parentx;

\_root.line.\_y = parenty;

\_root.line.\_xscale = \_root.child1.\_x-parentx;

\_root.line.\_yscale = \_root.child1.\_y-parenty;

}

onClipEvent (mouseDown)

{

startDrag ("", true);

spring = true;

}

onClipEvent (mouseUp)

{

stopDrag ();

spring = false;

}

onClipEvent (enterFrame)

{

parentx = \_root.parent.\_x;

parenty = \_root.parent.\_y;

\_root.line.\_x = parentx;

\_root.line.\_y = parenty;

//////

\_root.line.\_xscale = \_root.child1.\_x-parentx;

\_root.line.\_yscale = \_root.child1.\_y-parenty;

//!spring = if false

if (!spring)

{

//code to create the movements

spX += (startX-\_x);

spY += (startY-\_y);

spX \*= .09;

spY \*= .09;

\_x += spX;

\_y += spY;

}

}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 6:10am UTC](https://forum.kirupa.com/t/code/5040/19 "2002-09-05T06:10:55Z")

</div>

you don’t need to create the line 100/100 with a 135 degree slant?

I thought that was riquired for a line follow.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2002, 6:25am UTC](https://forum.kirupa.com/t/code/5040/20 "2002-09-05T06:25:08Z")

</div>

i have no idea,but i got it off [here](http://www.flashcircle.com)

[Next page](https://forum.kirupa.com/t/code/5040.md?page=2)
