3

I am trying to build an MXML application with Flash Builder 4.5, and I am integrating an API that requires the root of a display object to be a MovieClip. Personally I think this is bad design but I have to go with it. The root object always seems to end up as the stage, because of course I have to add the object to the stage for it to be added to the display list. Is there some way that I can either change the stage type in an MXML application to a MovieClip or is there some way to force a MovieClip wrapper to become the root of a display object?

Matt Esch
  • 22,661
  • 8
  • 53
  • 51
  • AFAIK, Flex application is already a movie clip. The first frame is the preloader part, the second frame is the application itself. – Hrundik Jun 26 '11 at 19:45
  • maybe you are looking for FlexGlobals.topLevelApplication – Yordan Yanakiev Jun 26 '11 at 20:28
  • @Hrundik I think that if you export an application from flash for flex it is wrapped in something called a UIMovieClip. @Yordan Yanakiev could you elaborate on this? I believe what I need to do is set an application container that is of type MovieClip but I am unsure of how to do this. – Matt Esch Jun 26 '11 at 20:55
  • @me232 then I don't get you. Do you want to load movie clips into your flex application, or do you want to load your flex application to some other place that expects MovieClip? – Hrundik Jun 27 '11 at 12:14
  • @Flextras.com The root of the .swf generated by mxmlc for your application is a generated class which extends SystemManager. And SystemManager is inherited from MovieClip. So, you can load your flex application using loader:Loader, you can cast loader.content as MovieClip safely. – Hrundik Jun 27 '11 at 12:17
  • How about you tell us why you need the root to be a MovieClip? Ever thought of just having the loaded SWF just be self contained within the loader? – J_A_X Jun 28 '11 at 14:24
  • I am working with an API and it looks to be badly coded. It provides you with a movie clip that is used by the API, but it also makes reference to its root display object, which it expects to be a movieclip itself. I have found that I can get this to work by wrapping the API movieclip in a UIComponent and adding to the application via `FlexGlobals.topLevelApplicaton.addElement` – Matt Esch Jul 01 '11 at 13:31

1 Answers1

0

Both mx Application and Spark Application inherit from Sprite, not MovieClip. Take a look at the inheritance chain at the top of

mx Application docs

Spark Application docs

The third-party API can't cast your Flex movie to MovieClip, because it's not one.

HTH;

aMY

Community
  • 1
  • 1
Amy Blankenship
  • 6,485
  • 2
  • 22
  • 45