Skip to main content
Inspiring
September 17, 2008
Question

Error: Type was not found or was not a compile-time constant

  • September 17, 2008
  • 7 replies
  • 1867 views
This is my first time using flex. I tried compiling the scripts below using

mxmlc example.mxml

And I get:

Error: Type was not found or was not a compile-time constant: UIMovieClip

This is on a windows machine. If I type just "mxmlc" I get that I'm using version 3.1. Some please help?
This topic has been closed for replies.

7 replies

MrCactu5Author
Inspiring
September 19, 2008
In the long run the example I want to write is not so elementary. I want to write an interface to a simple game - the example I have is Domineering http://www.boardgamegeek.com/game/7450. I need to draw the pieces drawing the board (on something like a canvas) and drawing the pieces on the board in various configurations. Flash seemed like a good candidate to make a lightweight web interface.

Also check out Eidogo which uses flash but not necessarily flex. http://eidogo.com/#gnugo

Ideally I would like to connect this thing to a server so two players can play remotely but first things first.
Inspiring
September 19, 2008
Well, you know how to draw now! :-)
When the time comes we can advise you on a socket or multiplayer server...
MrCactu5Author
Inspiring
September 19, 2008
so THAT's what it's supposed to look like...
Participating Frequently
September 19, 2008
HA! I hope you're being sarcastic, because that's really funny. Seriously.

Anywho, before we get off topic again and answer questions that may be irrelevant...what is it you're really trying to do. Use a UIMovieClip or draw something in Flex?

Inspiring
September 19, 2008
So, no apologies to the OP then! :-)
Remains the thing that the example using the UIMovieClip doesn't compile on his machine using mxmlc with the SDK 3... but I guess his original question is answered.
Participating Frequently
September 18, 2008
LuigiL,

If you installed the componet kit in Flex, maybe you could check the Properties->Flex Build Path to see if they class paths have been added?

In any case, this may be getting off topic as maybe UIMovieClip is not needed.

When I type mx. and check the auto-complete options i don't see mx.flash. I don't have the integration ket installed.
Inspiring
September 18, 2008
I think a swc gets added to the lib, it doesn't show in the build path. Anyway, if you don't get any code hinting, the package must be added when you install the kit. You don't have it? Pointer (free of charge): get it :-)
Apologies to the OP: I was convinced the package was standard!
Participating Frequently
September 18, 2008
I just tried it at work. I do get the code hinting for the mx.flash package. After reading more, the Flex Component Kit for Flash CS3 was a patch to FlexBuilder 2.0.1. It is standard now in FlexBuilder 3.0.: http://labs.adobe.com/wiki/index.php/Flex_Component_Kit_for_Flash_CS3.

I have the old version of FlexBuilder at home and the new version at work which is why I saw a difference.


Inspiring
September 18, 2008
Couldn't find any clear indication in the doc's that the mx.flash package gets added with the component kit.
Anyway, for the OP attached code should compile.
Participating Frequently
September 18, 2008
I usually just wrap non IUIComponents in a UIComponent in order to attach using addChild(). I thought using UIMovieClip wouldn't compile because it requires more class dependencies than are provided in the default project set up (similar to when you want to use flash components in Flex). That is what I thought this line meant in the instructions from the link:
6. Include the SWC file in your library-path when you compile your Flex application.

LuigiL, perhaps you already have the class dependencies specified which is why it compiles for you?

In any case, I think using a UIComponent would be easier in this case.

var spriteHolder:UIComponent = new UIComponent();
addChild(spriteHolder);
spriteHolder.addChild(someSpriteYouCreated);

I thought UIMovieClip was part of the "create Flex components in Flash" workflow.
Inspiring
September 18, 2008
When using the Flex Component Kit For Flash, the component you create needs to extend UIMovieclip. That dependency is added locally in the Flash IDE by the FlexComponentBase component. To actually use the component, you publish a swc and add that to your library in FB.

>>LuigiL, perhaps you already have the class dependencies specified which is why it compiles for you?
Seems like the only possible solution, that the Flex Component Kit For Flash adds the mx.flash package that contains UIMovieClip
MrCactu5Author
Inspiring
September 18, 2008
OK. So Luigi's last example works for me where you draw directly onto the graphics object of the Canvas. However, my experience with the Shape class is not so clear cut. Here is an example (without importing) where the shape - a circle - does not render:
Inspiring
September 18, 2008
No, because that generates the same type coercion error to UIComponent (if you use the debugger version of the Flash Player you can see what is happening).

See attached code.
Inspiring
September 18, 2008
More specifically:
if you use myCanvas.addChild(child) (or invoke addChild(child) on the main application for that matter) 'child' must implement IUIComponent interface.

Wrapping the Sprite (GraphicsExample.as) in a UIMovieClip resolves that. But why that doesn't compile on your machine... I'm puzzled by that.
Participating Frequently
September 17, 2008
Try following the steps here:
http://livedocs.adobe.com/flex/3/langref/mx/flash/UIMovieClip.html

Using UIMovieClip is a lot more involved than just importing the package (unfortunately).

Are you sure you need a UIMovieClip or would a Sprite do? (It looks like it would according to the code you posted.)
Inspiring
September 18, 2008
jpsoul, UIMovieClip is the 'Flex MovieClip', just a class in the framework.
When using the Flex Component Kit For Flash, the base class in Flash must extend UIMovieclip.

Otherwise, as in the posted example, because you cannot add a Sprite to the Application directly (results in a type coercion error to UIComponent) you can use the UIMovieClip to wrap the - in this example - Sprite, and add it to the Application.

Since the original post by the OP showed that he wanted to use the GraphicsExample.as which is a Sprite, I suggested to wrap it in a UIMovieClip. And it compiles fine on my machine, using mxmlc. Thing is that it doesn't compile on the machine of the OP.

Of course there would be other ways to draw something, but I'm just following the example the OP posted using GraphicsExample.as. Why it doesn't compile on his machine, puzzles me at this time.
Inspiring
September 18, 2008
So, if you simply want to compile something to test, try the attached code that simply draws something using the graphics object of a Canvas.