A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: if statement

  1. #1

    if statement

    how do you make an "if" statement cause a movie clip to play a certain frame if it's at frame 1 and "stop" or "play" at other frames.

    Something like:

    if(_root.myMovieClip=frame(1)){
    play.nextFrame;
    }
    else{
    play();
    }

    This isn't right but any help would GREATLY appreciated.

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    if(_root.myMovieClip._currentframe = 1){

  3. #3
    Flasher
    Join Date
    Nov 2002
    Posts
    171
    should it not be

    if(_root.myMovieClip._currentframe == 1){

    to test for equality?

    im unsure cos iaskwhy seems to be a flash master......
    Last edited by richblend; 07-21-2003 at 10:08 AM.

  4. #4
    Ya _root.myMovieClip._currentframe = 1 would cause the movieclip to go to frame one.

  5. #5
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Believe it or not, it works either way. But it will not cause it to go to frame 1 if it's inside an if statement.

  6. #6
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Check it out.
    Attached Files Attached Files

  7. #7
    Flasher
    Join Date
    Nov 2002
    Posts
    171
    thats me told then

  8. #8
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    No, yours is the correct way.

    if(_root.myMovieClip._currentframe == 1){

    Both work, sending the mc to the nextFrame, but the double == works only if it's on frame 1. Mine works no matter what frame it's on, so technically it's wrong.

  9. #9
    Senior Member the_protectot's Avatar
    Join Date
    Jul 2003
    Posts
    401
    Umm first of all,the "_currentframe" property is read-only; it can't be set, just retrieved. So the correct code would be...

    code:

    if(_root.myMovieClip._currentframe==1){
    _root.myMovieClip.nextFrame();
    }
    else{
    _root.myMovieClip.play();
    }


  10. #10
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    >>Umm first of all,the "_currentframe" property is read-only; it can't be set,

    Well of course it can. It's one of the easiest ways to make a movie clip fast forward.
    Attached Files Attached Files

  11. #11
    Senior Member the_protectot's Avatar
    Join Date
    Jul 2003
    Posts
    401
    Like I said, the _currentframe property can not be set. In your movie, you're just telling the MC to go to whatever the currentframe is, plus or minus whatever number. You are still READING the value of current frame then using that value to do stuff.

    For instance: you used

    gotoAndPlay(_curentframe + 2); //READ the currentframe and go two more.

    That's not the same as saying..

    this._currentframe = 1; //can't be done

  12. #12
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Maybe IASKWHY should change his handle to IWONDERWHY!

  13. #13
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    I'll concede the point that the reference guide 'says' that _currentframe is read only. On the other hand, you can use this.gotoAndStop(_currentframe); and it works, so I think it's pushing the point at best. I wonder why?

  14. #14
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    But then this.stop(); would do the same! So maybe change your handle to WHYBOTHER!

  15. #15
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Maybe I should wonder why they haven't named this the Oldnewbie Flash Mx forum? You seem to have taken it over.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center