all groups > flash actionscript > june 2005 >
You're in the

flash actionscript

group:

comboBox behaving badly


comboBox behaving badly paulpsd7
6/30/2005 11:37:08 PM
flash actionscript: I've got a combo box in a SWF which is loaded into another one. First of all,
to get this to work, I tracked down
http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=194&thre
adid=789423&highlight_key=y&keyword1=combo%20box0.

So now the combo box opens just fine.

My trouble is due to the fact that I've set the combo box to only open to show
4 items, however it actually contains 10 items. Since the combo box comes with
a scrollbar, this shouldn't be a problem either. If I have Item 1 selected, and
I want to select Item 10, I can click on the combo box, scroll down to Item 10,
click on it, and voia, it should be selected.

It isn't working that way. What happens is that after I click on the scrollbar
and drag down to Item 10, when I release my mouse, the combobox closes again
before allowing me to select the item. This happens when you select up as well.
Essentially, after it opens, the combo box allows me one more mouse click
before it closes again. If I fritter away that mouse click on scrolling instead
of selecting, then I'm out of luck.

Any way around this?
Re: comboBox behaving badly paulpsd7
6/30/2005 11:38:44 PM
Re: comboBox behaving badly paulpsd7
7/6/2005 9:04:51 PM
Okay, I think my description was a bit hard to visualize. So I've posted this
online.

http://www.psd7.com/temp/abbott

If you click on anything under #1 or #2 in the top nav, you'll see actual
content. In this content, I've got a scrolling combo box under the heading
VISUAL SELECTOR.

Try and select Figure 10 (or anything higher than Figure 3) and you'll see
what I mean.

Also, when I click on the combo box, I get a green outline around the box's
borders. Any chance I can get rid of that? I've applied the following code to
my combo box in the hopes it would eliminate it:

image_cb._focusrect = false;

...but it didn't make any difference.
Re: comboBox behaving badly paulpsd7
7/18/2005 7:11:08 PM
Okay, this problem seems to have everyone stumped. I'm wondering if that's
because no one else is experiencing the problem. Can someone please go to the
staging version of this project, and let me know if you're experiencing the
same problem?
http://www.psd7.com/temp/abbott/

Click on Chapter 1 or 2. When the content appears, try out the combo box under
the heading VISUAL SELECTOR. Let me know if you're able to go straight from,
say, image 1 to image 10, requiring that you both scroll down the combo box and
then select an item. If I could determine whether other people are experiencing
this, it would help tremendously in my attempts to resolve it. Thanks!
Re: comboBox behaving badly myIP
7/18/2005 8:56:48 PM
Yeah, the ComboBox seems a little funky. I can scroll down the list and click
on the tenth item with my mouse wheel. However when I use my mouse button and
release off of the ComboBox?s scrollbar handle, the list rolls back up
instantly leaving behind a green outline of the list. Without looking at your
code it seems like you have two events contradicting each other.
Re: comboBox behaving badly paulpsd7
7/18/2005 10:07:03 PM
Thanks for checking it out for me.

While it does seem like I have 2 events conflicting with each other, fact is I
haven't modified a single line of the code that comes with that combo box. It's
all completely standard.

Of course, I also have a scrollbar instance on the main stage, attached to the
dynamic text field. Do you think the combo box and the text scrollbar could be
interfering with each other? Of course, I haven't changed a line of code
regarding the scrollbar either.

Regarding the combo box, I just gave it an instance name and populated it,
like this:

// This was a line required to get the combo box to run in the first place.
Dunno what it means.
image_cb._lockroot = true;

// This is my attempt to get rid of that green outline
image_cb._focusrect = false;

// This populates the combo box with data and labels
image_cb.addItem({data:1, label:"select"})
image_cb.addItem({data:2, label:"Figure 1"})
image_cb.addItem({data:3, label:"Figure 2"})
image_cb.addItem({data:4, label:"Figure 3"})
image_cb.addItem({data:5, label:"Figure 4"})
image_cb.addItem({data:6, label:"Figure 5"})
image_cb.addItem({data:7, label:"Figure 6"})
image_cb.addItem({data:8, label:"Figure 7"})
image_cb.addItem({data:9, label:"Figure 8"})
image_cb.addItem({data:10, label:"Figure 9"})
image_cb.addItem({data:11, label:"Figure 10"})
image_cb.addItem({data:12, label:"Figure 11"})
image_cb.addItem({data:13, label:"Figure 12"})
image_cb.addItem({data:14, label:"Figure 13"})
image_cb.addItem({data:15, label:"Figure 14"})
image_cb.addItem({data:16, label:"Figure 15"})
image_cb.addItem({data:17, label:"Figure 16"})
image_cb.addItem({data:18, label:"Figure 17"})
image_cb.addItem({data:19, label:"Figure 18"})
image_cb.addItem({data:20, label:"Figure 19"})
image_cb.addItem({data:21, label:"Figure 20"})
image_cb.addItem({data:22, label:"Figure 21"})
image_cb.addItem({data:23, label:"Figure 22"})

// This function happens when the user changes the combo box value
function change(evt){
showImage (image_cb.selectedIndex + 1);
trace(evt.target.selectedItem.label);
}

// Here is the listener for the combo box
image_cb.addEventListener("change", this);

// Here is the function which is called when the combo box value changes
_global.showImage = function(frame) {
images.gotoAndStop (frame);
image_cb.selectedIndex = (frame -1);
}

Any ideas?
Re: comboBox behaving badly myIP
7/19/2005 12:00:00 AM
I was going to suggest that you lockroot the comboBox but, you have already
done so. What this does from what I understand prevents conflicts between two
timelines of a movieClip or even another SWF. So that brings up my next
question. Is this comboBox in another SWF being loaded into your main SWF? If
so use the lockroot again, but just locking the SWF?s timeline. Put;

this._lockroot = true;

in the timeline. I hope this helps.

Re: comboBox behaving badly paulpsd7
7/25/2005 12:00:00 AM
Okay, I think we're onto something here. I've got both a scrollbar and a combo
box on the main timeline. Since the combo box also contains another instance of
the same scrollbar, this could be where the conflict is occuring.

Now when you say "Put; this._lockroot = true; in the timeline," which timeline
do you mean? I don't how to access the timelines within the actual components,
so instead I put this._lockroot = true in the Movie Clip's timeline. That
didn't make any difference.
Re: comboBox behaving badly paulpsd7
7/25/2005 12:00:00 AM
One more thing which I didn't mention before. Both the combo box and the
scrollbar are not actually on the _root timeline, but rather are on a separate
SWF which loads onto the main timeline in a movie clip called contentMC.
Perhaps that makes a difference?
Re: comboBox behaving badly paulpsd7
7/25/2005 5:55:03 PM
Okay, this problem has been solved. It was caused by a conflict arising from
the fact that the combo box is not on the _root timeline, but is in a separate
SWF that was loaded into an MC on the _root timeline. To get around this
problem, I added this line of code to the timeline that contains the combo box:

[code]this._lockroot = true;[/code]

Now everything works. For a short time, as I mentioned above, I had this code
in the MovieClip's timeline. That didn't work and actually spit back an error.
Re: comboBox behaving badly myIP
7/25/2005 5:57:54 PM
Perhaps that makes a difference?

Yes, I think that?s your problem. Yes, I believe putting _lockroot in your
main SWF?s timeline is not going to make a difference. What you need to do is
put that in the incoming SWF?s timeline. You mentioned that you don?t have
access to it, correct? If so, if you search livedocs under _lockroot it tells
you how to lockroot an incoming SWF from the main SWF. It?s the very last
example that they list on how using lockroot, which is right below;

this.createEmptyMovieClip("nolockroot_mc", this.getNextHighestDepth());
nolockroot_mc._lockroot = true;
nolockroot_mc.loadMovie("nolockroot.swf");

I would just delete your contentMC on stage, use the code above in your main
Timeline, change ?nolockroot_mc? to contentMC and change the SWF to the
incoming one that you have.

Re: comboBox behaving badly paulpsd7
7/25/2005 6:03:40 PM
Oops. I spoke too soon.

While the combo box works fine when I test movie, when I look at it in a
browser it still has the same problem. I've tried deleting my cache, and using
different browsers, but still the problem persists.

Is there something more I need to do in order to have lockroot take effect
when the SWF appears in a browser?
Re: comboBox behaving badly myIP
7/25/2005 8:37:27 PM
So the SWF works fine alone but, when it is in a browser it gets funkified? If
that is the case then the _lockroot did its job, however now there is another
problem. Try what this thread recommends. The fourth post down, ?Try loading
your movie into a new level?.

http://www.actionscript.org/forums/showthread.php3?t=44860
Re: comboBox behaving badly paulpsd7
7/25/2005 10:40:20 PM
Great recommendation, and it worked perfectly.

Only trouble is, I purposely didn't load the SWF into a level, and loaded it
into a MC instead, because the content needs to appear above of the background
but beneath the top navigation. See, when you roll over the top nav, you get a
dropdown menu that appears. When I load the content into a _level, this
dropdown menu is under that content.

I know I could extract out the top navigation and load that into a higher
level. However, short of that, which would entail a fair amount of reworking,
can you think of any other way I could achieve this same result?

Thanks so much for your help on this.
Re: comboBox behaving badly myIP
7/25/2005 11:24:57 PM
I am not exactly sure what you are asking, but it sounds like you may want to
use the _visible property. You can have your contentMC invisble above or under
your Nav bar or vise versa. When the user rolls over the corresponding
category have the dropdown menu or Nav bar become visible.
Re: comboBox behaving badly paulpsd7
7/25/2005 11:33:25 PM
Sometimes a picture is worth a thousand words. http://www.psd7.com/temp/abbott/
Click any chapter heading (or subnav) to load content. Then after the content
is loaded, try rolling over the top navigation again. The subnav is now behind
the content. This is because the top navigation is on _level0, and the content
is on _level23.

Using _visible seems like it would just make the content appear or disappear,
rather than allow parts of it to show through.

I could always move the top navigation to another level, say at _level24.
However, this would entail a lot of reprogramming, so I'm looking for an
alternative.
Re: comboBox behaving badly myIP
7/26/2005 12:00:00 AM
Alright, the code I recommend to you from the livedocs needs to be modified.
Change the ? this.getNextHighestDepth() ? parameter to ? -16384?. This will
put the contentMC on top of the Nav bar.

-16384 is reserved of dynamic content, such as using loadMovie( ). The Nav
bar has a depth somewhere between -16383 to -1, these depths are reserved for
design-time(author-time). Depths 0 to 1048575 are reserved for dynamically
generated content (attachMovie, duplicateMovie()). Think of depths in Flash as
the third dimension, the Z axis that you don?t really see, it?s the stacking of
movieClips! Depths can override layers in a timeline which will make their
contents irrelevant, in a hierarchical perspective. So see if depth -16384 for
your contentMC works!

Re: comboBox behaving badly myIP
7/26/2005 5:43:52 PM
- 16384 should work unless there is a movieClip behind contentMC that is
covering the stage. The lightBlue color which is below the Nav bar, is that
the stage or a movieClip? If so try working the number up to 0 and see which
movieClips are getting exposed. Or just find out the depth of a movieClip by
putting the following code below, for an example;

trace(?myMC ?+movieClipInstanceName.getDepth());

Re: comboBox behaving badly paulpsd7
7/26/2005 10:05:29 PM
Okay, I got it to work!!

Once I removed contentMC from the stage, and created it dynamically, setting
its depth, that was key. However, having done that, I did have the background
MC to deal with (which fades from light blue to dark blue), since this wanted
to appear on top of the content. The way I got around it is to put this
background in the same SWF as the content.

I have always been confused about depth, wondering how it was different from
the stacking order of the various layers on the stage. While I can't seem to
find a definitive answer in the Actionscript Dictionary, it seems to me that
depth transcends the layer stacking order. In other words, you can take an MC
on the bottom layer on the stage, and set its depth to something high, and it
will appear on top of other MCs that are on higher layers on the stage. Is that
your understanding?

Either way, thank you so much for your help!
Re: comboBox behaving badly myIP
7/27/2005 12:00:00 AM
AddThis Social Bookmark Button