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...










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

2009-11-24 Thread Amy


--- In flexcoders@yahoogroups.com, Thomas Silvester thomas_...@... wrote:

 How can i do that ? any sample code .

In the Help files, there's something like creating a style property, which 
will give you the outlines of what you need to do.

HTH;

Amy



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...

  



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

2009-11-21 Thread Amy


--- In flexcoders@yahoogroups.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...



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

2009-11-20 Thread mitchgrrt
3. Width and height are properties of Image, not styles, so setStyle()
won't work.

--- In flexcoders@yahoogroups.com, Chris zomgfore...@... wrote:

 I am assuming that your list control has a set width and height. If
you have
 variableRowHeight=true, or you want a variable row height, then this
answer
 probably isn't what you are after.

 1. Currently you are using Image as a base class. The way item
renderers
 work, the width, height, and background can be controlled by the item
 renderer's parent. I think you would want to wrap your Image within a
 canvas, so that the image's dimensions won't be controlled by the
parent,
 and can instead be set by you. The parent of the renderer will set the
 width/height of the canvas, and you can set the image width/height.

 2. I don't know what a PopupMenu is. Is that the dropdown that is
created by
 a ComboBox?


 On Fri, Nov 20, 2009 at 8:42 AM, Thomas Silvester thomas_...@...wrote:

 
 
  Hi All,
  I have 2 questions?
  1.I would like to chnage the width and height of an image using an
Imagae
  renderer, how do i do that?
  2. Can I chnage the widht or height of a POPUPMenu using the same
style  as
  below uing a renderer.
 
  Any information regarding this is appreciated.
  Thanks in Advance,
  Anitha.
 
  I tried this, but it did not chnage the width or height of the
image..
 
  *
 
  package
  *
 
  {
 
  *import* mx.controls.*;
 
  *public* *class* ImageRenderer *extends* Image
 
  {
 
 
 
  *private* *var* slaimage:Image;
 
   *public* *function* ImageRenderer()
 
  {
 
  *super*();
 
  }
 
  *override* *public* *function* *set* data(value:Object) :*void*
 
  {
 
  *if*(value != *null*)
 
  {
 
  *super*.data = value;
 
  slaimage=
  *new* Image();
 
  slaimage.source=value.CurrentSLA;
 
  slaimage.setStyle(
  *width*,15);
 
  slaimage.setStyle(*height*
  ,15);
 
   }
 
  }