Forum Topic: AttachMovie not working

(72 views • 1 reply)

This topic is 1 page long.

<< < > >>
None

ShirkDeio

Reply To Post Reply & Quote

Posted at: 7/14/09 08:43 PM

ShirkDeio LIGHT LEVEL 16

Sign-Up: 03/29/07

Posts: 989

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.

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.

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.

I am a servant of the Most High God
The Hanging Collab || The Legend of Newgrounds (Game) || Crystal Rays (Song)


None

ShirkDeio

Reply To Post Reply & Quote

Posted at: 7/14/09 09:01 PM

ShirkDeio LIGHT LEVEL 16

Sign-Up: 03/29/07

Posts: 989

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.

I am a servant of the Most High God
The Hanging Collab || The Legend of Newgrounds (Game) || Crystal Rays (Song)


All times are Eastern Standard Time (GMT -5) | Current Time: 10:29 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!