Hi,

You could..

var wrapper:IUIComponent = new UIComponent();
wrapper.addChild(contentBg);

panelOne.addChild(wrapper);

This makes it harder to ref and size.

You should look into skin subclasses like ProgrammaticSkin.

If you make a class that subclasses ProgrammaticSkin, then you can use the graphics of that class and override updateDisplayList() (do your drawing there).

Then when you create your skin, it will be added to the canvas no problem.

You will also then have access to move() and setActualSize() of the skin that is drawing your graphics. Calling setActualSize() will then call your overriden updateDisplayList() method which will size you graphics rendering correctly.

Peace, Mike

On 8/11/06, soso noso <[EMAIL PROTECTED]> wrote:

Hi all -
I've been doing due diligence to find an answer to this, as in I didn't come here first, but I'm not getting exactly how to apply visual coding to the mxml area.

For a quick example - I have a simple mxml file:

<?xml version="1.0" encoding="utf-8"?>
<customState:StateDev
        xmlns:mx=" http://www.adobe.com/2006/mxml"
        xmlns:customStates="dev.state.*"
        width="300"
        height="100%"
        creationComplete="drawContentArea();">

    <mx:Panel id="panelOne" layout="absolute" width="100%" height="100%" title="My Panel" x="0" y="0"/>

</customState:StateDev>

easy enough. this can run fine alone but I just want to dynamically draw something on the stage.

so I figured I could attached a sprite and use the drawing api. like so:

package dev.state
{
    import mx.containers.Canvas;
    import flash.display.Sprite;

   
    public class StateDev extends Canvas
    {
        public var contentBg:Sprite;
        public var panelOne:Panel;

       
        public function StateDev()
        {
            super();

        }
       
        public function drawContentArea ():void
        {
            contentBg = new Sprite();
            contentBg.graphics.beginFill(0xFF0000);
            contentBg.graphics.drawRoundRect(0, 0, 150, 400, 10, 10);
            contentBg.graphics.endFill();
            panelOne.addChild(contentBg);
        }
    }
}


obviously this isn't working. I get the errorr "TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent."

can someone clue me in? or just point me in the direction of where maybe I can find the answer online since my searching and reading hasn't seemed to solve it.


Thanks -
cb


Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail Beta.




--
What goes up, does come down. __._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to