Flex MXML UIComponent

时间:2011-07-11 05:34:31

标签: flex

我刚刚开始使用flex,我遇到了一些我发现的问题。我开始使用MXML用于状态等,但是当我尝试做一些更新屏幕上显示内容的东西时,它变得很奇怪。它会更新发生的情况,但不会删除前一帧,因此它不会更新所有内容。我猜这是UIComponent的行为,但无论如何都在这周围?以下是我的代码。我正在使用as3isolib进行游戏,我正试图让它在flex中工作。谢谢!

    <mx:Script>

        <![CDATA[
            import as3isolib.display.IsoSprite;
            import as3isolib.display.IsoView;
            import as3isolib.display.primitive.IsoBox;
            import as3isolib.display.scene.IsoGrid;
            import as3isolib.display.scene.IsoScene;
            import as3isolib.geom.IsoMath;
            import as3isolib.geom.Pt;
            import as3isolib.graphics.Stroke;

            import eDpLib.events.ProxyEvent;

            import flash.display.Sprite;
            import flash.events.Event;
            import flash.events.MouseEvent;

            protected var inGame:Boolean = false;
            private var grid:IsoGrid;
            private var scene:IsoScene;
            private var box:IsoBox;

            private static const CELL_SIZE:Number = 50;

            public function creationComplete():void 
            {
            }

            public function enterFrame(event:Event):void    
            {
                if(inGame)
                {
                    grid = new IsoGrid();
                    grid.addEventListener(MouseEvent.CLICK, gridClick);
                    grid.setGridSize(10,10,1);
                    grid.showOrigin = false;
                    grid.cellSize = CELL_SIZE;

                    box = new IsoBox();
                    box.setSize(CELL_SIZE, CELL_SIZE, CELL_SIZE);
                    box.moveTo(CELL_SIZE, CELL_SIZE, 0);

                    scene = new IsoScene();
                    scene.hostContainer = isoHostContainer;
                    scene.addChild(grid);
                    scene.addChild(box);
                    scene.render();
                }
            }
            private function gridClick(event:ProxyEvent)
            {
                var me:MouseEvent = MouseEvent(event.targetEvent);
                var p:Pt = new Pt(me.localX, me.localY);
                IsoMath.screenToIso(p);
                box.moveTo(Math.floor(p.x/CELL_SIZE)*CELL_SIZE, Math.floor(p.y/CELL_SIZE)*CELL_SIZE, 0);
                scene.render();
            }
            protected function startGameClicked(event:Event):void   
            {
                currentState = "Game"   
            }
            protected function enterGame(event:Event):void  
            {
                //              GameObjectManager.Instance.startup();
                inGame = true;  
            }
            protected function exitGame(event:Event):void   
            {
                inGame = false; 
            }       
        ]]> 
    </mx:Script>

    <mx:Panel width="100%" height="100%" layout="absolute" verticalCenter="0" horizontalCenter="0">

        <mx:UIComponent id="isoHostContainer" verticalCenter="0" horizontalCenter="0" mask="{maskContainer}"/>
        <mx:Container id="maskContainer" width="100%" height="100%" backgroundColor="red"/>

    </mx:Panel>
</mx:Application>

0 个答案:

没有答案