A Flash Developer Resource Site

Results 1 to 4 of 4

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
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    you have the correct idea, but wrong sintax.

    to do this you use the _currentframe property of the MovieClip

    a comparison uses two equal signs:
    = ->this is assignment
    == ->this is comparison

    if this is what you want:
    code:

    if (_root.myMovieClip._currentframe == 1) {
    _root.myMovieClip.nextFrame();
    } else {
    _root.myMovieClip.play();
    }
    //is the same as:
    with (_root.myMovieClip) {
    if (_currentframe == 1) {
    nextFrame();
    } else {
    play();
    }
    }


  3. #3
    one more question for ya. i only use movie clips now. no buttons. more flexibility. i'm trying though, to figure out how to cause a movie clip to stay on a frame while a photo gallery slide show takes place. i'm guessing the code goes something like:

    //movie clip is playing
    if(_root.myMovieClip.play=true){
    //the rollover image _root.myMovieClip.myMovieClipChild.gotoAndPlay(2);
    }
    //movie clip isn't playing
    if(root.myMovieClip.play=false){
    //the 'up' image
    _root.myMovieClip.myMovieClipChild.gotoAndPlay(1);
    }

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    there is no direct way to know whether a movie clip is playing or not
    butI guess you can define a variable isPlaying that tests that:
    code:

    some_mc.isPlaying = true;
    //or
    some_mc.isPlaying = false;


    and then you can test the condition:
    code:

    if(some_mc.isPlaying == true){
    //something happens
    }else{
    //something else happens
    }


    when you test if something is true or not:
    code:

    if(some_mc.isPlaying == true)
    //is the same as:
    if(some_mc.isPlaying)
    //ie, you can ommit the true


    the same applys when you're testing if a condition is false:
    code:

    if(some_mc.isPlaying == false)
    //or
    if(!some_mc.isPlaying)
    //notiece the !


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