Re: [flexcoders] Re: Is thereany way using a Image Renderer ,I can change the widtth or height of an image?

2009-11-24 Thread Thomas Silvester
How can i do that ? any sample code .
thanks,
Anitha.

--- On Sat, 11/21/09, Amy amyblankens...@bellsouth.net wrote:


From: Amy amyblankens...@bellsouth.net
Subject: [flexcoders] Re: Is thereany way using a Image Renderer ,I can change 
the widtth or height of an image?
To: flexcoders@yahoogroups.com
Date: Saturday, November 21, 2009, 7:59 PM


  





--- In flexcod...@yahoogro ups.com, mitchgrrt mitch_gart@ ... wrote:

 3. Width and height are properties of Image, not styles, so setStyle()
 won't work.

You can add code to accept them as styles...








Re: [flexcoders] Re: Is thereany way using a Image Renderer ,I can change the widtth or height of an image?

2009-11-24 Thread Thomas Silvester
Thanks a lot Chris, I made some modification to the code below  you gave and it 
did magic for me.
Thanks again.
Anitha.

--- On Sun, 11/22/09, Chris zomgfore...@gmail.com wrote:


From: Chris zomgfore...@gmail.com
Subject: Re: [flexcoders] Re: Is thereany way using a Image Renderer ,I can 
change the widtth or height of an image?
To: flexcoders@yahoogroups.com
Date: Sunday, November 22, 2009, 11:44 PM


  



Looking deeper into your code I noticed:

That you are creating an Image *inside* an Image. There's no need to create an 
image inside an image, perhaps you should use one of the more generic 
'container' classes inside mx.containers. *. In my example below I chose Canvas.

You are constructing your image control within your setter for your property if 
data is null. Generally, you want to follow the standard practice of creating 
your children in the createChildren( ) method. You'll find that Flex has more 
consistent behavior for your custom controls if you do that.

You need to call addChild() on your newly created child otherwise it won't be 
placed on the stage.


Here is a modified version of your class that may or may not compile. Compiling 
is an exercise to the user. :)

package{

import mx.controls. *;
import mx.core.*;
import mx.containers. Canvas;

public class ImageRenderer extends Canvas implements IDataRenderer
{

    private var slaimage:Image;
    private var _data:Object;
    
    public function ImageRenderer( )
    {
        super();
    }
    
    override public function createChildren( )void
    {
        super.createChildre n();
        slaimage = new Image();
        slaimage.width = 15;
        slaimage.height= 15;
        // optional: vertically and horizontally center your image within the 
canvas.
        slaimage.setStyle(horizontalCenter, 0);
        slaimage.setStyle(verticalCenter, 0);
        addChild(slaimage) ; // -THIS IS IMPORTANT TO DO
        //if data is set before createChildren( ) is called, use it.
        if(_data){
            slaimage.source= value.CurrentSLA ;
        }
    }
    
    override public function set data(value:Object) :void
    {
        _data = value;
        if(slaimage) {
            slaimage.source= value.CurrentSLA ; //only set this if it exists. 
If it doesn't, then its being called before createChildren has been called.
        }
    } 
}


On Sat, Nov 21, 2009 at 7:29 AM, Amy amyblankenship@ bellsouth. net wrote:


  






--- In flexcod...@yahoogro ups.com, mitchgrrt mitch_g...@. .. wrote:

 3. Width and height are properties of Image, not styles, so setStyle()
 won't work.

You can add code to accept them as styles...










Re: [flexcoders] Re: Is thereany way using a Image Renderer ,I can change the widtth or height of an image?

2009-11-22 Thread Chris
Looking deeper into your code I noticed:

That you are creating an Image *inside* an Image. There's no need to create
an image inside an image, perhaps you should use one of the more generic
'container' classes inside mx.containers.*. In my example below I chose
Canvas.

You are constructing your image control within your setter for your property
if data is null. Generally, you want to follow the standard practice of
creating your children in the createChildren() method. You'll find that Flex
has more consistent behavior for your custom controls if you do that.

You need to call addChild() on your newly created child otherwise it won't
be placed on the stage.


Here is a modified version of your class that may or may not compile.
Compiling is an exercise to the user. :)

package{

import mx.controls.*;
import mx.core.*;
import mx.containers.Canvas;

public class ImageRenderer extends Canvas implements IDataRenderer
{

private var slaimage:Image;
private var _data:Object;

public function ImageRenderer()
{
super();
}

override public function createChildren()void
{
super.createChildren();
slaimage = new Image();
slaimage.width = 15;
slaimage.height= 15;
// optional: vertically and horizontally center your image within
the canvas.
slaimage.setStyle(horizontalCenter, 0);
slaimage.setStyle(verticalCenter, 0);
addChild(slaimage); // -THIS IS IMPORTANT TO DO
//if data is set before createChildren() is called, use it.
if(_data){
slaimage.source=value.CurrentSLA;
}
}

override public function set data(value:Object) :void
{
_data = value;
if(slaimage){
slaimage.source=value.CurrentSLA; //only set this if it exists.
If it doesn't, then its being called before createChildren has been called.
}
}
}

On Sat, Nov 21, 2009 at 7:29 AM, Amy amyblankens...@bellsouth.net wrote:





 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
 mitchgrrt mitch_g...@... wrote:
 
  3. Width and height are properties of Image, not styles, so setStyle()
  won't work.

 You can add code to accept them as styles...