Thursday, December 01, 2005

Flash's ComboBox Component

The ComboBox component in Flash does not behave as expected if used in a movieclip loaded by loadMovie or attachMovie. What happens is that the ComboBox won't open, as if it doesn't react to events. The problem has been discussed, and I managed to find the following suggestions:
  1. Drag an instance of the component onto the stage of the movieclip that's loading the movieclip containing the ComboBox. It can then be deleted, the point is that the loading movieclip has the component in its library. This appeared to solve the problem for a lot of people.
  2. Use loadMovieNum instead of loadMovie
  3. Attach the ComboBox with ActionScript instead of placing it in a movieclip
  4. Randomly rename the combo, movieclip, file etc until it mysteriously starts to work (worked for one guy, though may not be the most robust solution)
I tried all of these without luck, the damned ComboBox wouldn't open. In the end, I noticed by coincidence that the Combo did in fact open, just that the drop-down dropped down behind anything else on the stage. Thus, if I had no background images or other assets on stage, the ComboBox worked as expected. This wasn't an acceptable solution, and I ended up placing the whole Combo-scenario on its own frame on the main timeline, thus avoiding the loadMovie-problem - fortunately the nature of the application made that a possible solution.

From what I understand though, this is a bug in the ComboBox/loadMovie-features, and it puzzles me that Macromedia didn't fix it in the newly released Flash 8. From the newsgroups it seems that the problem has been around for a while, and in the cases that it doesn't work placing the Combo in the library of the main clip, there seems to be no workarounds. I don't know what I would have done if I hadn't been able to place it on a frame on the main timeline.

29 Comments:

At 8:09 pm, Anonymous Anonymous said...

Have you tried swapDepts()?

It changes the stacking order of swf's and MovieClips

with combobox inside a movieclip call :
myComboMovieclip.swapDepths(myMovieClip)

If your referencing a movieclip on a different level, just add level to the path. feks

swap the depth of a movielip inside a loaded movie with a movieclip on the main timeline like this:

myMovieClip.swapDepths(_level0.anotherMovieClip)



if your swapping on the same level you can use a number as an argument.


myMoviClip.swapDepths(666)

 
At 4:23 pm, Blogger ballerina said...

I actually don't remember if I tried swapDepths, but it probably would have worked if I had placed the combo in a movieclip of its own.

Thanks for the tip! :-)

 
At 3:47 pm, Anonymous Anonymous said...

Just an FYI - if you use this._lockroot = true; in the movieclip you are loading,the combobox works fine. Or alternatively, if you are usinf a loader component you could use my_ldr.content._lockroot = true; where my_ldr is the name you've given to your loader component.

 
At 9:02 pm, Anonymous Anonymous said...

Lockroot worked like a charm. thanks!

 
At 9:11 pm, Blogger chregan said...

Thank you so much for this post, lock root sorted out my problem!

 
At 3:26 pm, Anonymous Anonymous said...

the lockroot does the trick. huh. thanks a lot for that, it was really bugging me.

 
At 6:34 pm, Anonymous Anonymous said...

This is a common issue when you have a parent .swf that loads children .swf files that contain one of the following components Alert, ComboBox, DateField, Menu, MenuBar, or Window.

In cases where this scenario occurs, I have found that it is best to declare a global variable, such as _global.TrueRoot, in the parent .swf that refers to the root. For example if I have a parent that loads in children that have _lockroot = true I might declare _global.TrueRoot = _root in the first frame of the parent and then use _global.TrueRoot in the children when they need to interact with the _root (parent) movieclip.

 
At 5:19 pm, Anonymous Anonymous said...

Thank you! very helpful

 
At 10:51 am, Blogger Ragnar said...

I attached this code to the MC into which the comboBox is loaded:

onClipEvent (load) {
this._lockroot = true;
}

works for me.

 
At 11:00 am, Anonymous Anonymous said...

this._lockroot = true; works perfectly

 
At 2:22 pm, Anonymous Anonymous said...

I spent 3 hours to find solution for similar problem.

lockroot is fine.

Thanks!

 
At 2:22 pm, Anonymous Anonymous said...

I spent 3 hours to find solution for similar problem.

lockroot is fine.

Thanks!

 
At 10:02 pm, Anonymous Anonymous said...

Hi folks, my name is Herbert I'm from Nicaragua (22 years old), I once had that same problem with the combobox component, but I discovered a way to fix it.

Here's the link to the solution (at the botton of the webpage, you can also get the this webpage from Flash Help pane):

http://livedocs.adobe.com/flash/9.0/main/00002626.html

If it help anyone, please send me a comment to: herbertrobb@yahoo.com

Greetings. :)

 
At 10:55 pm, Anonymous Anonymous said...

In my flash file I used a lot of actionscript for multilingual stuff and the regular lockroot stuff didn't work as expected. My solution was to add the following code directly to the ComboBox

onClipEvent (load) {this._lockroot = true;}

 
At 10:16 pm, Blogger nexthor said...

Your're the best! lockroot works very good for me!!! thankx!!!!

 
At 12:36 pm, Blogger Eliram said...

Thank you for the _lockroot tip.

 
At 1:48 pm, Blogger papashivo said...

Muah!!!!

this._lockroot = true;

Muah!!!

Saved me a headache!!!

 
At 5:38 pm, Blogger bomark said...

I'd like to add my thank you. I spent more than three hours trying to find what the problem was with a popup form that had a combobox. My textboxes worked fine but comboboxes did nothing.
I added
this._lockroot = true;
to the first frame of my Movieclip and voila! It all worked.

 
At 10:25 pm, Blogger Yalçın Yavaş said...

thank you for your posts. lockroot work fine

 
At 3:58 pm, Blogger Yalçın Yavaş said...

lockroot solves some problem of combobox. I can't select item when i use scrollbar.

i solved problem :)

i put combobox component to out of scene where i use loadmovie.

 
At 7:50 am, Anonymous Anonymous said...

After 3h working in this problem I finally found this post. LOCKROOT just solved the problem. Thank you!!!!!!!

 
At 9:28 pm, Anonymous Junior Passarelli Antunes said...

Laila, Thank you very, very much!!!

I was going crazy with that!!!

Put a instance in the main movie solve the trouble...

Now my hair it´s safe...

Hugs from Brazil!!!

 
At 6:51 pm, Anonymous NCard said...

"At 3:47 PM, Anonymous said...
Just an FYI - if you use this._lockroot = true; in the movieclip you are loading,the combobox works fine. Or alternatively, if you are usinf a loader component you could use my_ldr.content._lockroot = true; where my_ldr is the name you've given to your loader component."

THIS SOLVED THE ISSUE. Thanks a lot!

 
At 4:37 pm, Anonymous Anonymous said...

lockroot on combobox worked great for me. Dumb Flash

 
At 6:55 pm, Blogger Nick Portokallidis said...

Thank you ,works like a charm ,
just use [instance name you will put the content].lockroot=true;

 
At 4:13 pm, Blogger yuvutu said...

Forget all that. I suggest you use a a VPN service with an (Anonymous Proxy)

 
At 11:57 pm, Blogger Enrique Colasurdo said...

Great! This post always saves my life

THANKS!

 
At 2:09 pm, Anonymous Anonymous said...

Solved my problem.... thanks a lot!

 
At 8:22 am, Anonymous Anonymous said...

Indeed. Using the Loadername._lockroot = true works. I put it on frame one of the main movie where I load in the external movie. The combobox works now.

 

Post a Comment

<< Home

En blogg kan være et godt verktøy for en som i litt for stor grad glemmer de små og store tingene som utgjør livet. Dette er min reserve- hukommelse.