Re: [flexcoders] Centering a Scaled Image ( Bug ? )

2009-11-30 Thread Manoj Kumar
try this mt-

private function onAppComplete():void
{
stage.addEventListener(Event.RESIZE,onResize);
_spr.x = (stage.stageWidth - _spr.width)/2;
_spr.y = (stage.stageHeight - _spr.height)/2;
_ui.width = stage.stageWidth;
_ui.height = stage.stageHeight;
}
private function onResize(evt:Event):void
{
_spr.x = (stage.stageWidth - _spr.width)/2;
_spr.y = (stage.stageHeight - _spr.height)/2;
_ui.width = stage.stageWidth;
_ui.height = stage.stageHeight;
}



--- On Mon, 11/30/09, ganaraj p r ganara...@gmail.com wrote:

From: ganaraj p r ganara...@gmail.com
Subject: [flexcoders] Centering a Scaled Image ( Bug ? ) [1 Attachment]
To: flex_in...@googlegroups.com, flexcoders@yahoogroups.com
Date: Monday, November 30, 2009, 4:08 PM







 



  



  
  
[Attachment(s) from ganaraj p r included below]

  
  I was wondering if this was a bug with flex or if I was doing something 
totally wrong. 
The amount of code in this is extremely low, so , I was guessing that there was 
nothing wrong from my part.


?xml version=1.0 encoding=utf-8?mx:Application 
xmlns:mx=http://www.adobe. com/2006/ mxml layout=absolute

mx:Image id=myimage maintainAspectRatio =true  
horizontalCenter=0 verticalCenter=0 

source=@Embed(source='images.jpg')
scaleContent=true width=100% height=100%/ 

/mx:Application

This is all the code there is in this application ( I am attaching the app, for 
your reference ) .My expectation from this code is that the image should fit 
the screen, maintain the aspect ratio of the image and finally be both centered 
horizontally and vertically!



Can someone help me out in this ?
-- 
Regards,
Ganaraj P R





 




  Attachment(s) from ganaraj p r

  
 1 of 1 File(s) 
  


  sampletest.zip
  
  
   

  

  Reply to sender
  | 
Reply to group
  

Messages in this topic
  (1)
   






  Recent Activity:



  New Members
  25

  

  
Visit Your Group
Start a New Topic
  



  


  --

Flexcoders Mailing List

FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt

Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847

Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com  




  MARKETPLACE
  
  
Going Green: Your Yahoo! Groups resource for green living  
  
  
Mom Power: Discover the community of moms doing more 
for their families, for the world and for each other  
  

  

  
  Switch to: Text-Only, Daily Digest • Unsubscribe • Terms of Use




   

  
  
  



 




 

  .


   


__,_._,try this-___


 



  






  

Re: [flexcoders] Centering a Scaled Image ( Bug ? )

2009-11-30 Thread ganaraj p r
Hi,

Thanks. Yes. But that is a workaround right?

I wanted to know if this was a bug with flex! Or if there was an mxml way of
doing it.

On Mon, Nov 30, 2009 at 5:42 PM, Manoj Kumar manoj_kode...@yahoo.comwrote:



 try this mt-

 private function onAppComplete():void
 {
 stage.addEventListener(Event.RESIZE,onResize);
 _spr.x = (stage.stageWidth - _spr.width)/2;
 _spr.y = (stage.stageHeight - _spr.height)/2;
 _ui.width = stage.stageWidth;
 _ui.height = stage.stageHeight;
 }
 private function onResize(evt:Event):void
 {
 _spr.x = (stage.stageWidth - _spr.width)/2;
 _spr.y = (stage.stageHeight - _spr.height)/2;
 _ui.width = stage.stageWidth;
 _ui.height = stage.stageHeight;
 }



 --- On *Mon, 11/30/09, ganaraj p r ganara...@gmail.com* wrote:


 From: ganaraj p r ganara...@gmail.com
 Subject: [flexcoders] Centering a Scaled Image ( Bug ? ) [1 Attachment]
 To: flex_in...@googlegroups.com, flexcoders@yahoogroups.com
 Date: Monday, November 30, 2009, 4:08 PM




 I was wondering if this was a bug with flex or if I was doing something
 totally wrong.

 The amount of code in this is extremely low, so , I was guessing that there
 was nothing wrong from my part.

 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe. com/2006/ 
 mxmlhttp://www.adobe.com/2006/mxml
 layout=absolute
  mx:Image id=myimage maintainAspectRatio =true
 horizontalCenter=0 verticalCenter=0
  source=@Embed(source='images.jpg')
 scaleContent=true width=100% height=100%/
 /mx:Application


 This is all the code there is in this application ( I am attaching the app,
 for your reference ) .
 My expectation from this code is that the image should fit the screen,
 maintain the aspect ratio of the image and finally be both centered
 horizontally and vertically!


 Can someone help me out in this ?

 --
 Regards,
 Ganaraj P R


  




-- 
Regards,
Ganaraj P R


Re: [flexcoders] Centering a Scaled Image ( Bug ? )

2009-11-30 Thread Chris
Well that is one day to do it, but this should work better:

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute
mx:Image id=myimage maintainAspectRatio=true
source=@Embed(source='images.jpg')
scaleContent=true width=100% height=100% horizontalAlign=middle
verticalAlign=middle /
/mx:Application

So the issue with the code is more an understanding of scaling:

My expectation from this code is that the image should fit the screen,
 maintain the aspect ratio of the image and finally be both centered
 horizontally and vertically!


Techinically the Image above 'fits' the screen, that is its width and height
is set to 100% of the application. Since it fills the application
completely, setting verticalCenter and horizontalCenter have no effect. You
would have to set a width and height of the Image's *content* to center, not
the image itself. An important but subtle distinction. The Image control
contains an image, but will have empty space inside it also if
maintainAspectRatio is true. The alignment of the contents within the Image
is controlled by the horizontalAlign and verticalAlign styles.

Peace
C


On Mon, Nov 30, 2009 at 10:03 PM, ganaraj p r ganara...@gmail.com wrote:



 Hi,

 Thanks. Yes. But that is a workaround right?

 I wanted to know if this was a bug with flex! Or if there was an mxml way
 of doing it.


 On Mon, Nov 30, 2009 at 5:42 PM, Manoj Kumar manoj_kode...@yahoo.comwrote:



 try this mt-

 private function onAppComplete():void
 {
 stage.addEventListener(Event.RESIZE,onResize);
 _spr.x = (stage.stageWidth - _spr.width)/2;
 _spr.y = (stage.stageHeight - _spr.height)/2;
 _ui.width = stage.stageWidth;
 _ui.height = stage.stageHeight;
 }
 private function onResize(evt:Event):void
 {
 _spr.x = (stage.stageWidth - _spr.width)/2;
 _spr.y = (stage.stageHeight - _spr.height)/2;
 _ui.width = stage.stageWidth;
 _ui.height = stage.stageHeight;
 }



 --- On *Mon, 11/30/09, ganaraj p r ganara...@gmail.com* wrote:


 From: ganaraj p r ganara...@gmail.com
 Subject: [flexcoders] Centering a Scaled Image ( Bug ? ) [1 Attachment]
 To: flex_in...@googlegroups.com, flexcoders@yahoogroups.com
 Date: Monday, November 30, 2009, 4:08 PM




 I was wondering if this was a bug with flex or if I was doing something
 totally wrong.

 The amount of code in this is extremely low, so , I was guessing that
 there was nothing wrong from my part.

 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe. com/2006/ 
 mxmlhttp://www.adobe.com/2006/mxml
 layout=absolute
  mx:Image id=myimage maintainAspectRatio =true
 horizontalCenter=0 verticalCenter=0
  source=@Embed(source='images.jpg')
 scaleContent=true width=100% height=100%/
 /mx:Application


 This is all the code there is in this application ( I am attaching the
 app, for your reference ) .
 My expectation from this code is that the image should fit the screen,
 maintain the aspect ratio of the image and finally be both centered
 horizontally and vertically!


 Can someone help me out in this ?

 --
 Regards,
 Ganaraj P R





 --
 Regards,
 Ganaraj P R
  



Re: [flexcoders] Centering a Scaled Image ( Bug ? )

2009-11-30 Thread ganaraj p r
Thank you :)

that helped a great deal.

On Tue, Dec 1, 2009 at 12:30 PM, Chris zomgfore...@gmail.com wrote:



 Well that is one day to do it, but this should work better:


 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 layout=absolute
 mx:Image id=myimage maintainAspectRatio=true
 source=@Embed(source='images.jpg')
 scaleContent=true width=100% height=100% horizontalAlign=middle
 verticalAlign=middle /
 /mx:Application

 So the issue with the code is more an understanding of scaling:


 My expectation from this code is that the image should fit the screen,
 maintain the aspect ratio of the image and finally be both centered
 horizontally and vertically!


 Techinically the Image above 'fits' the screen, that is its width and
 height is set to 100% of the application. Since it fills the application
 completely, setting verticalCenter and horizontalCenter have no effect. You
 would have to set a width and height of the Image's *content* to center, not
 the image itself. An important but subtle distinction. The Image control
 contains an image, but will have empty space inside it also if
 maintainAspectRatio is true. The alignment of the contents within the Image
 is controlled by the horizontalAlign and verticalAlign styles.

 Peace
 C



 On Mon, Nov 30, 2009 at 10:03 PM, ganaraj p r ganara...@gmail.com wrote:



 Hi,

 Thanks. Yes. But that is a workaround right?

 I wanted to know if this was a bug with flex! Or if there was an mxml way
 of doing it.


 On Mon, Nov 30, 2009 at 5:42 PM, Manoj Kumar manoj_kode...@yahoo.comwrote:



 try this mt-

 private function onAppComplete():void
 {
 stage.addEventListener(Event.RESIZE,onResize);
 _spr.x = (stage.stageWidth - _spr.width)/2;
 _spr.y = (stage.stageHeight - _spr.height)/2;
 _ui.width = stage.stageWidth;
 _ui.height = stage.stageHeight;
 }
 private function onResize(evt:Event):void
 {
 _spr.x = (stage.stageWidth - _spr.width)/2;
 _spr.y = (stage.stageHeight - _spr.height)/2;
 _ui.width = stage.stageWidth;
 _ui.height = stage.stageHeight;
 }



 --- On *Mon, 11/30/09, ganaraj p r ganara...@gmail.com* wrote:


 From: ganaraj p r ganara...@gmail.com
 Subject: [flexcoders] Centering a Scaled Image ( Bug ? ) [1 Attachment]
 To: flex_in...@googlegroups.com, flexcoders@yahoogroups.com
 Date: Monday, November 30, 2009, 4:08 PM




 I was wondering if this was a bug with flex or if I was doing something
 totally wrong.

 The amount of code in this is extremely low, so , I was guessing that
 there was nothing wrong from my part.

 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe. com/2006/ 
 mxmlhttp://www.adobe.com/2006/mxml
 layout=absolute
  mx:Image id=myimage maintainAspectRatio =true
 horizontalCenter=0 verticalCenter=0
  source=@Embed(source='images.jpg')
 scaleContent=true width=100% height=100%/
 /mx:Application


 This is all the code there is in this application ( I am attaching the
 app, for your reference ) .
 My expectation from this code is that the image should fit the screen,
 maintain the aspect ratio of the image and finally be both centered
 horizontally and vertically!


 Can someone help me out in this ?

 --
 Regards,
 Ganaraj P R





 --
 Regards,
 Ganaraj P R


  




-- 
Regards,
Ganaraj P R