Den movie jeg jeg vil hente, er ret indviklet. Kan det ha noget med det at gøre? Den virker fint hvis jeg kører den som .swf og .exe fil. Den kan også kun køre i actionScript 1.0 flashplayer 5.0.
det hjalp da jeg slettede en af koderne - jeg kom lige til at se at de begge var skrevet ind. Men du kan stadig tjene nogle point :-)
Nu loader den filmen ind, men den loader den ikke ind i selve movieClip'et, men halvt inden og halvt udenfor spil movieClip'et. Har du en god løsning på det?
Det er det her spil den skal loade: (lidt indviklet)
Første frame:
function initGame () { // set the horizontal and vertical distance // between tiles tileDist = 77;
// set all tiles in exactly the correct spot for (x=1;x<=3;x++) { for (y=0;y<=2;y++) { tile = x+y*3; _root["tile"+tile]._x = x*tileDist; _root["tile"+tile]._y = y*tileDist+tileDist; } }
// make 10 random but valid moves for(tilenum=0;tilenum<10;tilenum++) { do { // pick a random tile tile = "tile"+(random(8)+1); // see whether there is an empty space near it emptySpace = findEmpty(tile); // keep looping until a tile is found that // has an empty space near it } while ( emptySpace == "none" );
// move this tile to the empty space moveTile(tile,findEmpty(tile)); } }
// given a tile, see if the empty space is near it function findEmpty (tile) { // get location of tile tilex = _root[tile]._x; tiley = _root[tile]._y;
// see whether there is a tile to the left if (tilex > tileDist) { if (!tileThere(tilex-tileDist, tiley)) { return("left"); } }
// see whether there is a tile to the right if (tilex < tileDist*3) { if (!tileThere(tilex+tileDist, tiley)) { return("right"); } }
// see whether there is a tile above if (tiley > tileDist) { if (!tileThere(tilex, tiley-tileDist)) { return("above"); } }
// see whether there is a tile below if (tiley < tileDist*3) { if (!tileThere(tilex, tiley+tileDist)) { return("below"); } }
// tiles are in all directions return("none"); }
// check to see whether there is a tile at a certain location function tileThere (thisx, thisy) { // loop through tiles for (i=1;i<=8;i++) { // see if x matches if (_root["tile"+i]._x == thisx) { // se if y matches if (_root["tile"+i]._y == thisy) { return true; } } }
// no tile there return false; }
// move a tile in a certain direction function moveTile (tile, direction) { if (direction == "above") { _root[tile]._y -= tileDist; } else if (direction == "below") { _root[tile]._y += tileDist; } else if (direction == "left") { _root[tile]._x -= tileDist; } else if (direction == "right") { _root[tile]._x += tileDist; } }
// utility function to see on which tile the // player clicked function tileUnderMouse () { for (i=1; i<=8; i++) { if (_root["Tile"+i].hitTest(_xmouse, _ymouse)) { return (i); } } }
initGame(); stop();
Ved siden af selve filmen ligger der et movieClip med følgene actionScript:
onClipEvent(mouseDown) { // get tile clicked tileClicked = _root.tileUnderMouse();
// see whether there is an empty space nearby emptySpace = _root.findEmpty("tile"+tileClicked);
// move the piece to the empty space _root.moveTile("tile"+tileClicked,emptySpace); }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.