[FMX] Split Movieclip

Hi,

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

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

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

D’accord, pas en flamand :wink: 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.

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

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 :slight_smile: