Skip navigation
Currently Being Moderated

How do I detect the Previous Frame in a if/then statement?

May 7, 2012 9:00 PM

Tags: #frames #ifthen

I am attempting to instill certain conditions based on where the play head has been. In the code below, I would like to check if the previous frame was frame 6. If so, then something should happen. I get an error saying "Target of assignment must be a reference value."


//Check certain conditions and adds the appropriate movie clip.

if (prevFrame() = "6")



    page4_xText_2.x = 223;

    page4_xText_2.y = 51;

    bnt_forwardPage_5b.visible = true;

    bnt_backPage_5b.visible = true;





    page4_xText_1.x = 203;

    page4_xText_1.y = 103;

    bnt_forwardPage_5.visible = true;

    bnt_backPage_5.visible = true;




Any suggestions?

  • Currently Being Moderated
    May 7, 2012 10:11 PM   in reply to Mr. Baker the Shoe Maker

    You have a lot of problems there.


    That specific error is because you are tyring to assign the string "6" to a function called prevFrame(). What you want inside of if statements is the comparison operator == not the asignment operator =.


    BUT that won't fix your problem either. prevFrame() isn't what you think it is. It is a method (function) of the MovieClip class that tells the playhead to goto the previous frame. If your movie is playing normally, then all you need to know is




    If your movie is playing in some kind of random order then you will need to make a way of keeping track of which frames and then use that technique to know. There is no built in way of knowing which frame was played before the current frame.


    Or, when you get to frame six you could tell flash to wait one more frame and then do something.


    Whatever it is that you are actually trying to do, there is probably a different and easier way to do it.

    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