Skip to main content
Inspiring
June 6, 2014
Question

Using attachMovie multiple times to create a tile background

  • June 6, 2014
  • 1 reply
  • 313 views

I'm want to tile a 700 x 700 area using attachMovie().

The movieclips used for the attachMovie is 50 x 50

This is the code. Something is wrong here.

var NuX:Number=0;

var NuY:Number=0;

var btnX:Array=[gpat_btn0, gpat_btn1, gpat_btn2];

var attX:Array=["pat0","pat1","pat2"];

for(i=0;i<btnX.length;i++){

  btnX.pvar=i;

  btnX.onRelease = function(){

  NuX=NuY=0;

  for(j=0;j<14;j++){

  if(NuX>=650){

  NuX=0;

  NuY=NuY+50;

  }

  _root.movieC1.movieC2.clip0.attachMovie(attX[this.pvar], attX[this.pvar]+j, _root.movieC1.movieC2.getNextHighestDepth(), {_x:NuX, _y:NuY});

  NuX=NuX+50;

  //trace(NuX)

  }

  }

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 6, 2014

you're going to need 296 tiles and you're only creating 14. extend the for-loop.

Inspiring
June 6, 2014

Thanks.

But my problem is that the code is not working at all? There might be some error in the code? I have doubts with this particular line?

_root.movieC1.movieC2.clip0.attachMovie(attX[this.pvar], attX[this.pvar]+j, _root.movieC1.movieC2.getNextHighestDepth(), {_x:NuX, _y:NuY});

kglad
Community Expert
Community Expert
June 6, 2014

use trace(attX[this.pvar]) to see if a linkage id is being traced.