-
shavingcream incarnate
Inexplicable Bug
So I'm programming a (hex) tile based game, and after running the drawHexMap function shown here with drawHexMap(map1, storageArray, 30, 50, 50)
The storageArray array is filled with the pointers to the tiles, organized by the type of tile (the frame)
Actionscript Code:
function drawHexMap(map, storageMap, tileS, borderX, borderY){ //the map that should be passed is a 2d array of ints, containing how the hex map will be laid out var tile, depth; for(var i = 0; i < map.length; i++){ for(var j = 0; j < map[0].length; j++){ depth = _root.getNextHighestDepth(); tile = _root.attachMovie("hex_tile","HT:"+i+","+j, depth); depth = tileS / tile._width * 100; //re-use depth var tile._xscale = tile._yscale = depth; tile._x = borderX + (tileS*j + (i%2)*tileS/2); tile._y = borderY + (i*tileS*(tile._width / tile._height)); tile.r = i; //row tile.c = j; //col- depth = map[i][j]; //re-use depth again tile.gotoAndStop(depth + 1); if(!storageMap[depth]) storageMap[depth] = []; storageMap[depth][storageMap[depth].length] = tile; } } }
For some reason, when i call this later code in my EnterFrame function (shown below), which should make the alpha of a single tile 50 when scrolled over, doesn't work at all.
Actionscript Code:
for(var i = 0; i < storageArray.length; i++){ for(var j = 0; j < storageArray[i].length; j++){ tempTile = storageArray[i][j] trace(i+","+j+" \t["+tempTile+" ("+tempTile._x+", "+tempTile._y+") ].hitTest("+_xmouse+", "+_ymouse+", true) = "+ tempTile.hitTest(_xmouse,_ymouse,true)); if(tempTile.hitTest(_xmouse, _ymouse, true)){ tempTile._alpha = 50; } else tempTile._alpha = 100; } }
I've run the exact same code, but instead using a different array that i filled manually, and it works perfectly. I can't seem to figure out why this would happen. Could it be that my code somehow got corrupted and there is no real bug in the coding? Is that even possible? Please help, i've been trying to figure this out for hours
Thanks in advance - gukinator
-
Client Software Programmer
if youre just trying to make each tile to alpha 50 why dont you put this code on the tile:
PHP Code:
on(rollOver){ this._alpha=50; } on(rollOut, dragOut){ this._alpha=100; }
-
shavingcream incarnate
Since each tile is placed dynamically, i can't place code on the mc without replacing attachMovie with duplicateMovie. If i were to do this, flash would have to create a new thread for each movie clip, instead of one main onEnterFrame for them all, which is extremely slow, especially with increasing numbers of tiles.
At least i think, if i know on(enter frame) creates a new thread, i'm not 100% sure if on(rollOver), etc. does
-
Client Software Programmer
hmm not sure than I was just trying to help
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|