15 Replies Latest reply on Jan 27, 2010 5:20 AM by beno12345

    Extending a Timeline

    beno12345 Level 1

      Hi;

      I've created an mc that's 10 frames long. When I try and get it to do something beyond those 10 frames:

       

            public function checkFrame2(e:Event):void

            {

               if (e.target.currentFrame == 20)

               {

                  e.target.removeEventListener(Event.ENTER_FRAME, checkFrame2);

                              addChild(myThumbTop);

                              addChild(myThumbBottom);

               }

            }

      it doesn't show up at all. I will be using this mc repeatedly. Please advise.
      TIA,
      beno

        • 1. Re: Extending a Timeline
          Ned Murphy Adobe Community Professional & MVP

          If the movie is only 10 frames long it cannot go beyond the 10 frames.  It is not clear to me what you are doing that would make it disappear--or what you mean by that.

          • 2. Re: Extending a Timeline
            beno12345 Level 1

            This is my first Flash movie, and I'm ambitious (for better or worse). I've called a script in the first frame and I'll I'm doing is calling and manipulating various mc's in my script. One of those mc's is 10 frames long. Now, I would have thought I could call that mc anywhere in the movie, but apparently not. If I call it on the 10th frame I can get it to loop forever. But not on the 11th, because this mc, which is in my library, is only 10 frames long. But I only want it to be 10 frames long! I just want to call it from the script anywhere in the timeline I so choose:

             

                  public function checkFrame(e:Event):void

                  {

                     if (e.target.currentFrame == 20)

                     {

                        e.target.removeEventListener(Event.ENTER_FRAME, checkFrame);

                        addChild(myThumb);

                        TweenMax.to(myThumb, .4, {shortRotation:{rotation:60}, ease:Back.easeOut});

                     }

                  }

            where myThumb is the mc. I hope that clarifies my poor question.

            TIA,

            beno   

            • 3. Re: Extending a Timeline
              Ned Murphy Adobe Community Professional & MVP

              If your movieclip is a separate movieclip object that lives in your library and it is 10 frames long, then you can place it on your timeline and extend its presence as far as you like along the timeline, from just one frame to all of them.  As long as the instance is present, it can be addressed via actionscript.  It sounds like you have only allowed it to exist from frames 1 thru 10 of the main timeline... in which case that's the only place you can interact with it.  If you want to interact with it in all frames of your timeline, it needs to be present in all frames.

              • 4. Re: Extending a Timeline
                beno12345 Level 1

                There is nothing on my timeline at all! Of course, the library widgets have their timelines. Everything is called from a separate script. So I'm still confused as to how to get this widget to exist beyond the 10th frame. I'm obviously missing something fundamental here I tried to edit my code to select only that pertinent to this problem. The code's below.    

                TIA,

                beno

                 

                package

                {

                   import flash.events.Event;

                   import flash.events.MouseEvent;

                   import flash.display.MovieClip;

                   import com.greensock.*;

                   import com.greensock.easing.*;

                 

                   public class Main extends MovieClip

                   {

                      //Import Library Assests

                                public var myThumb:CloseThumb;

                 

                      public function Main()

                      {

                         init();

                 

                      }

                 

                      public function init():void

                      {

                                        theThumb();

                      }

                 

                                public function theThumb():void

                                {

                                        myThumb = new CloseThumb();

                                        myThumb.x = head.x + 265;

                                        myThumb.y = head.y + 255;

                myThumb.addEventListener(Event.ENTER_FRAME, checkFrame);

                                }

                 

                      public function checkFrame(e:Event):void

                      {

                         if (e.target.currentFrame == 20)

                         {

                            e.target.removeEventListener(Event.ENTER_FRAME, checkFrame);

                                        addChild(myThumb);

                TweenMax.to(myThumb, .4, {shortRotation:{rotation:60}, ease:Back.easeOut});

                         }

                      }

                 

                   }

                }

                • 5. Re: Extending a Timeline
                  waterdad568 Level 3

                  It appears you are asking an object to appear in a place that does not exist. On your main timeline frame 20.

                   

                  Try this, on your main timeline, drag your mc's layer and the actions layer out past frame 20.

                   

                  Run your code again and tell us what happens.

                  • 6. Re: Extending a Timeline
                    beno12345 Level 1

                    Dragged out timeline till all blue to frame 50 in the mc widget (myThumb), which made the main timeline blue to 50 as well. Saved and ran. Results the same

                    beno

                    • 7. Re: Extending a Timeline
                      Ned Murphy Adobe Community Professional & MVP

                      You'll need to explain what you're trying to do with that code, and which object it is that has ten frames, and which has at least 20 frames (e,target).  If e.target is the object with 10 frames, it makes no sense to be checking if it is in  frame 20.

                      • 8. Re: Extending a Timeline
                        waterdad568 Level 3

                        Leave the widgets timeline alone, look at your breadcrumb trail, we want to be on the Scene1 "main" timline, not inside the mcs timeline.

                         

                        Drag the mc's timeline (on the main timeline not itself) and the actions layer out to frame 21. The actions (code) layer should be white end to end with a dot in the first frame, you may need to add a blank keyframe on frame 21, or one more than your coding to.

                        • 9. Re: Extending a Timeline
                          beno12345 Level 1

                          I cleared out the frames of the mc widget, went to main timeline (Scene 1) and added a kf at frame 50. Same result!

                          beno

                          • 10. Re: Extending a Timeline
                            waterdad568 Level 3

                            Did you also extend the the layer that has your code in it?

                             

                            Is your code on a layer in the main timeline? Or is on the widgets timeline, or somewhere else?

                            • 11. Re: Extending a Timeline
                              beno12345 Level 1

                              The code is in a separate package/file. There is nothing at all on any timeline, except the obvious in the widgets.

                              beno

                              • 12. Re: Extending a Timeline
                                waterdad568 Level 3

                                Is your runtime environment of the .as file a browser? Have you tried clearing the caches and reloading after your updates to the file?

                                • 13. Re: Extending a Timeline
                                  beno12345 Level 1

                                  No, I'm running it in Flash. All other changes I make are shown immediately as well.

                                  beno

                                  • 14. Re: Extending a Timeline
                                    waterdad568 Level 3

                                    I am probably in over my head at this point, but I'll try and give you some places to look. Does the compiler error when you publish or test your swf? Have you used the trace method anywhere to see what your code output? Are there any other objects displayed on the stage that could be covering your clip, or need to be removed before the clip is displayed? If you don't get any errors from the compiler then maybe look at your layer positions of objects in your main timeline, if the clip layer is below another objects layer that you called to the stage, then it may cover your clip unless you compensate for that objects position in your code, or layer hierarchy. Layer 1 will cover all, 2 will cover 3 etc... Maybe move you mc layer to the very top layer of your main timeline and give that a try.

                                     

                                    Best I think I can do for ya.

                                    • 15. Re: Extending a Timeline
                                      beno12345 Level 1

                                      I've pruned my code down to a few critical elements. Here is my *.as file:

                                       

                                      package

                                      {

                                         import flash.events.Event;

                                         import flash.events.ProgressEvent;

                                         import flash.events.Event;

                                         import flash.events.MouseEvent;

                                         import flash.display.MovieClip;

                                         import com.greensock.*;

                                         import com.greensock.easing.*;

                                       

                                         public class Main2 extends MovieClip

                                         {

                                            //Import Library Assests

                                                      public var myThumb:CloseThumb;

                                                      public var myThumbTop:CloseThumbTop;

                                                      public var myThumbBottom:CloseThumbBottom;

                                       

                                            public function Main2()

                                            {

                                               init();

                                       

                                            }

                                       

                                            public function init():void

                                            {

                                                              theThumb();

                                                              theThumbTop();

                                                              theThumbBottom();

                                      }

                                       

                                                      public function theThumb():void

                                                      {

                                                              myThumb = new CloseThumb();

                                                              myThumb.x = 365;

                                                              myThumb.y = 355;

                                      myThumb.addEventListener(Event.ENTER_FRAME, checkFrame);

                                                      }

                                       

                                            public function checkFrame(e:Event):void

                                            {

                                               if (e.target.currentFrame == 10)

                                               {

                                      trace('check');

                                                  e.target.removeEventListener(Event.ENTER_FRAME, checkFrame);

                                                              addChild(myThumb);

                                      TweenMax.to(myThumb, .4, {shortRotation:{rotation:60}, ease:Back.easeOut});

                                               }

                                            }

                                       

                                                      public function theThumbTop():void

                                                      {

                                                              myThumbTop = new CloseThumbTop();

                                                              myThumbTop.x = 385;

                                                              myThumbTop.y = 375;

                                      myThumbTop.addEventListener(Event.ENTER_FRAME, checkFrame4);

                                                      }

                                       

                                       

                                                      public function theThumbBottom():void

                                                      {

                                                              myThumbBottom = new CloseThumbBottom();

                                                              myThumbBottom.x = 385;

                                                              myThumbBottom.y = 375;

                                      myThumbBottom.addEventListener(Event.ENTER_FRAME, checkFrame4);

                                                      }

                                       

                                       

                                            public function checkFrame4(e:Event):void

                                            {

                                               if (e.target.currentFrame == 10)

                                               {

                                                  e.target.removeEventListener(Event.ENTER_FRAME, checkFrame4);

                                      trace('check4');

                                                              addChild(myThumbTop);

                                                              addChild(myThumbBottom);

                                               }

                                            }

                                       

                                       

                                         }

                                      }

                                       

                                      'check' does not print, but 'check4' prints twice. If I take the 'check' trace out of the if loop and leave it in the function, it prints. It doesn't matter if I reduce currentFrame to 0 or bump it up to 20 (CloseThumb is 1 frame long; I've made it a shape tween 10 frames long and that didn't help), it won't print in that if loop. What's the difference between these elements?? Why isn't it printing there when 'check4' is printing??

                                       

                                      If you'd like to take a look, here's my pared-down code and fla:

                                      http://angrynates.com/cart/main2.zip

                                      TIA,

                                      beno