2 Replies Latest reply on Apr 16, 2007 1:23 PM by hey_duude

    random .attachMovie bug

    hey_duude Level 1
      Hi i'm creating a simple game for a uni project, where the user has to catch falling objects... you know the sort of thing.
      I've done it by creating movie clips of objects falling in the library and loading them (using .attachMovie) randomly every 20 frames into empty MC that exist on stage. Problem is that when i test or publish the movie the clips do not always attach to the empty clips, i've spent a couple of days trying to figure it out, it seems to be random and when i used debug mode and put breakpoints in before and after the .attachMovie command it seems to work fine, i'm stumped. Any ideas would be very much appreciated as i have to hand this in on friday and am not a fan of failure.
        • 1. Re: random .attachMovie bug
          Rothrock Level 5
          Your going to have to show us some code.

          The way you say every 20 frames, sounds a little suspicious. Generally it isn't such a good idea to combine timeline with Actionscript. So there may be a looping problem or some such.
          • 2. Re: random .attachMovie bug
            hey_duude Level 1
            Well basically i have this piece of code:

            //attach movie
            ObjectHolder1.attachMovie(WhichObject[objectnumber], "Object1_mc", 0);

            which runs in the timeline of a scene every 20 frames.

            WhichObject is a list containing the 10 names of the different movie clips, objectnumber is a random number.
            There are 4 ObjectHolders, so in frame 1 is the code above, in frame 20 is:

            ObjectHolder2.attachMovie(WhichObject[objectnumber], "Object2_mc", 0);

            etc.

            So the entire timeline is 100 frames then it loops. Most of the movie clips that are attached are 50 frames long, 1 of them is 100 frames (so the object falls more slowly).

            the movieclips are unloaded after 50 frames or 100 frames depending which movieclip is attached using

            ObjectHolder1.unloadMovie("Object1_mc"); inside an if statement which determines which movieclip is playing from variables which are set when the clip is attached.

            using Trace() and debug mode it seems that sometimes (apparently randomly) the .attachMovie line of code doesn't work when i run the movie. But when i put a breakpoint on this line and run it in debugger it seems to always work.

            Does that make it any clearer? I hope so i'm quite desperate. I am a bit of a newbie so i appreciate that i have probably chosen a terrible way of creating this, all advice is appreciated.

            Thanks