?
Solved

If statement

Posted on 2005-03-29
5
Medium Priority
?
153 Views
Last Modified: 2010-05-18
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
Comment
Question by:mingchih
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Billystyx
ID: 13659819
Why do you need an If statement - what do you want it to do that it is not doing right now?

Billystyx
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 2000 total points
ID: 13659845
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
 

Author Comment

by:mingchih
ID: 13659862
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
 

Author Comment

by:mingchih
ID: 13659872
wow, it is much complex then I though....
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 13659893
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question