[flexcoders] Setting width/height not affecting visual display?

2010-07-13 Thread Roy Pardi
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(0x00, 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/





Re: [flexcoders] Setting width/height not affecting visual display?

2010-07-13 Thread Oleg Sivokon
These properties may be overridden. My gut feeling says there should be
something like commitProperties / validate or some similar method to apply
all changes to the changed display object.


Re: [flexcoders] Setting width/height not affecting visual display?

2010-07-13 Thread Mayur Bais
Two things

1) Try setting the height and width of the container.

2) I tried to read the adobe docs  and it says The SpriteVisualElement class
is a light-weight Sprite-based implemention of IVisualElement. and there are
no height and width property available for this class.
where are there are only write only protected properties available and that
are viewHeight and viewWidth (Which scales instance of IVisualElement
proportionately.)
You might want to check more in details
http://docs.huihoo.com/flex/4/spark/core/SpriteVisualElement.html



On Tue, Jul 13, 2010 at 6:44 PM, Oleg Sivokon olegsivo...@gmail.com wrote:



 These properties may be overridden. My gut feeling says there should be
 something like commitProperties / validate or some similar method to apply
 all changes to the changed display object.

  



Re: [flexcoders] Setting width/height not affecting visual display?

2010-07-13 Thread Roy Pardi
At 3:14 PM +0200 7/13/10, Oleg Sivokon wrote:
These properties may be overridden. My gut feeling says there should be
something like commitProperties / validate or some similar method to apply
all changes to the changed display object.


Thanks for the reply. Still tinkering here - I changed the type of the
'childSprite' var to be an instance of 'Sprite' - and then it works:
changing the width/height of 'testSprite (SpriteVisualElement) results in
a resizing of its child content.

Guess I am not clear on when to use 'SpriteVisualElement' - I started using
it in place of 'Sprite' because I could not add a Sprite to any of the
Spark containers. Much of my app's content is generated through code.



public var testSprite:SpriteVisualElement

protected function creationCompleteHandler(event:FlexEvent):void
{

testSprite = new SpriteVisualElement();

var childSprite:Sprite = new Sprite();
childSprite.graphics.beginFill(0x00, 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/