need to access content.width
On Thu, Jun 19, 2008 at 7:07 AM, superbokbok <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm currently working on a custom component constructed with
> actionscript only as an Item Renderer.
>
> It's a simple component at the moment and one of the features I'm trying
> to implement is an auto size feature. Basically, the component takes in
> the data from the dataprovider, checks the width/height and then sets
> the image width/height if the values exceed 90. I've tried accessing a
> variety of properties within the SWFLoader class as well as the Image
> class but none seem to have any effect. I can't seem to resize the
> component through code. Here's what I have at the moment:
>
> import flash.events.Event;
>
> import mx.controls.Image;
> import mx.controls.Label;
> import mx.events.FlexEvent;
>
> public class CustomImage extends Image
> {
> public var textDisplay:Label;
> public var imageDisplay:Image;
>
> public function CustomImage()
> {
> super();
>
> }
>
> override public function set data(value:Object):void
> {
> super.data = value;
> super.invalidateProperties();
>
> if(value)
> super.source = data.image;
> //super.scaleY = 0.1;
> //super.scaleX = 0.1;
> }
>
> override protected function createChildren():void
> {
> super.createChildren();
>
> imageDisplay = new Image();
> imageDisplay.scaleContent = true;
> addChild(imageDisplay);
>
> if(!textDisplay)
> textDisplay = new Label();
> textDisplay.styleName = this;
> addChild(textDisplay);
> textDisplay.text = data.name;
>
> /* listen for the update complete event to know when loading
> is done */
>
> imageDisplay.addEventListener(FlexEvent.UPDATE_COMPLETE,resizeMe);
> }
>
> private function resizeMe(event:Event):void
> {
> if(this.width > 90)
> trace(this.width+'--'+this.height+'super');
> var tempWidth:int = 90;
> var tempHeight:int = 90;
> updateDisplayList(tempWidth,tempHeight);
>
> }
>
> override protected function
> updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void
> {
> super.updateDisplayList(unscaledWidth, unscaledHeight);
>
> }
>
> In the main application I have this for the tileList component:
> <mx:TileList id="friends" height="100%" width="100%"
> maxColumns="7" rowHeight="105" columnWidth="105"
> itemRenderer="com.customComp.CustomImage">
>
> Any help with this would be greatly, greatly appreciated!
> Regards,
> erick
>
>
>