0
votes

I wrote a big Actionscript project using AS3 as an "Actionscript Project" in Flash Builder 4.5. I have a bunch of solid, reusable, code, but one of the big components is a main.as file that extends Sprite and serves as the display code for my application.

I now, for various reasons, need that to be a Flex application. I'm trying to get the most minimal wrapper possible, so here's what I have (thanks to the internet):

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
           xmlns:s="library://ns.adobe.com/flex/spark"
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="590" minHeight="700"
           initialize="initPlayer()">`

<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.core.UIComponent;
        public function initPlayer():void {
            Alert.show("Testing!");
            var comp:UIComponent = new UIComponent();
            comp.addChild(new MainView());
            addChild(comp);
        }
    ]]>
</fx:Script>
</s:Application>

when I launch this, however, it comes up with a blank window. No errors, the alert doesn't fire, nothing. Any idea what's going on?

2

2 Answers

0
votes

Try using applicationComplete instead of initialize. initialize is triggered early in the application life cycle, and stuff like doing addChild is better suited later on in the cycle (applicationComplete corresponds to creationComplete in sub components).

0
votes

I use a simple sprite class "TestSprite" instead your "MainView". It works. Both the alert ahd the TestSprite works. so, i think there must be something in your "MainView" prevent flex display it.

public class TestSprite extends Sprite
{
    public function TestSprite()
    {
        super();
        graphics.beginFill(0x000000);
        graphics.drawRect(0, 0, 100, 100);
        graphics.endFill();
    }
}