5 Replies Latest reply: Jan 29, 2013 7:00 PM by kglad RSS

    Help: Tween array conflicting with background movie clip (.gif)

    raberboy23

      Firstly, I am new (under 2 months) to OOC programming. I am developing a fairly basic objective class space-shooter style flash game in AS3, which started out as a hobby, and is quickly progressing into a piece for my portfolio. It originally only contained 1 layer with 6 key frames for each stage in the swf (loading screen, main menu, game, controls, etc.) but my friend encouraged me to add a background layer to make it more presentable.

       

      That is when I ran into my current issue. I completed the following steps, in adding my background:

       

      New layer named Background

      Drag below Game layer in the timeline

      Insert new symbol, make movieclip

      Import to library

      Drag .gif bitmap onto layer

      Drag symbol onto Background layer

       

      The background layer shows up behind all of my objects, buttons and symbols on every keyframe, but when I test my swf, the background is black (the solid I set for my Game layer).

       

      I tweeked the script in the first frame of my Game layer by "noting out" the tweenIn(); and stop(); commands, and suprisingly the background .gif appears, but isn't animating through the subsequent frames of the .gif. If I unnote stop();, I get the same results. However, if I only unnote tweenIn();, then the issue resumes and the background layer is invisible. I am not receiving any errors or warnings in Compiler Errors or Output.

       

      These results of my troubleshooting led me to believe that my tweenIn function isn't written correctly or doesn't play very nicely with other layers on the frame. Here is my current script. I took the liberty in noting every line, just so there isn't any confusion in understanding my logic.

       

       

                       private function tweenIn() {
                                 // make tweens a new array
                                 tweens = new Array();
                                 // loop through all on screen content
                                 for (var i=0; i<numChildren; i++) {
                                           // make a reference to the current object
                                           var ob = getChildAt(i);
                                           // make a tween for the current object
                                           var tw:Tween = new Tween(ob,                     // the object to tween
                                                                                        "x",                                  // the property to tween
                                                                                        Regular.easeInOut,                    // the easing function to use
                                                                                        ob.x - stage.stageWidth*2,            // starting value
                                                                                        ob.x,                                 // end value
                                                                                        15+(i*30))                            // the time to take
                                           // add the tween to the list of tweens
                                           tweens.push(tw);
                                 }
                       }
      
      

       

      My friend said that it could be the array, but I couldn't find another way to use my tween without using an array.

       

      I really would appreciate anybody who could offer their expertice, opinion and/or words of encouragement.

       

      Thank you, kindly,

      Alex

        • 1. Re: Help: Tween array conflicting with background movie clip (.gif)
          kglad MVP

          it's more likely your start and end tween parameters.

           

          for example, anything that initially has its x property=0, will tween from the x=-stage.stageWidth*2 to x=0.

          • 2. Re: Help: Tween array conflicting with background movie clip (.gif)
            raberboy23 Community Member

            Kglad,

             

            Thank you very much for the response.

             

            In the keyframe for my background, I do not call on it to tweenIn();, so I don't believe that it should be affected.

             

            Alex

            • 3. Re: Help: Tween array conflicting with background movie clip (.gif)
              kglad MVP

              that's not the implication of your first message.  ie, if you comment out

               

              /*

                var tw:Tween = new Tween(ob,                     // the object to tween
                                                                                                "x",                                  // the property to tween
                                                                                                Regular.easeInOut,                    // the easing function to use
                                                                                                ob.x - stage.stageWidth*2,            // starting value
                                                                                                ob.x,                                 // end value
                                                                                                15+(i*30))                            // the time to take
                                                   // add the tween to the list of tweens
                                                   tweens.push(tw);

              */

               

              and your background appears, that tween IS the issue.

              • 4. Re: Help: Tween array conflicting with background movie clip (.gif)
                raberboy23 Community Member

                Kglad,

                 

                My apologies, I see what you were getting at now, in your first post.

                 

                I commented out the tween paramaters, as you suggested, and the background image loaded, just as you were expecting.Now my buttons don't work, but thats alright, gotta fix one problem to troubleshoot the next, right?

                 

                I really appreciate the expert advice on this topic, this thread can be closed.

                 

                Alex