Probably really dumb question here: I was setting the width/height of a
SpriteVisualElement and was not seeing the change reflected visually. I
made a quick test file (code below) to isolate this from the rest of the
app I am developing. Same thing - when the 'testSprite' receives a mouse
event, it increments it's width/height but there is no change in the visual
display.

I took the same code into Flash CS4 - changed "SpriteVisualElement" to
"Sprite" and it worked as expected - the width/height of 'testSprite' and
it's child increased by 5 px each click.

So I'm baffled. The 'container' var below is a Spark 'Group' container.
What am I missing?

thanks/r

public var testSprite:SpriteVisualElement

protected function creationCompleteHandler(event:FlexEvent):void
{
        testSprite = new SpriteVisualElement();

        var childSprite:SpriteVisualElement = new SpriteVisualElement();
        childSprite.graphics.beginFill(0xFFFF00, 1);
        childSprite.graphics.drawRect(0, 0, 200, 100);
        childSprite.graphics.endFill();
        childSprite.name = "child";

        testSprite.addChild(childSprite);

        container.addElement(testSprite);
        testSprite.addEventListener(MouseEvent.CLICK, grow);
}

public function grow(event:MouseEvent):void
{
        event.target.width += 5;
        event.target.height += 5;
        trace("grow",  event.target.width);
}
-- 
-----------------------------------------------------------------
http://www.roypardi.com/



Reply via email to