Thanks - got the first error fixed, but the second one remains. If I cast testSprite as DisplayObject, I still see this error: Main Thread (Suspended: TypeError: Error #1034: Type Coercion failed: cannot convert [EMAIL PROTECTED] to mx.core.IUIComponent.) mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi ld mx.core::Container/addChildAt mx.core::Container/addChild ..etc.
Jason Merrill Bank of America GT&O Learning & Leadership Development eTools & Multimedia Team ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Mathews Sent: Wednesday, September 19, 2007 11:22 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Actionscript sprite within the Flex framework The first error says you need the TestSprite class to be defined like: public class TestSprite extends Sprite The second error I initially thought was because the application addChild takes a UICompoent, but according to the help docs what you have 'should' work. I would try casting it as a DisplayObject although this probably isn't the correct way to fix it. mxmlApp.addChild(testSprite as DisplayObject); Steve On 9/19/07, Merrill, Jason <[EMAIL PROTECTED] <mailto:jason.merrill%40bankofamerica.com> > wrote: > 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 <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 <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 > > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com <http://www.mail-archive.com/flexcoders%40yahoogroups.com> > Yahoo! Groups Links > > > >