View Full Version : Rollover?
Dusky
08-24-2007, 02:01 PM
Hey there. I wasn't really sure where to post this but here goes...
For my school project, I have to make a sort of simple quiz game for little kids in Flash. In this game you have to have a map screen, with buttons on it to take you to other parts of the game. What I want to do make it so when you rollover one of the buttons, text appears describing the buttons in place of the text already on the page ("Rollover to see description.") Is it possible to do it within one frame, because the other frames have other parts of the game on it? I know it says something about it in the Flash 2004 handbook because my teacher lent it to me before summer (I had to give it back though - thats why I need help now). I'm using FlashMXProfessional 2004, on a Mac, if that makes a difference?
Can anyone help?
Thanks,
Dusky
Welcome aboard,
You can definately handle that in one frame.
Make the textField Dynamic and give it an instance name, then target that in the rollOver code of the buttons.
Something like this would do it:
(This is with a btn/mc named "myBtn" and a textField named "myText")
this.myBtn.onRollOver = function() {
this._parent.myText.text = "new Text";
};
Oh, duh...you said mx, I posted a F8 file...
Here the MX version if you want to see an example in action.
Dusky
08-24-2007, 02:56 PM
Thanks.
I tried it out, but it's coming up with errors.
I put in:
this.maptext.onRollOver = function() {
* * this._parent.maptext.text = "Level 1 - Mars. Watch a movie and answer questions on it.";}
but it says: **Error** Scene=Scene 1, layer=Background, frame=3:Line 4: Operator '=' must be followed by an operand
* * this._parent.maptext.text = "Level 1 - Mars. Watch a movie and answer questions on it.";}
Am I doing something wrong?
Well, I don't see why it would error...If i paste this into an actions window it parses just fine:
this.maptext.onRollOver = function() {
this._parent.maptext.text = "Level 1 - Mars. Watch a movie and answer questions on it.";
};
But, beyond that, this won't work for a few reasons even if the code doesn't error out...
First, onRollOver is a method of movieClips. So, you can't place that directly on a textField. You would have to nest your text field inside a movieClip and then target it from there.
Also, you are misunderstanding the use of _parent.
_parent means that you are targeting an object on a timeline above the current one. In this case you are trying to send information to the .text field of the object maptext, which is not on the parent timeline, it is in the current one.
But like I said, you cannot do a rollOver on a textField anyways...
Try it like this.
Create a movieClip and then inside that clip create your textField.
Then on the main timeline holding the movieClip, place this code:
//Target the movieClip and declare the rollOver
this.myMc.onRollOver = function() {
//Target the maptext object INSIDE this clip using "this".
this.maptext.text = "Level 1 - Mars. Watch a movie and answer questions on it.";
};
Unless I'm misunderstanding and you are targeting a movieClip/button with your code...
If that is the case then you would just need to change the name of your textField object, as it is the same as your button object...
If you want to post your file here I would be glad to take a look at it btw, just "Save and Compact" it, zip it up and attach it here.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.