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++; } } }