View Full Version : Help with Combo Box Component
boycetown
10-27-2006, 06:33 PM
So its my first time using the cool Combo Box that you can throw onto the stage. I have added my values into it to create a drop down list. Now I need to direct those values to a particular frame in a movie clip (let's call it "shirt_color_mc") that has been placed on the stage. I have other buttons on the stage that are doing the same thing. This is the basic actionscript I am using for the buttons that loads a particular frame in that movie clip:
on (release) {
shirt_color_mc.gotoAndStop("babyblue");
}
The question: How do I provide the same actionscripting for those values so that when selected from the drop down menu, it will load a particular frame in that movie clip? I am working on this as we speak so I may be able to figure it out but any help would be greatly appreciated. I'll be checking this regularly. Thanks.
mcmcom
10-27-2006, 06:37 PM
the comboBox should have an event named something like:
onSelectedIndexChange or onSelectedItem.
you can see all the events in the actionscript pane or the object browser
on that event you provide logic to determine what frame to play at:
something like:
myCombo.onSelectedIndexChange = function(){
if(myCombo.selectedIndex == 1){
//if its one goto and play frame one
myClip.gotoAndPlay(1);
}
if(myCombo.selectedIndex == 2){
//if its item two goto and play frame 5
myClip.gotoAndPlay(5);
}
} //..etc
you should look at the available properties and methods for the combobox as it tells you all the events you can utilize.
hth,
mcm
boycetown
10-27-2006, 06:55 PM
thanks mcmcom for the reply. i've been exploring the object inspector for the combo box but i'm still having issues. keep in mind i'm not an expert in flash. i noticed the "Schema" section in the inspector and noticed the selecteditem:object and selectedindex:number properties located in there. However, I don't know what to do with these. I went ahead and proceeded to just use the actionscripting you provided (of course modifying the names of the movie clip and combo box to what I have set them to) and it still doesn't work. It loads up errors. Can you just throw in an explanation how to go about this in as much detail as you can? Thanks, I'm still working away seeing if I can discover something new to figure it out. Appreciate it.
boycetown
10-27-2006, 07:46 PM
I just don't really understand the different Schema events and how I would use them. I've tried changing the field names and values. Its all frustrating because it seems like a simply thing but real tricky to figure it out. All i want is that a selected item from the drop down to load a frame in a movie clip that has been placed on stage.
loach
10-27-2006, 07:52 PM
You can set up an event listener to do this as well.Try this on your first frame.
stop();
var list:Object = new Object();
list.change = function() {
if (myCombo.selectedIndex == 0) {
myClip.gotoAndStop(2);
}
if (myCombo.selectedIndex == 1) {
myClip.gotoAndStop(3);
}
};
_root.myCombo.addEventListener("change", list);
You must have two values in your combo box like Blue,Green or whatever.Anyways just try that.And your combo box must have an instance name of myCombo or change it to reflect the name of your combobox
boycetown
10-27-2006, 08:15 PM
hey Loach,
so honestly, i'm quite lost in this all. the script you gave me, should i only use that? what i did was start with a clean slate combo box, added my values for the drop down, added the proper instance names to make it work with your script, and applied the actionscript you had provided onto the combo box. i am still gettin errors. In your actionscripting, are the index values that you start with (0,1,etc.) automatically applied sequentially to the combo box values? When I view the flash movie there are no drop downs appearing in the drop down combo box.
loach
10-27-2006, 08:28 PM
The actionscript should go on Frame one or whatever frame you need your combobox on it should not go on the combobox itself.I've included an .fla so you can see this more indepth. Only thing is change the gotoandplay(1) to your movie clip. I just used frames. The selected index is done automatically the first value in your combo is 0, the second value is 1,etc.It is just like an array it starts at 0.
boycetown
10-27-2006, 08:33 PM
Thanks a ton Loach! I didn't need to use the zip file you sent me, that was good enough. I got it to work, but I guess I just want to really learn flash and don't understand how to write the scripting you provided. Is this something that I just need to learn on my own and study in depth or is it a basic thing that I can just learn pretty quickly? Thanks a ton and your response would be greatly appreciated.
loach
10-27-2006, 08:51 PM
Well Really all you can do is buy books, and browse the forums. Yeah pretty much you have to learn on your own. At least I have. I've been doing AS for a little over a year now, and have learned everything I know by books and this forum. Also check out Lynda.com. They have online training videos you can watch for like $25.00 a month on alot more than flash(photoshop,dreamweaver,etc). But AS3 is due out next year sometime so it'll be time to start learning all over again. I'm not sure I'll upgrade right away though I'm still have trouble with AS2 most of the time.
Cheers
boycetown
10-27-2006, 08:58 PM
any good recommendations on Actionscripting or flash books? Ones that will give you the basic run down on how to structure and code actionscripting? As I mentioned, I know the basics, placement of objects in the timeline, basic actionscript functions like timeline controls, etc. if you see my website you'll gain an idea. I'd like to ideally learn how to structure everythin as you have come to understanding through you scripting and write script on the fly and learn the job of functions such as this jumble that you sent me:
var list:Object = new Object();
list.change = function() {
The words are there to hint out things but parentheses and periods and all the structuring and Actionscript words to place in there are all unknown to me. Let me know if you have any good recommendations. Thanks again Loach for all the help, its truly appreciated. If anyone has any recommendations it would be greatly apprecaited.
loach
10-27-2006, 09:13 PM
I'm a big fan of Friends of Ed books. I would start with Foundation Actionscript for flash 8, and then move to Object Oriented Actionscript with flash 8, Then Actionscript Animation Making Things Move. These are in my opinion really excellent books on actionscript. Also a must once you get the "Hang of stuff" is Essential Actionscript 2.0 (orielly). And last but not least search the forums in and out. I have found alot of gems on these forums. If you find one you like subscribe to it to come back later for reference. I looked at your site. It is nice certainly alot more than I do with actionscript/flash. I'm more into the web applications/web services type of development, but it looks like from your site that you know flash pretty darn good. So buy a couple of the books and shoot you'll be a guru in no time.
Cheers
Loach
Mazoonist
10-28-2006, 12:36 AM
I second the motion on that book loach recommended. I have it and it's one of the best you can buy. I even wrote a review of it on Amazon. I'm talking about Foundation Actionscript for Flash 8.
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.