Tracy beat me to it... but I'm going to send my email as well :). This is because your code isn't in an event handler. In MXML you can't have "free-floating" script, just like in an ActionScript 3 class, you can't have circle.graphics.beginFill(0x990000) outside of a method. I recommend doing the following:
Change your mx:Application tag to read as this: <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onReady()"> Then: <mx:Script> <![CDATA[ import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; private function onReady():void { var circle:Sprite = new Sprite(); circle.graphics.beginFill(0x990000); circle.graphics.drawCircle(50, 50, 50); circle.graphics.endFill(); addChild(circle); } ]]> </mx:Script> On Sun, Apr 5, 2009 at 1:38 PM, brad.bueche <[email protected]> wrote: > I'm at a loss here. I copied this code straight off the adobe site: > > > http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_29.html > > And copied it write into a new mxml project (below) and Flex is throwing > 1120 erorrs saying "circle is undefined". How can that be? > > ****************************************************************** > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute"> > <mx:Script> > <![CDATA[ > import flash.display.Sprite; > import flash.events.Event; > import flash.events.MouseEvent; > > var circle:Sprite = new Sprite(); > circle.graphics.beginFill(0x990000); > circle.graphics.drawCircle(50, 50, 50); > circle.graphics.endFill(); > addChild(circle); > > function fadeCircle(event:Event):void{ > circle.alpha -= .05; > > if (circle.alpha <= 0){ > circle.removeEventListener(Event.ENTER_FRAME, fadeCircle); > } > } > > function startAnimation(event:MouseEvent):void{ > circle.addEventListener(Event.ENTER_FRAME, fadeCircle); > } > > circle.addEventListener(MouseEvent.CLICK, startAnimation); > > ]]> > </mx:Script> > > </mx:Application> > > > -- Cheers, Nate ---------------------------------------- http://blog.natebeck.net

