Skip navigation
Currently Being Moderated

Dynamically add frames to movie clip?

May 15, 2012 7:31 AM

Tags: #add #frames #dynamically

Hello!

 

Im trying to figure out a way to add frames to a movie clip timeline with AS3. The number of keyframes that will be added depends on user input so i can not set them in advance. Is there a way to do this? Im using AS3.

 

may be i am thinking wrong

here is the scenario

 

Im trying to figure out a way to add frames to a movie clip timeline with AS3. The number of keyframes that will be added depends on user input so i can not set them in advance. Is there a way to do this? Im using AS3.

I want the user to be able to load a couple of images (unknown amout) and then "play" through these images as an animation. You should also be able to pause and resume the animation. The loading works fine (getting all the URLs into an array etc) but the next part is trickier.

 

plz tell me if u have better solution?

 

Thanks

 
Replies
  • Currently Being Moderated
    May 15, 2012 7:54 AM   in reply to Usama Mushtaq

    Try to find a slideshow tutorial that displays images automatically where you can adjust the timing.  Search Google using terms like "AS3 self-run slideshow tutorial"

     
    |
    Mark as:
  • Currently Being Moderated
    May 16, 2012 3:08 AM   in reply to Usama Mushtaq

    You can use an empty MovieClip for that

     

    Basically, create an empty MovieClip with as many frames as you need (depending on your fps, obviously) to act as some sort of timer. Adobe's default Timer cannot "pause", it can only "stop", so I don't recommend it for  the task at hand.

     

    Let's say you create a MovieClip named "mc_timer" with 24frames in it. With 24ffps, this means the image changes every second. Convert the 24th frame into a keyframe, and have it call for a function in root that will advance the slide

     

    Let's say you have this code in root (that is the very top level)

     

    function advancePhoto():void
    {
         //do your image changing routine here
    }
    

    At the 24th frame of your "mc_timer", put this:

     

    MovieClip(root).advancePhoto();
    

     

     

    Then, just play mc_timer. Every 24 frames it will call for "advancePhoto" function. To "pause" the slideshow, simply call mc_timer.stop(), the playhead will stay put (simulating a pause), and to resume just call mc_timer.play(), the playhead will start playing from its current position

     

    With this, the photo can change indefinitely without anywork on your part. Just make sure you stop the mc_timer in case you don't need it anymore

     
    |
    Mark as:
  • Currently Being Moderated
    May 16, 2012 4:14 AM   in reply to Usama Mushtaq

    >>may be i am thinking wrong

     

    Yes, you are. Disard the notion of the timeline, you don't need it. You'd be much better off doing this with pure as3 - just use a tweening package such as TweenMax - look at TimelineMax actually for being able to pause, rewind, etc.

     
    |
    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