Your suggestion worked fine, thanks. I double checked my version and there are no errors. Here is my version which has AnimatedBall , an extention of sprite being used as a child of the Application, but has no errors, with the source code, if anyone's interested http://www.geotonics.com/examples/Animation/Animation.html.
Alex Harui wrote: > > I’m surprised there is no error (I didn’t try it though). Sprites > can’t be children of Applications. The rules in Flex are: > > Navigator children must be Containers > > Container children must be IUIComponents > > UIComponent children can be anything. > > There are also component lifecycle behaviors you have to know about to > be a good flex component, such as which methods to override when, and > that you are sized by your parent. > > When you compile AnimatedBall as its own project, you get a small swf > with the Ball as the main class at a default size of 500x375. > > When you make it a child of Application, you should normally get an > error, but if you subclass UIComponent you’ll get further, but you’ll > also need to specify a size for it. > > So, change “extends Sprite” to “extends UIComponent” and size the tag > something like <com:AnimatedBall width=”100%” height=”100%”> > > ------------------------------------------------------------------------ > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] > *On Behalf Of [EMAIL PROTECTED] > *Sent:* Saturday, September 29, 2007 5:50 PM > *To:* flexcoders@yahoogroups.com > *Subject:* Re: [flexcoders] actionscript class in Flex project > > I made a mistake in the last post (I didn't intend to call init() in the > application tag) > corrected version : > > I have an action script file of an animated ball. 20 is added to x on > every frame. If I create an actionscript project and run it, it works > fine. Now how do I include this class in a flex project ? > > If I create a mxml file like this I thought it would have the ball in > it. It runs, but there is not ball, no errors no nothing. The code for > the ball is below > > <?xml version="1.0" encoding="utf- > > 8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml > <http://www.adobe.com/2006/mxml> > <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml>>" > layout="absolute" xmlns:com="com.*"> > <mx:Script> > <![CDATA[ > import com.AnimatedBall; > ]]> > </mx:Script> > <com:AnimatedBall /> > > </mx:Application> > > package com { > import flash.display.Sprite; > import flash.events.Event; > > public class AnimatedBall extends Sprite { > private var ball:Sprite; > > public function AnimatedBall() { > init(); > } > private function init():void { > ball = new Sprite(); > addChild(ball); > ball.graphics.beginFill(0xff0000); > ball.graphics.drawCircle(0, 0, 40); > ball.x = 20; > > ball.addEventListener(Event.ENTER_FRAME, > onEnterFrame); > } > private function onEnterFrame(event:Event):void { > ball.x++; > } > } > } > > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/