Hello,

When I try to draw a circle on the screen by calling a script that's in the 
mxml, it works 
fine:

<mx:Button label="Button" click="createSprite1();" right="10" top="10"/>
and
public function createSprite1():void
{       
        var visual:Visual = new Visual();
        var ref:UIComponent = new UIComponent();
        addChild(ref);
        ref.addChild(visual);
        trace('called from mxml');
}

But if I try to call it from a class, it is called (I can tell because of the 
trace output) but it 
doesn't draw the circle on the screen.

Here's my rough code that doesn't work so far:

<mx:Button label="Button" click="createSprite2();" right="10" top="40"/>
public function createSprite2():void
{       
        var main:Main = new Main();   
        main.createSprite();    
}

And then my Main.as file just has the same code:

public function createSprite() : void
{
        var visual:Visual = new Visual();
        var ref:UIComponent = new UIComponent();
        addChild(ref);
        ref.addChild(visual);
        trace('called from Main.as');
}

As I said, I know this class is being called because I can see the trace 
output.  Any 
suggestions why this isn't working for me?

Thanks for any help,
Jon


Reply via email to