Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to navigate with combobox component 1

Status
Not open for further replies.

nejimmy

Technical User
Sep 28, 2004
5
US
I'm using Flash MX 2004 and have brought a combobox to the stage and entered labels but I'm not sure how or if it is possible to navigate to other frames or urls by clicking on on one of the labels (you know like a dropdown menu). I know just enough actionscript to know I don't know near enough~thanks (-:
 
Absolutely!

Personally I would add data entries as well but you don't have to. You have to add a listener for the "change" event of the combobox. Note: the combobox must have an instance name.

On frame 1 of the timeline that contains the combobox.

Code:
myListener = new Object();
myListener.change = function(component) {
	varName = component.target.text;
	if (varName == "myVariable"){
            gotoAndStop(5);
        }
};

instanceNameOfCombo.addEventListener("change", myListener);

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Ok I know I said I was using Flash MX 2004 and I was "at home" here at work I have Flash MX, and numbskull that I am [sadeyes] I put the code into frame 1 on the same timeline as the combo box. I changed the "myVariable" to reflect my label and added a data entry that matched my label, just to make sure. I gave my combobox an instance name of drop1 and changed the code accordingly. I put a stop action on frame 1 and another on frame 5 and put a graphic on 5 to see if it would work. Well obviously I did something wrong or neglected something, like I mentioned before I'm green[alien]. Here's my code after alterations again thanks for the quick response, this is a nice forum

Code:
myListener = new Object();
myListener.change = function(component) {
    varName = component.target.text;
    if (varName == "Google"){
            gotoAndStop(5);
        }
};
drop1.addEventListener("change", myListener);
 
There is a difference between Flash MX and Flash MX 2004 combobox components and the way that you deal with them. The method I provided is for the version 2 (Flash MX 2004) component.

If you can work on it in Flash MX then I assume you are not using the version 2 (flash mx 2004) combobox? You can use the version 1 component in Flash MX 2004 but not reversed.

You may have to do it this way. In the Properties panel of the combobox if you have a "ChangeHandler" input field set it to _global.comboFunction.

Then add the following to the first frame, actions layer of the timeline with the combo.

Code:
//Version 1 combobox function
_global.comboFunction = function(component) {
	varName = component.getValue();
	if (varName == "Google"){
            gotoAndStop(5);
        }
};

BTW... All of the changes that you made to the original code I posted were correct and would work fine with the Version 2 component in Flash MX 2004 (v.2 components require the Flash 7 plugin and Actionscript 2).

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
First off thanks for all the info it has been an education on the differences between Flash MX and Flash MX 2004. My Situation is this I have a Flash MX on a pc at work and Flash MX 2004 on my pc at home. Let me clean the slate and ask only one thing at a time.

In Flash MX, with the combobox component that came with Falsh MX do you know the code for making links to html pages?

This would be a good start for me, I apologize for coming to the table having a poor idea of what I wanted to eat, I'm a slob I'll admit it.

Hey Thanks for all your help, Trying to read through the Flash help stuff is a choreX-)
 
For Flash MX use the last code I posted. Remember you have to set the name of the Change Handler function in the properties for the combobox. If you want it to automatically get a URL(google) you would do this:

Code:
//Version 1 combobox function
_global.comboFunction = function(component) {
    varName = component.getValue();
    if (varName == "Google"){
            getURL("[URL unfurl="true"]http://www.google.com","_blank");[/URL]
        }
};

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
Well maybe it's the lack of sleep, here's a link to the fla file. I couldn't get it to work and I'm sure it's something simple that I simply overlooked or better yet that I just don't know or understand.
My fla file
Thanks again pixl8r for your paitence I appreciate it
I must be slow[snail]
 
Well I'm not sure why but the _global function was not working correctly. Two things I added were "data" and an instance name for your combobox.

Have a look.

Click here

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
So it wasn't me oh rature and joy! Hey thanks Pxl8r I relly appreciate it it's working and I actually understand what's going on in the code! I'm still a little self-conscious about my eye though[3eyes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top