Skip navigation
raberboy23
Currently Being Moderated

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

Jan 29, 2013 2:44 PM

Tags: #flash #as3 #action_script_3 #layers #tween #cs6 #.gif #games #movieclip_symbol #background_movieclip

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

 
Replies
  • kglad
    72,340 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 29, 2013 3:16 PM   in reply to raberboy23

    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.

     
    |
    Mark as:
  • kglad
    72,340 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 29, 2013 6:08 PM   in reply to raberboy23

    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.

     
    |
    Mark as:
  • kglad
    72,340 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 29, 2013 7:00 PM   in reply to raberboy23

    no problem.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points