[Flash 8/AS 2.0] Not Doesn't Attaching Correctly When A Calling An External SWF

I’m trying to use a SWF to call a flash-based game file that is located in an external SWF on the same server on the web. The game SWF works fine by itself or embedded in html, however when it’s called from the other SWF file all of the movie clips in the game that spawn dynamically from the game nothing lines up correctly.

The only thing that I can think of is that since the movie clips are set up to test along a grid to see if they overlap the background and something isn’t seeing the bg correctly in the larger SWF file.

I would love any insight anyone can give me and can give more details if you need them.[URL=“http://www.thedirtyearth.com”]

Here is the code that calls the game SWF (code is in AS 2.0):

_root.all_content.mg_02.onRelease = function() {
_root.loadbox._visible = true;
_root.loadbox.bgtexture._visible = true;
_root.bottom_btn.enabled = false;
_root.left_btn.enabled = false;
_root.right_btn.enabled = false;
_root.top_btn.enabled = false;
disablemenu();
_root.loadbox.mc_container._x = 130;
_root.loadbox.mc_container._y = 55;
_root.loadbox.mc_container._xscale = 80;
_root.loadbox.mc_container._yscale = 80;
_root.loadbox.mc_container.loadMovie(“url.swf”);
};

This is more or less the game code:

stop();

function startLevel() {
level = 0;

// create berries
berries = new Array();

// loop through grid of locations
for(y=1;y<16;y++) {
    for(x=1;x<22;x++) {

        // see whether the background covers location
        if (!(background.hitTest(x*37.5,y*37.5,true))) {

            // create a berry and place it there
            attachMovie("berry","berry"+level,level);
            clip = _root["berry"+level];
            clip._x = x*37.5;
            clip._y = y*37.5;

            // add to array of berries
            berries.push(clip);
            level++;
        }
    }
}

// create the fox and set his location
attachMovie("fox","fox",level++);
fox._x = 412.5;
fox._y = 412.5;

// also add movement and destination properties
fox.move = {x:0, y:0};
fox.dest = {x:412.5, y:412.5};
fox.nextmove = 0;

// create the bunny and set his location
attachMovie("bunny","bunny",level++);
bunny._x = 412.5;
bunny._y = 187.5;

// also add movement, destination, and remember previous location
bunny.move = {x:1, y:0};
bunny.dest = {x:450, y:187.5};
bunny.nextmove = 0;
bunny.last = {x:412.5, y:187.5};

}

function move() {
// see whether it is time for another move
if (getTimer() > fox.nextmove) {

    // don't allow another move for 50ms
    fox.nextmove = getTimer() + 75;

    // move fox
    fox._x += fox.move.x*7.5;
    fox._y += fox.move.y*7.5;

    // see whether the fox went though the tunnel
    if (fox._x > 825) fox._x = 0;
    if (fox._x < 0) fox._x = 825;

    // see whether the fox reached his destination
    if ((fox._x == fox.dest.x) and (fox._y == fox.dest.y)) {
        eatBerry();
        nextMove();
    }
}

}

function eatBerry() {
// assume all berries are gone
allGone = true;

// loop through all berries
for(i=0;i<berries.length;i++) {

    // see whether this berry is where fox is
    if ((berries*._currentFrame == 1) and (berries*._x == fox._x) and (berries*._y == fox._y)) {

        // remove berry
        berries*.gotoAndStop("nothing");

        // open fox mouth
        fox.gotoAndPlay("eat");

        // add to score
        score++;

    // if a berry is found that has not been eaten, then level is not over
    } else if (berries*._currentFrame == 1) {
        allGone = false;
    }
}

// if all berries eaten, then end level
if (allGone) {
    gotoAndPlay("level over");
    gameLevel++
}

}

function nextMove() {
// assume no movement
fox.move.x = 0;
fox.move.y = 0;

// check arrow keys and set potential movement
// also flip fox left or right if needed
if (Key.isDown(Key.LEFT)) {
    fox.move.x = -1;
    fox._xscale = Math.abs(fox._xscale);
} else if (Key.isDown(Key.RIGHT)) {
    fox.move.x = 1;
    fox._xscale = -Math.abs(fox._xscale);
} else if (Key.isDown(Key.UP)) {
    fox.move.y = -1;
} else if (Key.isDown(Key.DOWN)) {
    fox.move.y = 1;
}

// predict new destination
newx = fox._x + fox.move.x*37.5;
newy = fox._y + fox.move.y*37.5;
okToMove = false;

// loop through berries to see whether any match destination
for(i=0;i<berries.length;i++) {

    // found a match, set new destination
    if ((berries*._x == newx) and (berries*._y == newy)) {
        fox.dest.x = newx;
        fox.dest.y = newy;
        okToMove = true;
    }
}

// special settings for going through tunnel
if (newx == 825) {
    okToMove = true;
    fox.dest.x = 37.5;
} if (newx == 0) {
    okToMove = true;
    fox.dest.x = 787.5;
}

// if destination doesn't match berry, then don't move
if (!okToMove) {
    trace("Error: Not OK to move!");
    fox.move.x = 0;
    fox.move.y = 0;
}

}

function moveBunny() {

// see whether it is time for next bunny move
if (getTimer() > bunny.nextmove) {

    // don't allow another bunny move for a while
    bunny.nextmove = getTimer() + 60 - gameLevel*10;

    // move bunny
    bunny._x += bunny.move.x*7.5;
    bunny._y += bunny.move.y*7.5;

    // see whether bunny reached destination
    if (bunny._x == bunny.dest.x and bunny._y == bunny.dest.y) {

        // create an array of possible next locations
        possibilities = new Array;    
        for(i=0;i<berries.length;i++) {

            // calculate distance from present location to berry
            xdiff = Math.abs(berries*._x - bunny._x);
            ydiff = Math.abs(berries*._y - bunny._y);

            // see whether this is an adjacent berry
            if ((xdiff == 37.5 and ydiff == 0) or (xdiff == 0 and ydiff == 37.5)) {

                // then this is a possibility
                possibilities.push(berries*);
            }
        }

        // pick a random possibility
        do {
            r = int(Math.random()*possibilities.length);

            // get new destination and movement
            bunny.dest.x = possibilities[r]._x;
            bunny.dest.y = possibilities[r]._y;
            bunny.move.x = (possibilities[r]._x - bunny._x)/37.5;
            bunny.move.y = (possibilities[r]._y - bunny._y)/37.5;

        // use this possibility only if it is not going back to the last spot
        // or if this is the only choice
        } while ((bunny.dest.x == lastx and bunny.dest.y == lasty) and (possibilities.length > 1));

        // remember the previous location
        lastx = bunny._x;
        lasty = bunny._y;
    }

}

// see whether bunny is close to fox
if (Math.abs(bunny._x - fox._x) <= 10 and Math.abs(bunny._y - fox._y) <= 10) {
    if (lives < 1) {
        gotoAndStop("game over");
    } else {
        lives--;
        gotoAndStop("lost life");
    }
}

}