[flexcoders] Re: [flexcomponents] simple renderer please help..........please review it
yes got that ! Thanks ! On Feb 18, 2008 12:31 PM, Alex Harui [EMAIL PROTECTED] wrote: Sorry, don't have time to look it up right now, but you're probabl missing implements IListItemRenderer -- *From:* [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] *On Behalf Of *learner *Sent:* Sunday, February 17, 2008 10:22 PM *To:* [EMAIL PROTECTED] *Cc:* flexcoders@yahoogroups.com *Subject:* Re: [flexcomponents] simple renderer please help..please review it Can you please also give me the link to the this template in doc?? When I changed the code and made my itemrender to extend UIcomponent... its giving me error as : Type Coercion failed: cannot convert ms.messengermodule::[EMAIL PROTECTED] to mx.controls.listClasses.IListItemRenderer. Thanks Ps On Feb 16, 2008 12:11 AM, Alex Harui [EMAIL PROTECTED] wrote: Not bad for a first try. I would: 1) extend UIComponent instead of Canvas. You aren't using any of Canvas's features so you'll save on size and performance 2) only call invalidateProperties() in the data setter. Move the code in there to commitProperties instead. That'll probably remove the need for the try/catch block. The way it is coded now, you'll get exceptions if the data setter is run before child objects have been set up in createChildren 3) Move the positioning of your components to updateDisplayList(). 4) Calculate measuredWidth/Height in measure(), but you shouldn't set x,y there as you may not actually be sized to your measured size and in general, you'll probably want to react to that in updateDisplayList(). The measure method should compute measuredWidth/Height from the getExplicitOrMeasuredWidth/Height of the child components plus any spacing and gap styles or properties. 5) not bother to set the avatarholder's imagesource in measure(). If these are external images, they won't be measureable in measure() because loading external images is asynchronous. I don't see any particular reason for why your images end up on the wrong row. Maybe there's some problem with AvatarHolder? *The 'template' for this is in our docs. I'm sure our doc team would love to know why the docs weren't clear enough for you.* -Alex -- *From:* [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] *On Behalf Of *learner *Sent:* Friday, February 15, 2008 12:52 AM *To:* flexcoders@yahoogroups.com; [EMAIL PROTECTED] *Subject:* [flexcomponents] simple renderer please help..please review it Hi all, I am doing my constant effort to learn and make a decent item renderer for a list .. I have also attached a code that i have written for it... please please have a look at it and tell me where i am doing wrong and loopholes are... the problem that i am facing is ; in my image holder the images are not shown properly ... meaning sometimes the image from the different row gets displayed in the other row.. I guessed that there is a way in which u can cache the bitmap in image holder and things like that.. don't know in details ... can any body please suggest me the proper way to design a renderer for this.. please review the following code... (Would be a great help if any body can design this properly for me...i know its too much too ask.. but that will give me guideline and a sort of template . And I once for all ,will get the authentic way to make renderer...till this time .. for me its just blind chess which has really exhausted me ) Thanks my item rendere contains : 1) image.. 2) a text comming next to image 3) a text comming below the text in 2) (Code file is attached) package ms.messengermodule { import mx.containers.Canvas; import mx.controls.Image; import mx.controls.Label; public class ContactBox extends Canvas { /*private var memberStatus:Label;*/ [Embed(source='style.swf', symbol='memberOnline')] private var onlineIcon:Class; [Embed(source='style.swf', symbol='memberOffline')] private var offlineIcon:Class; [Embed(source='ms/felix/css /assets/felixStyle.swf', symbol='memberBusy')] private var busyIcon:Class; [Embed(source='style.swf', symbol='organizer')] private var organizerIcon:Class; private var memberName:Label; private var memberDescription1:Label; private var memberDescription2:Label; private var memberDescription3:Label; private var avatarHolder:ImageHolder; private var description1:String; private var description2:String; private var description3:String; private var contactObject:ContactObject; private var statusImage:Image; private var statusIcon:Object; private var memberNamestr:String; private var userImage:String; /** * Constructor */
[flexcoders] Re: [flexcomponents] simple renderer please help..........please review it
thanks a ton Alex.. I don't see anything wrong with my avatarHolder's code.. still pasting the code here. Please see the code of my avatarHolder ..i think your thoughtful eyes can catch a loophole... I am just want my code to be seen by the experience ppl here.. as i don't have anything to validate it. so please help me out.. -- package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.events.IOErrorEvent; import flash.net.URLRequest; import ms.imfusion.util.MsLogger; import mx.core.BitmapAsset; import mx.core.Container; import mx.core.UIComponent; import mx.states.RemoveChild; public class ImageHolder extends Container { private var loader:Loader; private var myBitmap:Bitmap; private var imageSrc:String; private var imageSprite:Sprite; private var request:URLRequest; private var uiComp:UIComponent function ImageHolder(){ super(); setStyle(borderColor,#989898); setStyle(borderStyle,solid); setStyle(borderAlpha,0); setStyle(cornerRadius,3); setStyle(dropShadowEnabled,true); createControls() } [Bindable] public function set imageSource(img:String):void{ try{ imageSrc = img; imageSprite = new Sprite(); //trace(before loading an image imageSrc : + imageSrc); request = new URLRequest(imageSrc); loader.contentLoaderInfo.addEventListener( Event.COMPLETE, completeHandler); loader.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR,function (){ MsLogger.getInstance().Log(this,URL not found); }) loader.load(request); //trace(after loading an image imageSrc: + imageSrc); imageSprite.visible = false; imageSprite.addChild(loader); } catch(e:Error){ MsLogger.getInstance().Log(this,e.message,unable to load image); } } public function unloadImage(){ //removeChild(uiComp) loader.unload(); } private function createControls():void{ imageSprite = new Sprite(); loader = new Loader(); } private function completeHandler(event:Event){ try{ //trace(completeHandler an image imageSrc : + imageSrc); var loader:Loader = Loader(event.target.loader); var myBitmapData:BitmapData = Bitmap(loader.content ).bitmapData var myBitmapDataAsset:BitmapAsset = new BitmapAsset(myBitmapData); imageSprite.addChild(myBitmapDataAsset); uiComp = new UIComponent(); imageSprite.visible= true; uiComp.addChild(imageSprite) addChild(uiComp); this.visible = true; } catch(e:Error){ //trace(in completeHandler unable to load image); MsLogger.getInstance().Log(this,e.message,in completeHandler unable to load image); } } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{ super.updateDisplayList(unscaledWidth,unscaledHeight); if(uiComp!=null){ uiComp.x = (this.unscaledWidth - imageSprite.width )/2; uiComp.y = (this.unscaledHeight - imageSprite.height )/2; } } } } -- I will incorporate all your suggestion... and let me read the doc again... Thanks a ton.. I really appreciate your interest in solving our queries.. that helps a lot to dumbs like me... PS. On Feb 16, 2008 12:11 AM, Alex Harui [EMAIL PROTECTED] wrote: Not bad for a first try. I would: 1) extend UIComponent instead of Canvas. You aren't using any of Canvas's features so you'll save on size and performance 2) only call invalidateProperties() in the data setter. Move the code in there to commitProperties instead. That'll probably remove the need for the try/catch block. The way it is coded now, you'll get exceptions if the data setter is run before child objects have been set up in createChildren 3) Move the positioning of your components to updateDisplayList(). 4) Calculate measuredWidth/Height in measure(), but you shouldn't set x,y there as you may not actually be sized to your
[flexcoders] Re: [flexcomponents] simple renderer please help..........please review it
Can you please also give me the link to the this template in doc?? Thanks Ps On Feb 16, 2008 12:11 AM, Alex Harui [EMAIL PROTECTED] wrote: Not bad for a first try. I would: 1) extend UIComponent instead of Canvas. You aren't using any of Canvas's features so you'll save on size and performance 2) only call invalidateProperties() in the data setter. Move the code in there to commitProperties instead. That'll probably remove the need for the try/catch block. The way it is coded now, you'll get exceptions if the data setter is run before child objects have been set up in createChildren 3) Move the positioning of your components to updateDisplayList(). 4) Calculate measuredWidth/Height in measure(), but you shouldn't set x,y there as you may not actually be sized to your measured size and in general, you'll probably want to react to that in updateDisplayList(). The measure method should compute measuredWidth/Height from the getExplicitOrMeasuredWidth/Height of the child components plus any spacing and gap styles or properties. 5) not bother to set the avatarholder's imagesource in measure(). If these are external images, they won't be measureable in measure() because loading external images is asynchronous. I don't see any particular reason for why your images end up on the wrong row. Maybe there's some problem with AvatarHolder? *The 'template' for this is in our docs. I'm sure our doc team would love to know why the docs weren't clear enough for you.* -Alex -- *From:* [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] *On Behalf Of *learner *Sent:* Friday, February 15, 2008 12:52 AM *To:* flexcoders@yahoogroups.com; [EMAIL PROTECTED] *Subject:* [flexcomponents] simple renderer please help..please review it Hi all, I am doing my constant effort to learn and make a decent item renderer for a list .. I have also attached a code that i have written for it... please please have a look at it and tell me where i am doing wrong and loopholes are... the problem that i am facing is ; in my image holder the images are not shown properly ... meaning sometimes the image from the different row gets displayed in the other row.. I guessed that there is a way in which u can cache the bitmap in image holder and things like that.. don't know in details ... can any body please suggest me the proper way to design a renderer for this.. please review the following code... (Would be a great help if any body can design this properly for me...i know its too much too ask.. but that will give me guideline and a sort of template . And I once for all ,will get the authentic way to make renderer...till this time .. for me its just blind chess which has really exhausted me ) Thanks my item rendere contains : 1) image.. 2) a text comming next to image 3) a text comming below the text in 2) (Code file is attached) package ms.messengermodule { import mx.containers.Canvas; import mx.controls.Image; import mx.controls.Label; public class ContactBox extends Canvas { /*private var memberStatus:Label;*/ [Embed(source='style.swf', symbol='memberOnline')] private var onlineIcon:Class; [Embed(source='style.swf', symbol='memberOffline')] private var offlineIcon:Class; [Embed(source='ms/felix/css /assets/felixStyle.swf', symbol='memberBusy')] private var busyIcon:Class; [Embed(source='style.swf', symbol='organizer')] private var organizerIcon:Class; private var memberName:Label; private var memberDescription1:Label; private var memberDescription2:Label; private var memberDescription3:Label; private var avatarHolder:ImageHolder; private var description1:String; private var description2:String; private var description3:String; private var contactObject:ContactObject; private var statusImage:Image; private var statusIcon:Object; private var memberNamestr:String; private var userImage:String; /** * Constructor */ function ContactBox() { super(); this.horizontalScrollPolicy = off; this.verticalScrollPolicy = off; } override public function set data(value:Object):void { try{ super.data = value; contactObject = value as ContactObject; description1 = contactObject.extensionObject[E]; // take the value from some dictinory object memberNamestr = contactObject.name.split( )[0]; userImage = contactObject.imageUrl; // user image statusIcon = ; getStatusIcon(); invalidateProperties(); } catch(e:Error){
[flexcoders] Re: [flexcomponents] simple renderer please help..........please review it
Can you please also give me the link to the this template in doc?? When I changed the code and made my itemrender to extend UIcomponent... its giving me error as : Type Coercion failed: cannot convert ms.messengermodule::[EMAIL PROTECTED] to mx.controls.listClasses.IListItemRenderer. Thanks Ps On Feb 16, 2008 12:11 AM, Alex Harui [EMAIL PROTECTED] wrote: Not bad for a first try. I would: 1) extend UIComponent instead of Canvas. You aren't using any of Canvas's features so you'll save on size and performance 2) only call invalidateProperties() in the data setter. Move the code in there to commitProperties instead. That'll probably remove the need for the try/catch block. The way it is coded now, you'll get exceptions if the data setter is run before child objects have been set up in createChildren 3) Move the positioning of your components to updateDisplayList(). 4) Calculate measuredWidth/Height in measure(), but you shouldn't set x,y there as you may not actually be sized to your measured size and in general, you'll probably want to react to that in updateDisplayList(). The measure method should compute measuredWidth/Height from the getExplicitOrMeasuredWidth/Height of the child components plus any spacing and gap styles or properties. 5) not bother to set the avatarholder's imagesource in measure(). If these are external images, they won't be measureable in measure() because loading external images is asynchronous. I don't see any particular reason for why your images end up on the wrong row. Maybe there's some problem with AvatarHolder? *The 'template' for this is in our docs. I'm sure our doc team would love to know why the docs weren't clear enough for you.* -Alex -- *From:* [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] *On Behalf Of *learner *Sent:* Friday, February 15, 2008 12:52 AM *To:* flexcoders@yahoogroups.com; [EMAIL PROTECTED] *Subject:* [flexcomponents] simple renderer please help..please review it Hi all, I am doing my constant effort to learn and make a decent item renderer for a list .. I have also attached a code that i have written for it... please please have a look at it and tell me where i am doing wrong and loopholes are... the problem that i am facing is ; in my image holder the images are not shown properly ... meaning sometimes the image from the different row gets displayed in the other row.. I guessed that there is a way in which u can cache the bitmap in image holder and things like that.. don't know in details ... can any body please suggest me the proper way to design a renderer for this.. please review the following code... (Would be a great help if any body can design this properly for me...i know its too much too ask.. but that will give me guideline and a sort of template . And I once for all ,will get the authentic way to make renderer...till this time .. for me its just blind chess which has really exhausted me ) Thanks my item rendere contains : 1) image.. 2) a text comming next to image 3) a text comming below the text in 2) (Code file is attached) package ms.messengermodule { import mx.containers.Canvas; import mx.controls.Image; import mx.controls.Label; public class ContactBox extends Canvas { /*private var memberStatus:Label;*/ [Embed(source='style.swf', symbol='memberOnline')] private var onlineIcon:Class; [Embed(source='style.swf', symbol='memberOffline')] private var offlineIcon:Class; [Embed(source='ms/felix/css /assets/felixStyle.swf', symbol='memberBusy')] private var busyIcon:Class; [Embed(source='style.swf', symbol='organizer')] private var organizerIcon:Class; private var memberName:Label; private var memberDescription1:Label; private var memberDescription2:Label; private var memberDescription3:Label; private var avatarHolder:ImageHolder; private var description1:String; private var description2:String; private var description3:String; private var contactObject:ContactObject; private var statusImage:Image; private var statusIcon:Object; private var memberNamestr:String; private var userImage:String; /** * Constructor */ function ContactBox() { super(); this.horizontalScrollPolicy = off; this.verticalScrollPolicy = off; } override public function set data(value:Object):void { try{ super.data = value; contactObject = value as ContactObject; description1 =
[flexcoders] RE: [flexcomponents] simple renderer please help..........please review it
Sorry, don't have time to look it up right now, but you're probabl missing implements IListItemRenderer From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of learner Sent: Sunday, February 17, 2008 10:22 PM To: [EMAIL PROTECTED] Cc: flexcoders@yahoogroups.com Subject: Re: [flexcomponents] simple renderer please help..please review it Can you please also give me the link to the this template in doc?? When I changed the code and made my itemrender to extend UIcomponent... its giving me error as : Type Coercion failed: cannot convert ms.messengermodule::[EMAIL PROTECTED] to mx.controls.listClasses.IListItemRenderer. Thanks Ps On Feb 16, 2008 12:11 AM, Alex Harui [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Not bad for a first try. I would: 1) extend UIComponent instead of Canvas. You aren't using any of Canvas's features so you'll save on size and performance 2) only call invalidateProperties() in the data setter. Move the code in there to commitProperties instead. That'll probably remove the need for the try/catch block. The way it is coded now, you'll get exceptions if the data setter is run before child objects have been set up in createChildren 3) Move the positioning of your components to updateDisplayList(). 4) Calculate measuredWidth/Height in measure(), but you shouldn't set x,y there as you may not actually be sized to your measured size and in general, you'll probably want to react to that in updateDisplayList(). The measure method should compute measuredWidth/Height from the getExplicitOrMeasuredWidth/Height of the child components plus any spacing and gap styles or properties. 5) not bother to set the avatarholder's imagesource in measure(). If these are external images, they won't be measureable in measure() because loading external images is asynchronous. I don't see any particular reason for why your images end up on the wrong row. Maybe there's some problem with AvatarHolder? The 'template' for this is in our docs. I'm sure our doc team would love to know why the docs weren't clear enough for you. -Alex From: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] ] On Behalf Of learner Sent: Friday, February 15, 2008 12:52 AM To: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com ; [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Subject: [flexcomponents] simple renderer please help..please review it Hi all, I am doing my constant effort to learn and make a decent item renderer for a list .. I have also attached a code that i have written for it... please please have a look at it and tell me where i am doing wrong and loopholes are... the problem that i am facing is ; in my image holder the images are not shown properly ... meaning sometimes the image from the different row gets displayed in the other row.. I guessed that there is a way in which u can cache the bitmap in image holder and things like that.. don't know in details ... can any body please suggest me the proper way to design a renderer for this.. please review the following code... (Would be a great help if any body can design this properly for me...i know its too much too ask.. but that will give me guideline and a sort of template . And I once for all ,will get the authentic way to make renderer...till this time .. for me its just blind chess which has really exhausted me ) Thanks my item rendere contains : 1) image.. 2) a text comming next to image 3) a text comming below the text in 2) (Code file is attached) package ms.messengermodule { import mx.containers.Canvas; import mx.controls.Image; import mx.controls.Label; public class ContactBox extends Canvas { /*private var memberStatus:Label;*/ [Embed(source='style.swf', symbol='memberOnline')] private var onlineIcon:Class;
[flexcoders] RE: [flexcomponents] simple renderer please help..........please review it
Not bad for a first try. I would: 1) extend UIComponent instead of Canvas. You aren't using any of Canvas's features so you'll save on size and performance 2) only call invalidateProperties() in the data setter. Move the code in there to commitProperties instead. That'll probably remove the need for the try/catch block. The way it is coded now, you'll get exceptions if the data setter is run before child objects have been set up in createChildren 3) Move the positioning of your components to updateDisplayList(). 4) Calculate measuredWidth/Height in measure(), but you shouldn't set x,y there as you may not actually be sized to your measured size and in general, you'll probably want to react to that in updateDisplayList(). The measure method should compute measuredWidth/Height from the getExplicitOrMeasuredWidth/Height of the child components plus any spacing and gap styles or properties. 5) not bother to set the avatarholder's imagesource in measure(). If these are external images, they won't be measureable in measure() because loading external images is asynchronous. I don't see any particular reason for why your images end up on the wrong row. Maybe there's some problem with AvatarHolder? The 'template' for this is in our docs. I'm sure our doc team would love to know why the docs weren't clear enough for you. -Alex From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of learner Sent: Friday, February 15, 2008 12:52 AM To: flexcoders@yahoogroups.com; [EMAIL PROTECTED] Subject: [flexcomponents] simple renderer please help..please review it Hi all, I am doing my constant effort to learn and make a decent item renderer for a list .. I have also attached a code that i have written for it... please please have a look at it and tell me where i am doing wrong and loopholes are... the problem that i am facing is ; in my image holder the images are not shown properly ... meaning sometimes the image from the different row gets displayed in the other row.. I guessed that there is a way in which u can cache the bitmap in image holder and things like that.. don't know in details ... can any body please suggest me the proper way to design a renderer for this.. please review the following code... (Would be a great help if any body can design this properly for me...i know its too much too ask.. but that will give me guideline and a sort of template . And I once for all ,will get the authentic way to make renderer...till this time .. for me its just blind chess which has really exhausted me ) Thanks my item rendere contains : 1) image.. 2) a text comming next to image 3) a text comming below the text in 2) (Code file is attached) package ms.messengermodule { import mx.containers.Canvas; import mx.controls.Image; import mx.controls.Label; public class ContactBox extends Canvas { /*private var memberStatus:Label;*/ [Embed(source='style.swf', symbol='memberOnline')] private var onlineIcon:Class; [Embed(source='style.swf', symbol='memberOffline')] private var offlineIcon:Class; [Embed(source='ms/felix/css /assets/felixStyle.swf', symbol='memberBusy')] private var busyIcon:Class; [Embed(source='style.swf', symbol='organizer')] private var organizerIcon:Class; private var memberName:Label; private var memberDescription1:Label; private var memberDescription2:Label; private var memberDescription3:Label; private var avatarHolder:ImageHolder; private var description1:String; private var description2:String; private var description3:String; private var contactObject:ContactObject; private var statusImage:Image; private var statusIcon:Object; private var memberNamestr:String; private var userImage:String; /** * Constructor */ function ContactBox() { super(); this.horizontalScrollPolicy = off; this.verticalScrollPolicy = off; } override public function set data(value:Object):void { try{ super.data = value; contactObject = value as ContactObject; description1 = contactObject.extensionObject[E]; // take the value from some dictinory object memberNamestr = contactObject.name.split( )[0]; userImage = contactObject.imageUrl; // user image statusIcon = ; getStatusIcon(); invalidateProperties(); } catch(e:Error){ trace(e.message); } } private function getStatusIcon():void {