# Mx Api Stuff

**URL:** <https://forum.kirupa.com/t/mx-api-stuff/5232>\
**Category:** flash\
**Created:** [September 5, 2002, 6:13am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232 "2002-09-05T06:13:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bezzer](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bezzer](https://forum.kirupa.com/u/Bezzer)\
**Post date:** [September 5, 2002, 6:13am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/1 "2002-09-05T06:13:46Z")

</div>

I was playing around with api and I came up with this, kinda looks like the pictures where they leave the camera shutter open 🙂

```php

_root.createEmptyMovieClip("bob",0);
while(i<40){
	bob.duplicateMovieClip("bob"+i,i)
	eval("bob"+i).moveTo(Math.random()*550,Math.random()*400);
	eval("bob"+i).lineStyle(Math.random()*3,Math.random() * 255 << 16 | Math.random() * 255 << 8 | Math.random() * 255,Math.random()*50+50);
	++i;
}
onEnterFrame = function(){
	for(x=0;x<40;++x){
		eval("bob"+x).clear()
		eval("bob"+x).moveTo(Math.random()*550,Math.random()*400);
		eval("bob"+x).lineStyle(Math.random()*3,Math.random() * 225 << 16 | Math.random() * 255 << 8 | Math.random() * 255,Math.random()*100);	
		//eval("bob"+x).lineTo(_xmouse,_ymouse);
		eval("bob"+x).curveTo(_xmouse,_ymouse,(550/2),50);
	}
}

```

Yeah just think it looks cool…hehe 🙂

---

<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:32am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/2 "2002-09-05T06:32:03Z")

</div>

Very neato. Although you should add

\_root.createEmptyMovieClip(“bob”, 1);

to the beginning of that code. That is…if you are posting that for copy and paste.

---

<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:33am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/3 "2002-09-05T06:33:59Z")

</div>

hehe ooops i forgot to paste that part…oh well hehe 🙂

---

<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 11, 2002, 7:40am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/4 "2002-09-11T07:40:13Z")

</div>

Hey Bezzer, you could propose this for the [25-line Actionscript contest](http://www.bit-101.com/contest)!

pom :asian:

---

<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 11, 2002, 7:41am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/5 "2002-09-11T07:41:58Z")

</div>

Hmm, that is a good idea!

---

<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 12, 2002, 11:18am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/6 "2002-09-12T11:18:38Z")

</div>

By the way, it didn’t work until I put createEmptyMovieClip(“bob”,-1). Which is logical because you duplicate your first clip at depth 0.

pom :asian:

---

<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 12, 2002, 11:23am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/7 "2002-09-12T11:23:38Z")

</div>

yeah that was what i was trying to make it for hehe…but i dun think i’ll enter…i’ve seen the other peoples stuff…To good for me 🙂

hrmmm i’ll look into the thing u had to change…i think i should start off at 1 🙂

---

<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 12, 2002, 11:51am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/8 "2002-09-12T11:51:42Z")

</div>

Don’t be shy, man! But it’s true that this Russian guy just made a 3D dog in 21 lines, and I don’t how anyone can beat that…

pom :asian:

---

<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 12, 2002, 11:55am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/9 "2002-09-12T11:55:56Z")

</div>

wow which entry is that? hehe i wanna see the 3d dog…

---

<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 12, 2002, 12:11pm UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/10 "2002-09-12T12:11:00Z")

</div>

One of the last ones, check it on the forums. From deliMIter. That guy is totally amazing, absolutely brilliant. But don’t look at the source, it’s worse than Chinese 😛

pom :asian:

---

<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 12, 2002, 3:57pm UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/11 "2002-09-12T15:57:30Z")

</div>

WOW, that delimeter guy is amazing as well. Although I think his code was too long to be in the contest…not sure how you count the lines though.

Anyways, I love how he uses the “?:” if/else statement. It is so much more efficient. I use it in Javascript all the time.

I pretty much understood his code up to here…

function fromAtoB(A, B) {  
// the next block is one line //  
if (typeof (A) == “movieclip”) {  
for (var i = 1; i\<(iLimit=Math.round(Math.sqrt((A.X-B.X)_(A.X-B.X)+(A.Y-B.Y)_(A.Y-B.Y)+(A.Z-B.Z)_(A.Z-B.Z))/((A.\_radius+B.radius)/4))); i++) {  
createClip(A.name+""+i+""+B.\_name, ++\_depth, Math.round((A.\_color & 0xFF)_(iLimit-i)/iLimit) | Math.round(((A.\_color \>\> 8) & 0xFF)_(iLimit-i)/iLimit) \<\< 8 | Math.round(((A.\_color \>\> 16) & 0xFF)_(iLimit-i)/iLimit) \<\< 16 | Math.round((B.\_color & 0xFF)_i/iLimit) | Math.round(((B.\_color \>\> 8) & 0xFF)i/iLimit) \<\< 8 | Math.round(((B.\_color \>\> 16) & 0xFF)i/iLimit) \<\< 16, (A.\_radius(iLimit-i)/iLimit+B.\_radiusi/iLimit)2Math.pow(Math.abs(i-iLimit/2), 1/3)/iLimit+10, {X:\_zx=A.X+i_(B.X-A.X)/iLimit, Y:\_zy=A.Y+i\*(B.Y-A.Y)/iLimit, Z:\_zz=A.Z+i\*(B.Z-A.Z)/iLimit, R:Math.sqrt(\_zx\*\_zx+\_zy\*\_zy+\_zz\*\_zz)}, true);  
}  
}  
// end of block //  
}

Then it all went downhill from there…haha.

---

<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 13, 2002, 3:27am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/12 "2002-09-13T03:27:33Z")

</div>

hrmm i can only see the lightnening one and the mouse fire thing from him…can u post a link to his dog please? 🙂

---

<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 13, 2002, 3:35am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/13 "2002-09-13T03:35:37Z")

</div>

I had a look at some of urs pom…or at least i think there urs…hehe

There really good 🙂

---

<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 13, 2002, 4:06am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/14 "2002-09-13T04:06:51Z")

</div>

He called it a molecular alcoholic pet…haha. It is incredible though. To think that nothing was drawin the making of this. His code is astounding too.

[http://www.station4net.com/flashfx/057-25-lines.html](http://www.station4net.com/flashfx/057-25-lines.html)

There is a link to 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 13, 2002, 10:16am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/15 "2002-09-13T10:16:36Z")

</div>

Thanks Bezzer 🙂

And about the line count, the worse thing is that his code is perfectly valid. You see, with MX, lots of functions create, attach or dulpicate an object, and they also return a reference to that object. So for instance, you could write:

```auto
_root.createEmptyMovieClip("holder",-1);
_root.holder.createTextField("myText",0,0,0,20,10).
_root.holder.myText.text="Flash rocks";

```

But you could also do it like:

```auto
_root.createEmptyMovieClip("holder",-1).createTextField("myText",0,0,0,20,10).text="Flash rocks";

```

You see how it works?

pom 🙂

---

<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 13, 2002, 11:04am UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/16 "2002-09-13T11:04:15Z")

</div>

didn’t know you could do that…thats a pretty nice trick…gotta love dot syntax 🙂

---

<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 13, 2002, 1:59pm UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/17 "2002-09-13T13:59:35Z")

</div>

i’ve been trying to make my code like that… i want to make these lines

```php

eval("bob"+x).clear()
		eval("bob"+x).moveTo(Math.random()*550,Math.random()*400);
		eval("bob"+x).lineStyle(Math.random()*50,Math.random() * 225 << 16 | Math.random() * 255 << 8 | Math.random() * 255,Math.random()*100);	
		eval("bob"+x).curveTo(_xmouse,_ymouse,(419.6/2),50);

```

into this…

```php

eval("bob"+x).clear().moveTo(Math.random()*550,Math.random()*400).lineStyle(Math.random()*50,Math.random() * 225 << 16 | Math.random() * 255 << 8 | Math.random() * 255,Math.random()*100).curveTo(_xmouse,_ymouse,(419.6/2),50);

```

but it doesn’t seem to work…i think im not understanding things right…

---

<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 13, 2002, 3:33pm UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/18 "2002-09-13T15:33:30Z")

</div>

Wow, gotta love that confuscated (? I think this is the word) code.

Hey Bezzer:

\_root.createEmptyMovieClip("\<B\>holder\</B\>",-1);  
\_root.\<B\>holder\</B\>.createTextField(“myText”,0,0,0,20,10).  
\_root.\<B\>holder\</B\>.myText.text=“Flash rocks”;

See how the name of the created movie clip is used it all of the other statements. It is written with a locator (aka \_root). Now if I understand Ilyas correctly, instead of typing \_root.holder all the time you can just attach it to the end of the createEmptyMovieClip command.

I noticed the code you have doesn’t contain the locator, possibly that is why it is not working.

---

<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 13, 2002, 3:36pm UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/19 "2002-09-13T15:36:43Z")

</div>

well eval(“bob”+x) is th locator…it gives it the name of a duplicated movie… so yeah i dont know why it doesn’t work… ☹

---

<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 13, 2002, 3:38pm UTC](https://forum.kirupa.com/t/mx-api-stuff/5232/20 "2002-09-13T15:38:56Z")

</div>

Maybe I should have specified, oops:) I meant the locator as in \_root or \_parent. I think that might be when it works.
