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


Reply via email to