Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts

    AttachMovie not working

    This is an incredibly frustrating problem for me. I'm an advanced ASer (AS2) and I'm having problems with the most basic function here, attachMovie.

    I have a tile-based engine I've been working on. I'm using a gotoAndStop engine to scroll the tiles when the character moves. That's where my problem is.

    When I go down and right one tile (scrolling) then scroll up one tile, the far left upper tile doesn't go to the proper frame, but plays the tile movieclip.

    I spent an hour using trace functions to figure out what was going on, and I found out that the attachMovie function isn't working for that one tile.

    I use a for loop to change tiles.

    Code:
    tiles_mc.attachMovie(tile,name,depth);
    trace(tiles_mc[name]);
    If I trace this on the second-to-last tile, it returns the movieclip. If I trace this on the last tile, it appends a blank line to the output box - there's the problem. It's not the upper left tile that's screwed up, it's the upper right tile that isn't getting placed on the proper x value because attachMovie is screwing up.

    Code:
    tiles_mc.attachMovie(tile,name,depth);
    trace(tiles_mc[name]);
    trace(tiles_mc.getInstanceAtDepth(depth));
    If I trace those on the last tile, the first trace outputs a blank line, and the second trace outputs the correct movieclip!

    What is going on? This is crazy, and I have a deadline I'm trying to meet. I would really appreciate any help you could offer.

  • #2
    New Coder
    Join Date
    Mar 2007
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I made it work by adding a line of code. When I removeMovieClip for an old tile, I also delete the old tile so it leaves nothing behind. I'm not sure why it needed that, but it did and now it works.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •