tilebased movieclips - unload og load
Jeg har alle movieclip som står i arrayet "tiles", liggende i librabry.Jeg har følgende kode i første frame:
var tiles = new Array([['a0'], ['a1'], ['a2'], ['a3'], ['a4']], [['b0'], ['b1'], ['b2'], ['b3'], ['b4']], [['c0'], ['c1'], ['c2'], ['c3'], ['c4']], [['d0'], ['d1'], ['d2'], ['d3'], ['d4']]);
colums = tiles[0].length;
rows = tiles.length;
visible_areax = 60;
visible_areay = 60;
this.attachMovie("empty_clip", "src", 0);
this.src._x = 0;
this.src._y = 0;
function buildMap() {
for (i=0; i<colums; ++i) {
for (j=0; j<=rows; ++j) {
this.src.attachMovie(tiles[i][j], "t_"+i+"_"+j, ++d);
this.src["t_"+i+"_"+j]._x = j*30;
this.src["t_"+i+"_"+j]._y = i*30;
}
}
}
buildMap();
onEnterFrame = function () {
move_vertical();
move_horisontal();
};
function move_vertical() {
if ((this.src._x+this.src.t_0_0._x)>0) {
if (_xmouse>=60) {
movement = -3;
} else {
movement = 0;
}
} else if ((this.src._x+this.src.t_0_4._x)<60) {
if (_xmouse<=10) {
movement = 3;
} else {
movement = 0;
}
} else if (_xmouse>=60) {
movement = -2;
} else if (_xmouse<=10) {
movement = 2;
} else {
movement = 0;
}
this.src._x += movement;
}
function move_horisontal() {
if (_ymouse>140 && this.src._y>0) {
movement = -2;
} else if (_ymouse<10 && this.src._y<140) {
movement = 2;
} else {
movement = 0;
}
this.src._y += movement;
}
Problemet er at jeg skal have gjort således at mine tiles bliver loadet og undloadet hele tiden, når jeg bevæger mine tiles rundt. Altså inde for et bestemt område.
