Change the extends Sprite to UIComponent
"Merrill, Jason" <[EMAIL PROTECTED]> escribió:
I'm trying to do a primarily Actionscript 3 written Flex app writing
within the Flex framework.
Following Moock's Actionscript 3.0: The Essential Guide examples, I have
set up a simple 3 file project, all files in the same folder. The app
attempts to draw a circle on the stage. See code and errors below:
//Application MXML file
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" applicationComplete="EntryClass.main()">
</mx:Application>
//EntryClass.as file
package
{
import mx.controls.Button;
import mx.core.Application;
public class EntryClass
{
public static function main():void
{
var testSprite:TestSprite = new TestSprite(12,
100, 100);
var mxmlApp:Application =
Application(Application.application);
mxmlApp.addChild(testSprite);
}
}
}
//TestSprite.as file
package
{
import flash.display.Sprite;
class TestSprite extends Sprite
{
private var _x:int;
private var _y:int;
private var _radii:int
public function TestSprite(size:int, posx:int, posy:int)
{
x = posx;
y = posy;
_radii = size;
graphics.lineStyle(1, 0xFFCC33);
graphics.beginFill(0xCC3300, 1);
graphics.drawCircle(0, 0, _radii);
graphics.endFill();
}
}
}
Before compiling, I get this error:
1084: class 'TestSprite' will be scoped to the default namespace:
internal. It will not be visible outside of this package.
After compiling, the debugger gives this error:
TypeError: Error #1034: Type Coercion failed: cannot convert
::[EMAIL PROTECTED] to mx.core.IUIComponent.
at
mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi
ld()
What's happening here? Is there a better way to set this up? Thanks.
Jason Merrill
Bank of America
GT&O Learning & Leadership Development
eTools & Multimedia Team
---------------------------------
¡Sé un mejor asador!
Aprende todo sobre asados en:
http://mx.yahoo.com/promos/mejorasador.html