# \[FMX\] Split Movieclip

**URL:** <https://forum.kirupa.com/t/fmx-split-movieclip/29188>\
**Category:** flash\
**Created:** [August 23, 2003, 6:33pm UTC](https://forum.kirupa.com/t/fmx-split-movieclip/29188 "2003-08-23T18:33:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Voetsjoeba](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@Voetsjoeba](https://forum.kirupa.com/u/Voetsjoeba)\
**Post date:** [August 23, 2003, 6:33pm UTC](https://forum.kirupa.com/t/fmx-split-movieclip/29188/1 "2003-08-23T18:33:02Z")

</div>

Hi,

Is it possible to split a movieclip into several other little ones (12x12) using ActionScript ?

---

<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 23, 2003, 10:14pm UTC](https://forum.kirupa.com/t/fmx-split-movieclip/29188/2 "2003-08-23T22:14:08Z")

</div>

? explain what you mean please ?  
(meme en francais ca va, mais pas  
en flamand pour moi 😉 )

---

<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 23, 2003, 10:33pm UTC](https://forum.kirupa.com/t/fmx-split-movieclip/29188/3 "2003-08-23T22:33:39Z")

</div>

you would have to use masks

- have a square movieclip to represent the size of the division (you could also use empty clips and dynamically draw it)
- attach a square movieclip for each division you need
- attach the clip to be divided within each square
- move the orginal image by an offset in respect to the square which would properly represent its division
- set the square to be the orginal clips mask
- and they lived happily ever after

---

<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 24, 2003, 5:31am UTC](https://forum.kirupa.com/t/fmx-split-movieclip/29188/4 "2003-08-24T05:31:25Z")

</div>

D’accord, pas en flamand 😉 Well, here’s the situation. See my footer ? It’s a grid of outfading white boxes. The box is duplicated using duplicateMovieClip so each one is the same. What I want to do is have it say Voetsjoeba on those white boxes, but for that, I’d have to split up a movieclip (with a white background and the text voetsjoeba on it) into several 12x12 boxes. But to keep the filesize down, it should be done using AS.

---

<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 24, 2003, 10:35am UTC](https://forum.kirupa.com/t/fmx-split-movieclip/29188/5 "2003-08-24T10:35:39Z")

</div>

I’ve done something similar recently: put a clip on your scene, instance name ‘pom’, and that code in the first frame:

```auto
num = 10 ;
w = Math.ceil(pom._width/num) ;
h = Math.ceil(pom._height/num) ;
pom._visible = 0 ;
Mouse.hide() ;

MovieClip.prototype.drawMask = function (wi, he, x, y) {
	with (this.createEmptyMovieClip("mask", 0)) {
		beginFill (0, 100);
		moveTo (x, y) ;
		lineTo (x+wi, y) ;
		lineTo (x+wi, y+he) ;
		lineTo (x, y+he) ;
		endFill() ;
	}
	this.setMask(this.mask) ;
}
function spring () {
	var ax = (_xmouse - this._x) * this.k1 ;
	var ay = (_ymouse - this._y) * this.k2 ;
	this.vx += ax ;
	this.vy += ay ;
	this._x += this.vx ;
	this._y += this.vy ;
	this.vx *= .9 ;
	this.vy *= .9 ;
}
for (var i=0; i < num; i++) {
	for (var j=0; j < num; j++) {
		dep ++ ;
		var cl = pom.duplicateMovieClip ("c"+dep, dep) ;
		cl._x = pom._x ;
		cl._y = pom._y ;
		cl.drawMask (w, h, w*i, h*j) ;
		cl.n = dep ;
		cl.k1 = Math.random()/10 + .01 ;
		cl.k2 = cl.k1/2 ;
		cl.onEnterFrame = spring ;
	}
}

```

Just replace the spring function by whatever you’ll like 🙂
