Re: [flexcoders] It shouldn't be this hard.
The first thought is: mx:Canvas width=100% height=100% mx:Image source={yourSource} horizontalCenter=0 verticalCenter=0 / /mx:Canvas To scale, dunno, but maybe something like: mx:Canvas id=imageContainer width=100% height=100% mx:Image id=image source={yourSource} width={imageContainer.width image.width ? imageContainer.width : image.width} height={imageContainer.height image.height ? imageContainer.height : image.height} scaleContent=true horizontalCenter=0 verticalCenter=0 / /mx:Canvas This one probably won't work, it's very dirty, however might give you a clue... ;) And the easiest way to scale, but still, not so nice from the point of ui (it scales both way) is just: mx:Image source={yourSource} scaleContent=true width=100% height=100% / Have fun, R. On 1/18/07, Russell Sprague [EMAIL PROTECTED] wrote: I hate the flex documentation... All I want to do is dynamically center an image on my stage. I have a VDividedBox with an image in the top, and text in the bottom. I loading in images by setting the source of an image tag(probably not the best way to do it, but again I hate the Flex docs...). So when the image loads I am trying to set it to center in the upper pane of the vdividedbox, but all my attemps have failed. It would be nice to also resize the image as the divideBar is dragged, but only to the original size of the image, then it just centers. Thanks Russ
RE: [flexcoders] It shouldn't be this hard.
I hate the flex documentation... Also, if there are specific problems with the documentation, please let the doc team know by either posting to this list, adding a comment to livedocs, or filing a bug at http://www.adobe.com/go/wish. Thanks, matt horn flex docs -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Roman Protsiuk Sent: Thursday, January 18, 2007 7:51 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] It shouldn't be this hard. The first thought is: mx:Canvas width=100% height=100% mx:Image source={yourSource} horizontalCenter=0 verticalCenter=0 / /mx:Canvas To scale, dunno, but maybe something like: mx:Canvas id=imageContainer width=100% height=100% mx:Image id=image source={yourSource} width={imageContainer.width image.width ? imageContainer.width : image.width} height={imageContainer.height image.height ? imageContainer.height : image.height} scaleContent=true horizontalCenter=0 verticalCenter=0 / /mx:Canvas This one probably won't work, it's very dirty, however might give you a clue... ;) And the easiest way to scale, but still, not so nice from the point of ui (it scales both way) is just: mx:Image source={yourSource} scaleContent=true width=100% height=100% / Have fun, R. On 1/18/07, Russell Sprague [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I hate the flex documentation... All I want to do is dynamically center an image on my stage. I have a VDividedBox with an image in the top, and text in the bottom. I loading in images by setting the source of an image tag(probably not the best way to do it, but again I hate the Flex docs...). So when the image loads I am trying to set it to center in the upper pane of the vdividedbox, but all my attemps have failed. It would be nice to also resize the image as the divideBar is dragged, but only to the original size of the image, then it just centers. Thanks Russ
Re: [flexcoders] It shouldn't be this hard.
@Matt yea I don't really hate the docs, I was just a little frustrated, because most of the examples are Actionscript examples, and if I am looking for an example of how to do something in mxml, I don't know enough to translate the AS to mxml. @roman I tried the horizontal and verticalCenter, and it didn't work I think part of the problem is there is nothing in the component until I load the image, so there is nothing to measure to. Russ Matt Horn wrote: I hate the flex documentation... Also, if there are specific problems with the documentation, please let the doc team know by either posting to this list, adding a comment to livedocs, or filing a bug at http://www.adobe.com/go/wish. http://www.adobe.com/go/wish. Thanks, matt horn flex docs -Original Message- From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com] On Behalf Of Roman Protsiuk Sent: Thursday, January 18, 2007 7:51 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: Re: [flexcoders] It shouldn't be this hard. The first thought is: mx:Canvas width=100% height=100% mx:Image source={yourSource} horizontalCenter=0 verticalCenter=0 / /mx:Canvas To scale, dunno, but maybe something like: mx:Canvas id=imageContainer width=100% height=100% mx:Image id=image source={yourSource} width={imageContainer.width image.width ? imageContainer.width : image.width} height={imageContainer.height image.height ? imageContainer.height : image.height} scaleContent=true horizontalCenter=0 verticalCenter=0 / /mx:Canvas This one probably won't work, it's very dirty, however might give you a clue... ;) And the easiest way to scale, but still, not so nice from the point of ui (it scales both way) is just: mx:Image source={yourSource} scaleContent=true width=100% height=100% / Have fun, R. On 1/18/07, Russell Sprague [EMAIL PROTECTED] mailto:rsprague%40infusion-studios.com mailto:[EMAIL PROTECTED] mailto:rsprague%40infusion-studios.com wrote: I hate the flex documentation... All I want to do is dynamically center an image on my stage. I have a VDividedBox with an image in the top, and text in the bottom. I loading in images by setting the source of an image tag(probably not the best way to do it, but again I hate the Flex docs...). So when the image loads I am trying to set it to center in the upper pane of the vdividedbox, but all my attemps have failed. It would be nice to also resize the image as the divideBar is dragged, but only to the original size of the image, then it just centers. Thanks Russ
Re: [flexcoders] It shouldn't be this hard.
Here is the code for the image component mx:Canvas xmlns:mx=http://www.adobe.com/2006/mxml; mx:Metadata [Event(name=imageLoaded, type=events.ImageLoaded)] /mx:Metadata mx:Script ![CDATA[ import events.ImageLoaded; import flash.events.Event; [Bindable] private var imgsrc:String; public function loadImage(val:String):void{ imgsrc = assets/images/+val; } private function imgLoaded(e:Event):void{ trace(w +e.target.width); var ed:Object = new Object(); ed.ow = e.target.width; ed.oh = e.target.height; var eventUpdateObj:ImageLoaded = new ImageLoaded(ed, imageLoaded); dispatchEvent(eventUpdateObj); } ]] /mx:Script mx:Image id=bImage source={imgsrc} complete=imgLoaded(event) width=100% height=100% resize=true/ /mx:Canvas here is the code in the vDividedBox that holds the Image mx:VDividedBox xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:is=components.* paddingTop=1 initialize=init() dividerPress=dPress() dividerRelease=dRelease() updateComplete=changeSize(event) liveDragging=true mx:Script ![CDATA[ import events.ImageLoaded; import mx.events.DividerEvent; private var dividerY:Number; private var cHeight:Number; [Bindable] private var iUrl:String = assets/images/L1t1_1.jpg; [Bindable] private var txt:String = This is some text that is in the text block of the body of the frame work.brIt is suppose to wrap. but I need enough text.brIt need more.brand more.brand more.brand more.brand more.brand more.brand more.brand more.; private function init():void{ dividerY = this.getChildAt(1).height; //bHolder.loadPage(http://www.infusion-studios.com;); iHolder.loadImage(L1t1_1.jpg); } private function toggleTxt(event:Event):void{ if(event.target.label == Close){ dividerY = this.getChildAt(1).height this.moveDivider(0,this.getChildAt(1).height-20); event.target.label = Open; }else{ this.moveDivider(0,-dividerY); event.target.label = Close; } } private function dPress():void{ bHolder.hideBrowser(); } private function dRelease():void{ if(this.getChildAt(1).height 22){ trace(cHeight +this.getChildAt(1).height); dividerY = 200; toggle.label = Open; }else{ toggle.label = Close; } bHolder.showBrowser(); } private function changeSize(event:Event):void{ bHolder.setBrowser(); } private function imageLoaded(event:ImageLoaded):void{ trace(imageLoaded +this.width/2); iHolder.x = this.width/2-topPane.width/2 } ]] /mx:Script mx:Canvas id=topPane label=Canvas 1 width=100% height=100% verticalScrollPolicy=off horizontalScrollPolicy=off is:BrowseHolder id=bHolder/ is:ImageHolder id=iHolder width=100% height=100% imageLoaded=imageLoaded(event)/ /mx:Canvas mx:Canvas id=txtC label=Canvas 2 width=100% height=100% verticalScrollPolicy=off horizontalScrollPolicy=off minHeight=20 mx:VBox id=textBlock width=100% height=100% verticalGap=0 mx:HBox id=bar width=100% height=20 backgroundImage=assets/images/barBg.jpg backgroundSize=100% horizontalGap=0 mx:Image source=assets/images/barEnd.jpg/ mx:Spacer width=100%/ mx:LinkButton id=toggle height=17 label=Close click=toggleTxt(event)/ /mx:HBox mx:TextArea width=100% height=100% htmlText={txt} borderStyle=none verticalScrollPolicy=auto/ /mx:VBox /mx:Canvas /mx:VDividedBox So I am calling the imageLoaded function when the image completes loading in the component. I figured that is were would need to set the x,y also since the image scales to fit in the pane, I would need that size, not the size of the image itself. Russ Rich Tretola wrote: Please post the code that you are using. Rich On 1/17/07, *Russell Sprague* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I hate the flex documentation... All I want to do is dynamically center an image on my stage. I have a VDividedBox with an image in the top, and text in the bottom. I loading in images by setting the source of an image tag(probably not the best way to do it, but again I hate the Flex docs...). So when the image loads I am trying to set it to center in the upper pane of the vdividedbox, but all my attemps have failed. It would be nice to also resize the image as the divideBar is dragged, but only to the original size of the image, then it just centers. Thanks Russ
Re: [flexcoders] It shouldn't be this hard.
You could always set the x/y by hand when you load the image. Something like this: loadImage():void { image.source = mynewimage.jpg callLater(centerImage); } centerImage():void { image.x = (wrapper.width / 2) - (image.width / 2); image.y = (wrapper.height/ 2) - (image.height/ 2); } Shan Russell Sprague wrote: @Matt yea I don't really hate the docs, I was just a little frustrated, because most of the examples are Actionscript examples, and if I am looking for an example of how to do something in mxml, I don't know enough to translate the AS to mxml. @roman I tried the horizontal and verticalCenter, and it didn't work I think part of the problem is there is nothing in the component until I load the image, so there is nothing to measure to. Russ Matt Horn wrote: I hate the flex documentation... Also, if there are specific problems with the documentation, please let the doc team know by either posting to this list, adding a comment to livedocs, or filing a bug at http://www.adobe.com/go/wish. http://www.adobe.com/go/wish. Thanks, matt horn flex docs -Original Message- From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com] On Behalf Of Roman Protsiuk Sent: Thursday, January 18, 2007 7:51 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: Re: [flexcoders] It shouldn't be this hard. The first thought is: mx:Canvas width=100% height=100% mx:Image source={yourSource} horizontalCenter=0 verticalCenter=0 / /mx:Canvas To scale, dunno, but maybe something like: mx:Canvas id=imageContainer width=100% height=100% mx:Image id=image source={yourSource} width={imageContainer.width image.width ? imageContainer.width : image.width} height={imageContainer.height image.height ? imageContainer.height : image.height} scaleContent=true horizontalCenter=0 verticalCenter=0 / /mx:Canvas This one probably won't work, it's very dirty, however might give you a clue... ;) And the easiest way to scale, but still, not so nice from the point of ui (it scales both way) is just: mx:Image source={yourSource} scaleContent=true width=100% height=100% / Have fun, R. On 1/18/07, Russell Sprague [EMAIL PROTECTED] mailto:rsprague%40infusion-studios.com mailto:[EMAIL PROTECTED] mailto:rsprague%40infusion-studios.com wrote: I hate the flex documentation... All I want to do is dynamically center an image on my stage. I have a VDividedBox with an image in the top, and text in the bottom. I loading in images by setting the source of an image tag(probably not the best way to do it, but again I hate the Flex docs...). So when the image loads I am trying to set it to center in the upper pane of the vdividedbox, but all my attemps have failed. It would be nice to also resize the image as the divideBar is dragged, but only to the original size of the image, then it just centers. Thanks Russ
Re: [flexcoders] It shouldn't be this hard.
well that is what I thought, but I couldn't get it to work. Shannon Hicks wrote: You could always set the x/y by hand when you load the image. Something like this: loadImage():void { image.source = mynewimage.jpg callLater(centerImage); } centerImage():void { image.x = (wrapper.width / 2) - (image.width / 2); image.y = (wrapper.height/ 2) - (image.height/ 2); } Shan Russell Sprague wrote: @Matt yea I don't really hate the docs, I was just a little frustrated, because most of the examples are Actionscript examples, and if I am looking for an example of how to do something in mxml, I don't know enough to translate the AS to mxml. @roman I tried the horizontal and verticalCenter, and it didn't work I think part of the problem is there is nothing in the component until I load the image, so there is nothing to measure to. Russ Matt Horn wrote: I hate the flex documentation... Also, if there are specific problems with the documentation, please let the doc team know by either posting to this list, adding a comment to livedocs, or filing a bug at http://www.adobe.com/go/wish. http://www.adobe.com/go/wish. Thanks, matt horn flex docs -Original Message- From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com] On Behalf Of Roman Protsiuk Sent: Thursday, January 18, 2007 7:51 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: Re: [flexcoders] It shouldn't be this hard. The first thought is: mx:Canvas width=100% height=100% mx:Image source={yourSource} horizontalCenter=0 verticalCenter=0 / /mx:Canvas To scale, dunno, but maybe something like: mx:Canvas id=imageContainer width=100% height=100% mx:Image id=image source={yourSource} width={imageContainer.width image.width ? imageContainer.width : image.width} height={imageContainer.height image.height ? imageContainer.height : image.height} scaleContent=true horizontalCenter=0 verticalCenter=0 / /mx:Canvas This one probably won't work, it's very dirty, however might give you a clue... ;) And the easiest way to scale, but still, not so nice from the point of ui (it scales both way) is just: mx:Image source={yourSource} scaleContent=true width=100% height=100% / Have fun, R. On 1/18/07, Russell Sprague [EMAIL PROTECTED] mailto:rsprague%40infusion-studios.com mailto:[EMAIL PROTECTED] mailto:rsprague%40infusion-studios.com wrote: I hate the flex documentation... All I want to do is dynamically center an image on my stage. I have a VDividedBox with an image in the top, and text in the bottom. I loading in images by setting the source of an image tag(probably not the best way to do it, but again I hate the Flex docs...). So when the image loads I am trying to set it to center in the upper pane of the vdividedbox, but all my attemps have failed. It would be nice to also resize the image as the divideBar is dragged, but only to the original size of the image, then it just centers. Thanks Russ
Re: [flexcoders] It shouldn't be this hard.
Please post the code that you are using. Rich On 1/17/07, Russell Sprague [EMAIL PROTECTED] wrote: I hate the flex documentation... All I want to do is dynamically center an image on my stage. I have a VDividedBox with an image in the top, and text in the bottom. I loading in images by setting the source of an image tag(probably not the best way to do it, but again I hate the Flex docs...). So when the image loads I am trying to set it to center in the upper pane of the vdividedbox, but all my attemps have failed. It would be nice to also resize the image as the divideBar is dragged, but only to the original size of the image, then it just centers. Thanks Russ -- Rich Tretola mx:EverythingFlex/ http://www.EverythingFlex.com