PDA

View Full Version : A question...



pezdemon
May 7th, 2002, 11:06 AM
Hi, didnt know what to put as the title sorry :)

Ok, what I want to do is:

When the mouse hovers over an image, or an area on my flash, i want a piece of text to appear in an area, and when the mouse goes onto another image then the text changes to the relevent piece of imformation.

Do I need to use action script? Or can I do it easily another way in MX?

I have a very rough idea on what to do using dynamic text boxes, but I dont know where to start really!!!!

If there is a tutorial on this I have over looked, please feel free to point in the right direction!

Thanks, Pez.

upuaut8
May 7th, 2002, 11:40 AM
It's really easiest to do with action script..or I should say.. the only way to do it properly is with action script.

You could just put the text in the rollover state of the button in question. It would apear as you desire it, every time someone rolls over the button.. but that's not efficient and it's really just too darn easy. :)

Are you only using Flash MX, or do you have Flash 5.0?.. because I can only describe how to do it in Flash 5.0 terminology. They changed the panels around on us in Flash MX.

pezdemon
May 7th, 2002, 11:43 AM
I only have MX, sorry. I only started using flash last weekend, so I really dont know how to do anything, this is just something I've always wanted to do :D

upuaut8
May 7th, 2002, 01:06 PM
Well.. give me a little time and I'll work out something for you. I'm sure Pom will correct me if I make any minor mistakes. For the most part, 5.0 and MX are the same.. it's just the location of the panels that is a little different.

pezdemon
May 7th, 2002, 01:09 PM
Thanks, i will work on the rest in the mean-time.. :D

upuaut8
May 7th, 2002, 01:53 PM
Well the easiest way is to start simple and learn the basics first.. so I want to you work on a new movie.. not the one you're currently working on.

Create a button on the main timeline.

Create a new layer.
Select your text tool.
Now.. here's where I'm not sure how MX differs. Look in your text panel. There should be a place for "text options". However, this might be in the properties panel at the bottem of the main window. Look for a pull down where you can choose, "Dynamic text".

Once you've got that chosen, in the blank layer, click and drag with the text tool until you've described a box which will be large enough for the text you want to have in it. For now it doesn't have to be really large, and you can always resize it later.

You'll see that the text box stays there and if it is selected with the black arrow tool will have a blue bounding box around it.

With this text box selected, you should see a text field in the properties panel which lets you enter a variable name. Enter "myFirstTextField" into that field.

Now for the button.

Select the button you've got on the main timeline and open your "action" panel. Paste the following code.

on(rollOver){
myFirstTextField=entryNumber1;
}

With the button still selected, choose menu option "Edit/Copy" and then "Edit/Paste". Another button will be pasted on the stage. Move it a little to the right of the first one. Paste another copy and move it a little to that one's right. Just basicaly line them all up down near the bottom of the screen somewhere.

Select the second one and change the script so that it looks like this.

on(rollOver){
myFirstTextField=entryNumber2;
}

then do the same for the third button so that it says 3 instead of 2.

Now.. as a final step.

create a new layer. Select frame one of that layer and paste the following script

entryNumber1="Hello.. this is my first dynamic text message.";
entryNumber2="Flash MX Rocks";
entryNumber3="DHTML eat your heart out.";

------------------------

I know that the above looks a little confusing.. but just do it step by step. If it doesn't work right the first time, write back to me and I'm sure we can fix it.

Basicaly what I've done is set you up with the most dynamic of all situations. Your dynamic text field is going to change to whatever the variable myFirstTextField is equal to. The buttons on rollOver, set that variable to equal each of three separate variables that we've set on the main timeline. If you want to you can add this to each of the buttons

on(rollOff){
myFirstTextField="";
}

that will make the feild go blank when you roll off of any of the buttons..

let me know how it works out.

pezdemon
May 7th, 2002, 02:10 PM
I just attempted it, and it didnt work, i think i messed up somewhere, so i will run through it again... by create a button, do you just mean make a circle, convert it to a symbol and make it a button? Because thats what i did.

pezdemon
May 7th, 2002, 02:17 PM
Just attempted it again and failed, I see the theory behind it, and it should work, i must be doing something wrong.

RenaissanceGirl
May 7th, 2002, 03:10 PM
Do you have AIM? Message me and I'll walk you through it; my sn is: RenaissanceGerl

upuaut8
May 7th, 2002, 03:38 PM
and if not.. just let me know.. I'll make the example here in Flash 5.0 and send it to you.

RenaissanceGirl
May 7th, 2002, 06:00 PM
Maybe this should help you out. Start with a fresh new movie. Create a textbox on the main timeline. Note that you have to label the textbox in two places. I have no idea what those kooky Flash people were thinking either... just do it. It should look something like this:
<img src="http://members.tripod.com/renaissancegirl/direct/textbutton1.txt" width="540" height="370">

Now create a button. It doesn't matter what the button looks like and for time's sake, I just used one from the components library. Select the button from the stage and add this script:
<img src="http://members.tripod.com/renaissancegirl/direct/textbutton2.txt" width="540" height="370">

We're almost there! Finally, just add some default text that will appear when nothing has been clicked yet.
<img src="http://members.tripod.com/renaissancegirl/direct/textbutton3.txt" width="540" height="370">

Now, just add a couple more buttons and add the exact same button scripts from the second step, with a slight modification of the text ofcourse, and you should be all set! See:

<EMBED src="http://members.tripod.com/renaissancegirl/direct/textbutton.swf" quality=high bgcolor=#FFFFFF WIDTH="300" HEIGHT="200" NAME="textbox" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>

RenaissanceGirl
May 7th, 2002, 06:10 PM
By the way, if you want the text to change when the mouse hovers (or in Flash's case: rollOver) over an image, convert the image to a button and change the scripts to this:

on (rollOver) {
_root.stuff = "Whatever your text might be...";
}

I am not Jubba
May 7th, 2002, 09:44 PM
not to confuse you but you only have to name it in the variable area. Giving it an instance name has no effect one way or the other for everything that I have tried....

pezdemon
May 7th, 2002, 11:56 PM
Thanks a lot, i will try that this afternoon when I'm not half asleep and dying from hayfeaver :D

pezdemon
May 8th, 2002, 12:17 AM
I just did it quickly and it works fine, thanks a lot :D

Just one thing; is there any way of making my text box triangular instead of rectangular?

I am not Jubba
May 8th, 2002, 12:26 AM
i Don't think so, but maybe you could modify my Animated Text Tutorial in the Special Effects Actionscript tutorial section of Kirupas site to get a triangular kind of effect....

upuaut8
May 8th, 2002, 12:37 AM
ahhh.. you illiminated half of the dynamicness of my example.. :) .. well whatever works.

I like my method because all your text is set in a single place where it's easy to find and get at.. plus it's only one step away from loading that information from an external source..

however.. for the sake of learning.. it's only important to see how the text box is changed. Thanks for the help Reni. I appreciate it. :)

RenaissanceGirl
May 8th, 2002, 02:00 AM
You're absolutely right upu - I butchered it down to a very simple form so it's easier to follow. Besides - pezdemon can figure it out I'm sure... it's the basic concept I was going for.

Thanks for clarifying the intance name/ variable thing Jubs - I really wasn't sure what that whole thing was, but I put the label on both and it worked and I just left it at that. I'll keep this in mind in the future.

I am not Jubba
May 8th, 2002, 07:41 AM
yeah at first when I convered to MX i was trying to do my own tutorial to make sure everything went off without a hitch, and I accidently kept naming the instance of the Text box and i couldn't get the effect to work. I tried and tried and tried, and then I realized "Hey, theres another box! Why the @#%$ did Macromedia do that?!!!"


[Edited because I can't spell "did" and I didn't want to look stupid. :lol: :) ]

pezdemon
May 8th, 2002, 08:17 AM
Thats what I was doing before :$

I am not Jubba
May 8th, 2002, 08:19 AM
its a common simple mistake. I mean, I didn't even notice the second box on the right until I took a good hard look at the screen.

RenaissanceGirl
May 8th, 2002, 10:09 AM
same here... those crazy Macromedia folks! So the instance textbox really absolutely doesn't do anything at all?

upuaut8
May 8th, 2002, 11:57 PM
heheh.. now I know what you're all talking about. I didn't at first because I only had it for 30 days and it's been a month since I have looked at it.. but yeah I made that mistake a couple of times while I was using it too.

pezdemon
May 9th, 2002, 06:15 AM
From what I've seen, when you name it, and then go to actions, it says something something something for NAME (action asigned)... or something along those lines, i think its just for naming purposes, but then they could just use the Var name for that... silly people... unless of course... you gave them all different names and actions, but they all had the same Var name, that way the text would display the same but it would have unique actions... I dont know really, I dont know enough about the way it works to say anything yet :D

upuaut8
May 9th, 2002, 06:27 AM
oh.. I can tell you WHY it does that. That's not too hard to figure out.. especially since we can now see that they've added instance naming for buttons. This is what I'm assuming.

All objects, including text fields are now able to be manipulated with action script (in a variety of new ways too), so the var name is what the text block is equal too, but the instance name is what you use to call to it for say _visible=false; actions and such.

makes perfect sense to me :)