• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

If statement

Hi, Experts:
I have the following scripting. How to make it to an If statement ? thanks

carnival.onRollOver = function(){       <--------carnival is movie clip instance name
      this.gotoAndPlay(2);
}

carnival.onRollOut = function(){
      this.gotoAndPlay(1);
}
0
Brian Lin
Asked:
Brian Lin
  • 2
  • 2
1 Solution
 
BillystyxCommented:
Why do you need an If statement - what do you want it to do that it is not doing right now?

Billystyx
0
 
blue-genieCommented:
my first question is why you want to make it an if statement?

what you can do is make use of a mouse listener, so it checks everytime the mouse moves, is it over the carnival movieclip, if it is do whatever, if its not - do the other thing.

as in......

stop();
// Create a mouse listener object
var mouseListener:Object = new Object();
/* Every time the mouse cursor moves within the SWF file,
  update the position of the crosshair movie clip
  instance on the Stage.*/
mouseListener.onMouseMove = function() {
      if (_root.carnival.hitTest(_xmouse, _ymouse, true)) {
            _root.gotoAndStop(2);
      } else {
            _root.gotoAndStop(1);
      }
};
Mouse.addListener(mouseListener);

blu.
0
 
Brian LinDesignerAuthor Commented:
I want to know if i can write...

if mouse roll over on carnival movie clip, then the picture will move. If I roll out from carnival movie clip, then the picture will stop.

if ( carnival == XXX ) {      <-- what should I put
     this.gotoAndPlay(2);
} else {
     this.gotoAndPlay(1);
}
0
 
Brian LinDesignerAuthor Commented:
wow, it is much complex then I though....
0
 
blue-genieCommented:
the code above will do the trick then, it's not that complex, listeners once you get your head around it are a very good thing to know.

however, if that is all you're trying to achieve, there's nothing wrong with doing it your original way.
blu.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now