# Attaching a mc u created in as?

**URL:** <https://forum.kirupa.com/t/attaching-a-mc-u-created-in-as/186211>\
**Category:** Uncategorized\
**Created:** [April 19, 2006, 7:08pm UTC](https://forum.kirupa.com/t/attaching-a-mc-u-created-in-as/186211 "2006-04-19T19:08:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exos\_Sho](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@Exos\_Sho](https://forum.kirupa.com/u/Exos_Sho)\
**Post date:** [April 19, 2006, 7:08pm UTC](https://forum.kirupa.com/t/attaching-a-mc-u-created-in-as/186211/1 "2006-04-19T19:08:29Z")

</div>

so i’ve done 2 little versions of a simple program,  
4 little rectangle are the corners of a bigger rectangle, which is been drawn per as.  
so the first version is most simple:  
the 4 little rectangles are on stage, every one is an own mc.  
the second one :  
one little rectangle is in the library and gets attached 4 times  
the third one(my problem):  
i want to create an rectangle via line.To etc. in an “this.createEmptyMovieClip” and then attach this one, but i can’t

here is how far i got

> this.createEmptyMovieClip(“square”);  
> this.square.beginFill(0xffaa00, 30);  
> this.square.lineStyle(1,0x00ff00,100);  
> this.square.lineTo(10,0);  
> this.square.lineTo(10,10);  
> this.square.lineTo(0,10);  
> this.square.lineTo(0,0);  
> this.square.endFill();

this.attachMovie(this.square, “s\_1”, 200);  
this.attachMovie(this.square, “s\_2”, 201);  
this.attachMovie(this.square, “s\_3”, 202);  
this.attachMovie(this.square, “s\_4”, 203);  
this.onLoad = function() {  
this.s\_1.\_x = 50;  
this.s\_1.\_y = 50;  
this.s\_2.\_x = 100;  
this.s\_2.\_y = 50;  
this.s\_3.\_x = 100;  
this.s\_3.\_y = 100;  
this.s\_4.\_x = 50;  
this.s\_4.\_y = 100;  
};  
this.onEnterFrame = function() {  
\_root.s\_1.onPress = function() {  
this.startDrag();  
};  
\_root.s\_1.onRelease = function() {  
this.stopDrag();  
};  
\_root.s\_2.onPress = function() {  
this.startDrag();  
};  
\_root.s\_2.onRelease = function() {  
this.stopDrag();  
};  
\_root.s\_3.onPress = function() {  
this.startDrag();  
};  
\_root.s\_3.onRelease = function() {  
this.stopDrag();  
};  
\_root.s\_4.onPress = function() {  
this.startDrag();  
};  
\_root.s\_4.onRelease = function() {  
this.stopDrag();  
};  
var x1:Number = \_root.s\_1.\_x;  
var x2:Number = \_root.s\_2.\_x;  
var x3:Number = \_root.s\_3.\_x;  
var x4:Number = \_root.s\_4.\_x;  
var y1:Number = \_root.s\_1.\_y;  
var y2:Number = \_root.s\_2.\_y;  
var y3:Number = \_root.s\_3.\_y;  
var y4:Number = \_root.s\_4.\_y;  
this.createEmptyMovieClip(“triangle\_mc”, -1000);  
triangle\_mc.beginFill(0xff0000, 30);  
triangle\_mc.lineStyle(0.25, 0xff0000, 100);  
triangle\_mc.moveTo(x4, y4);  
triangle\_mc.lineTo(x1, y4);  
triangle\_mc.lineTo(x1, y1);  
triangle\_mc.lineStyle(1, 0x000000, 100);  
triangle\_mc.moveTo(x1, y1);  
triangle\_mc.lineTo(x4, y4);  
triangle\_mc.endFill();  
triangle\_mc.beginFill(0xff0000, 30);  
triangle\_mc.lineStyle(0.25, 0xff0000, 100);  
triangle\_mc.moveTo(x4, y4);  
triangle\_mc.lineTo(x4, y3);  
triangle\_mc.lineTo(x3, y3);  
triangle\_mc.lineStyle(1, 0x000000, 100);  
triangle\_mc.moveTo(x4, y4);  
triangle\_mc.lineTo(x3, y3);  
triangle\_mc.endFill();  
triangle\_mc.beginFill(0xff0000, 30);  
triangle\_mc.lineStyle(0.25, 0xff0000, 100);  
triangle\_mc.moveTo(x2, y2);  
triangle\_mc.lineTo(x3, y2);  
triangle\_mc.lineTo(x3, y3);  
triangle\_mc.lineStyle(1, 0x000000, 100);  
triangle\_mc.moveTo(x2, y2);  
triangle\_mc.lineTo(x3, y3);  
triangle\_mc.endFill();  
triangle\_mc.beginFill(0xff0000, 30);  
triangle\_mc.lineStyle(0.25, 0xff0000, 100);  
triangle\_mc.moveTo(x2, y2);  
triangle\_mc.lineTo(x1, y2);  
triangle\_mc.lineTo(x1, y1);  
triangle\_mc.lineStyle(1, 0x000000, 100);  
triangle\_mc.moveTo(x1, y1);  
triangle\_mc.lineTo(x2, y2);  
triangle\_mc.endFill();  
var a4:Number = (x1-x4);  
trace(“a4=”);  
trace(a4);  
var b4:Number = (y1-y4);  
trace(“b4=”);  
trace(b4);  
var c4:Number = Math.sqrt(((a4)_(a4)+(b4)_(b4)));  
trace(“c4=”);  
trace(c4);  
trace(“-------------------------------------------”);  
var a1:Number = (x2-x1);  
trace(“a1=”);  
trace(a1);  
var b1:Number = (y2-y1);  
trace(“b1=”);  
trace(b1);  
var c1:Number = Math.round(Math.sqrt(((a1)_(a1)+(b1)_(b1))));  
trace(“c1=”);  
trace(c1);  
trace(“-------------------------------------------”);  
};
