flash (macromedia):
I'm having a lot of newbie troubles with my combobox. I'm trying to use a combobox as a means of navigating to different nested slides. Here's what I want: the user clicks on an item in the combobox, let's say "nebraska," and that action calls forth the nebraska slide. If the user then clicks on "new york," they will have called forth the new york slide. It seems like this should be easy enough, but I haven't found any tutorials that help. Any suggestions or links? Thanks for the help.
What you describe is easy enough but I am curious whether you want to continue to use the built-in navigation features that come with the slide presentation in addition to the combobox or you will disable the keyboard navigation and go with the combobox only. The slide presentation builds a list of all slides in their proper order into an array when the presentation loads and it remembers within its own navigation scheme where it is at any time, where the 'next' slide and 'previous' slides are as well as the first and last slides. If you go jumping around with a combobox, it is not immediately compatible with the slide navigation. Don't be dissuaded by that - you can script around almost anything but it will help to know in advance how you plan to navigate your slides if you want anything in addition to the combobox.
This is quick and dirty. It offers no transitions. It will not prevent you from also using the keyboard navigation but it will not match the keyboard navigation sequence (next and previous) to the combobox selections. It will only target the slides you name in the combobox list. There are other ways but they are more difficult. I don't use this presentation format so don't know very much about it so, if there is a better solution, I apologize in advance. //this script should go in the timeline of the main presentation slide and the combobox should be //placed on that slide as well. You can put it someplace else but would need to adjust //paths accordingly //make a change handler for the combobox jump2slide = new Object(); jump2slide.change = function (evt){ //make the slide just seen invisible if(current_slide <> undefined) { eval("this." + current_slide)._visible = 0; } //make the slide selected in the combobox visible eval("this." + evt.target.selectedItem.data)._visible = 1; //save the name of the slide just selected to be made invisible on next selection current_slide = evt.target.selectedItem.data; } //attach change handler to the combobox mycombobox.addEventListener("change", jump2slide); //populate the combobox with the names of your slides including the full path mycombobox.addItem("my presentation slides","do nothing"); mycombobox.addItem("-----------------------","do nothing"); mycombobox.addItem("my first slide","slide1"); mycombobox.addItem("my second slide","slide2"); mycombobox.addItem("my third slide","slide2/slide3"); //for child slides, be sure to include the full path in the name //make all slides in the mycombobox combobox invisible //this may or may not be necessary but it won't do any harm //you ccould also do this differently by searching for slide objects themselves //but it takes some effort to find child slides so this is just easier for(obj in mycombobox.dropdown.__dataProvider) { if(mycombobox.dropdown.__dataProvider[obj]["data"] <> "do nothing") { eval("this." + mycombobox.dropdown.__dataProvider[obj]["data"])._visible = false; } }
Did I mention I'm a newbie with Flash? I'm getting a lot of errors. I think it's because I'm not using the correct naming for the slides, etc, in this part of the code you gave me: //populate the combobox with the names of your slides including the full path mycombobox.addItem("my presentation slides","do nothing"); mycombobox.addItem("-----------------------","do nothing"); mycombobox.addItem("my first slide","slide1"); mycombobox.addItem("my second slide","slide2"); mycombobox.addItem("my third slide","slide2/slide3"); A few questions: When I have the combobox selected and I'm looking at the parameters for the combobox, I should be seeing data [] editable false labels [Choose a state, Nebraska, New York] row count [3] Is that right? Now, in the script, I should have something like this mycombobox.addItem("Choose a state","do nothing"); mycombobox.addItem("-----------------------","do nothing"); mycombobox.addItem("Nebraska","nebraska"); with "Nebraska" being the title I've given the element in the labels parameter, and "nebraska" being the title I've given the slide in the screens window? Lastly, I should be attaching the script to frame one of the actions layer, no?
You didn't have to mention that you were a newbie. If you were experienced, you would not be using slides to begin with :) Not going necessarily in order: Your conversion from the properties box to the timeline script is about right assuming that the instance name of the combobox is actually 'mycombobox'. I don't think you ever mentioned what the instance name was so I just put something generic. Either name your combobox 'mycombobox' or replace the 'mycombobox' with the actual instance name. In the properties dialog, you have the ability to enter in 'data' and 'label'. That is a horrendously bad way to do it. It is much easier to populate the combobox either with addItem as I wrote or with giving it a 'dataProvider'. No matter which way you choose to do it, the end result is that the combobox is set up with an object array with the objects 'label' and 'data' but that is way more information than any of us really care about so forget I even said it. The reason I prefer not to use the component inspector to enter the information is simply ease of maintenance. Also, it may make it a bit clearer to think of it this way: example: mycombobox.addItem('my first slide','slide1'); this adds 'my first slide' to the label object in the next available slot in the array and adds 'slide1' to its data object exactly the same as if you had entered it in the component inspector. You could also write it this way with exactly the same result: mycombobox.addItem({label:'my first slide',data:'slide1'}); It is not necessary to do that but it may make it read a little more clearly. Just choose whichever syntax you are happier with and stay with it. As far as the slide names, these are the names as they appear in the white box to the left of the stage (don't know what you call that box so I'll stick with the technical naming convention of 'white box'). In the white box, you see thumbnails of all your slides. To the right of each slide is its name. The default names are 'slide1', 'slide2', etc. but if you renamed them, you should use your names for the data item of the combobox. For the slides under the 'main' or 'presentation' slide, you would just use the name of the slide in the combobox data. If a slide has a child slide, you need to add its parent slide to the pathname. Say you have three slides: 'Nebraska', 'Colorado' and 'Arkansas'. mycombobox.addItem('my Arkansas slide','Arkansas');//the label can be anything you want but the data has to be exact mycombobox.addItem('my Colorado slide','Colorado'); mycombobox.addItem('my Nebraska slide','Nebraska'); note: 'exact' means exactly that including proper case of all letters - 'Nebraska' does not equal 'nebraska' in the data item Now let's say that you want a child slide for 'interestingplaces' for each state. Nebraska has a child slide named 'interestingplaces' and so does Colorado. Since they are children of other slides, the parents need to be in the path. mycombobox.addItem('my Arkansas slide','Arkansas'); mycombobox.addItem('my Colorado slide','Colorado'); mycombobox.addItem('Colorado sites of interest','Colorado/interestingplaces');//parent slide included in the path mycombobox.addItem('my Nebraska slide','Nebraska'); mycombobox.addItem('Nebraskasites of interest','Nebraska/interestingplaces'); Don't try to put interesting places for Arkansas because it will returned 'undefined'. Even Flash knows there are no interesting places in Arkansas (I'm from there so I can say that). All that combobox script needs to go in a keyframe on the timeline at the point where the combobox exists. Since you are using the slides format, you should place the combobox on the main presentation screen and the script on the timelime of the main presentation screen. If you get errors, can you mention specifically what errors you are getting?
Don't see what you're looking for? Try a search.
|