Re: [Flashcoders] Resizing a background image only.And keeping aspect ratio.

2008-02-03 Thread Pedro Kostelec
Perhaps sth like this would work:
original_picture_width=550;
original_picture_height=400;

picture_mc.width=stage.stageWidth;
picture_mc.height=(stage.stageWidth /
original_picture_width)*original_picture_height;

I am not sure it is completely as3, becasue i just started learning it, so
you perhaps should mdify it a bit.
WIth this i think you should keep the aspect ratio


On Feb 3, 2008 4:12 AM, Vlado Krempl [EMAIL PROTECTED] wrote:

 Hello everyone,


 Question:  (Using actionscript 3)

 How to scale just the background image (photograph) fullscreen in the
 browser but still keep it's aspect ratio.
 All the solutions on the internet seem to still be in Actionscript 2.  I'm
 using the code below -

  
 -

 stage.addEventListener(Event.RESIZE, onStageResize);

  function onStageResize(event:Event):void {

 picture_mc = 

  }

 --

 I've tried stage.stagewidth and scaleX = stage.width; but they all distort
 the image when resized.

 Anyone have a clue?

 Thanks.



 Vlado

 Please consider the environment before printing this e-mail.
 The contents of this message should be treated as COMMERCIAL IN CONFIDENCE
 unless otherwise specified in the message
 and is intended solely for the use of the individual or entity to whom it
 is addressed.
 If you have received this email in error please notify the sender. If you
 are not the named addressee you should not disseminate, distribute or copy
 this e-mail.
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
Pedro D.K.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspect ratio.

2008-02-03 Thread Pedro Kostelec
Oh,
It is picture_mc.scaleX and not picture_mc.width
and
picture_mc.scaleY instead of picture_mc.height

At least i supose

On Feb 3, 2008 12:29 PM, Pedro Kostelec [EMAIL PROTECTED] wrote:

 Perhaps sth like this would work:
 original_picture_width=550;
 original_picture_height=400;

 picture_mc.width=stage.stageWidth;
 picture_mc.height=(stage.stageWidth /
 original_picture_width)*original_picture_height;

 I am not sure it is completely as3, becasue i just started learning it, so
 you perhaps should mdify it a bit.
 WIth this i think you should keep the aspect ratio


 On Feb 3, 2008 4:12 AM, Vlado Krempl [EMAIL PROTECTED] wrote:

  Hello everyone,
 
 
  Question:  (Using actionscript 3)
 
  How to scale just the background image (photograph) fullscreen in the
  browser but still keep it's aspect ratio.
  All the solutions on the internet seem to still be in Actionscript 2.
   I'm using the code below -
 
   
  -
 
  stage.addEventListener(Event.RESIZE, onStageResize);
 
   function onStageResize(event:Event):void {
 
  picture_mc = 
 
   }
 
  --
 
  I've tried stage.stagewidth and scaleX = stage.width; but they all
  distort the image when resized.
 
  Anyone have a clue?
 
  Thanks.
 
 
 
  Vlado
 
  Please consider the environment before printing this e-mail.
  The contents of this message should be treated as COMMERCIAL IN
  CONFIDENCE unless otherwise specified in the message
  and is intended solely for the use of the individual or entity to whom
  it is addressed.
  If you have received this email in error please notify the sender. If
  you are not the named addressee you should not disseminate, distribute or
  copy this e-mail.
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 



 --
 Pedro D.K.




-- 
Pedro D.K.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspect ratio.

2008-02-03 Thread Kenneth Kawamoto

It could be cleaner, but here we go:

private function onStageResize(e:Event):void {
  var picRatio:Number = picture_mc.width/picture_mc.height;
  var stageRatio:Number = stage.stageWidth/stage.stageHeight;
  if(picRatio  stageRatio){
 picture_mc.width = stage.stageWidth;
 picture_mc.height = picture_mc.width/picRatio;
  } else {
 picture_mc.height = stage.stageHeight;
 picture_mc.width = picture_mc.height*picRatio;
  }
}

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:

Hello everyone,


Question:  (Using actionscript 3) 


How to scale just the background image (photograph) fullscreen in the browser 
but still keep it's aspect ratio.
All the solutions on the internet seem to still be in Actionscript 2.  I'm 
using the code below -
 
-

stage.addEventListener(Event.RESIZE, onStageResize);
 
 function onStageResize(event:Event):void {


picture_mc =  
 
 }

--

I've tried stage.stagewidth and scaleX = stage.width; but they all distort the 
image when resized.

Anyone have a clue?

Thanks.



Vlado

  

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Vlado Krempl

Thanks for the reply,

Cheers,

from
Sydney,
Australia.
- Original Message - 
From: Pedro Kostelec [EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 10:29 PM
Subject: Re: [Flashcoders] Resizing a background image only.And keeping 
aspectratio.




Perhaps sth like this would work:
original_picture_width=550;
original_picture_height=400;

picture_mc.width=stage.stageWidth;
picture_mc.height=(stage.stageWidth /
original_picture_width)*original_picture_height;

I am not sure it is completely as3, becasue i just started learning it, so
you perhaps should mdify it a bit.
WIth this i think you should keep the aspect ratio


On Feb 3, 2008 4:12 AM, Vlado Krempl [EMAIL PROTECTED] wrote:


Hello everyone,


Question:  (Using actionscript 3)

How to scale just the background image (photograph) fullscreen in the
browser but still keep it's aspect ratio.
All the solutions on the internet seem to still be in Actionscript 2. 
I'm

using the code below -

 
-

stage.addEventListener(Event.RESIZE, onStageResize);

 function onStageResize(event:Event):void {

picture_mc = 

 }

--

I've tried stage.stagewidth and scaleX = stage.width; but they all 
distort

the image when resized.

Anyone have a clue?

Thanks.



Vlado

Please consider the environment before printing this e-mail.
The contents of this message should be treated as COMMERCIAL IN 
CONFIDENCE

unless otherwise specified in the message
and is intended solely for the use of the individual or entity to whom it
is addressed.
If you have received this email in error please notify the sender. If you
are not the named addressee you should not disseminate, distribute or 
copy

this e-mail.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders





--
Pedro D.K.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Vlado Krempl

Thanks for the reply, will give it a go.
Cheers,
from
Sydney, Australia.
- Original Message - 
From: Kenneth Kawamoto [EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 11:03 PM
Subject: Re: [Flashcoders] Resizing a background image only.And keeping 
aspectratio.




It could be cleaner, but here we go:

private function onStageResize(e:Event):void {
  var picRatio:Number = picture_mc.width/picture_mc.height;
  var stageRatio:Number = stage.stageWidth/stage.stageHeight;
  if(picRatio  stageRatio){
 picture_mc.width = stage.stageWidth;
 picture_mc.height = picture_mc.width/picRatio;
  } else {
 picture_mc.height = stage.stageHeight;
 picture_mc.width = picture_mc.height*picRatio;
  }
}

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:

Hello everyone,


Question:  (Using actionscript 3)
How to scale just the background image (photograph) fullscreen in the 
browser but still keep it's aspect ratio.
All the solutions on the internet seem to still be in Actionscript 2. 
I'm using the code below -

 
-

stage.addEventListener(Event.RESIZE, onStageResize);
 function onStageResize(event:Event):void {

picture_mc =  }
--

I've tried stage.stagewidth and scaleX = stage.width; but they all 
distort the image when resized.


Anyone have a clue?

Thanks.



Vlado



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Vlado Krempl

Kenneth,

Works fantastic. Thanks.
One problem though, in the browser ( IE ) the image shows up small and only 
resizes when you adjust the browser.
Is it possible to have the image in the browser and have the image touching 
the sides at all times.

Here is a great example site.

http://www.zinkmag.com

Cheers,

vlado


- Original Message - 
From: Kenneth Kawamoto [EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 11:03 PM
Subject: Re: [Flashcoders] Resizing a background image only.And keeping 
aspectratio.




It could be cleaner, but here we go:

private function onStageResize(e:Event):void {
  var picRatio:Number = picture_mc.width/picture_mc.height;
  var stageRatio:Number = stage.stageWidth/stage.stageHeight;
  if(picRatio  stageRatio){
 picture_mc.width = stage.stageWidth;
 picture_mc.height = picture_mc.width/picRatio;
  } else {
 picture_mc.height = stage.stageHeight;
 picture_mc.width = picture_mc.height*picRatio;
  }
}

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:

Hello everyone,


Question:  (Using actionscript 3)
How to scale just the background image (photograph) fullscreen in the 
browser but still keep it's aspect ratio.
All the solutions on the internet seem to still be in Actionscript 2. 
I'm using the code below -

 
-

stage.addEventListener(Event.RESIZE, onStageResize);
 function onStageResize(event:Event):void {

picture_mc =  }
--

I've tried stage.stagewidth and scaleX = stage.width; but they all 
distort the image when resized.


Anyone have a clue?

Thanks.



Vlado



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Ivan Dembicki
Hello

oops

private function onAddedToStage(e:Event=null):void {
 onStageResize();
}
private function onStageResize(e:Event=null):void {
 picture_mc.width = stage.stageWidth;
 picture_mc.height = stage.stageHeight;
 picture_mc.scaleX = picture_mc.scaleY =
 Math.max (picture_mc.scaleX, picture_mc.scaleY);
}

-- 
iv
http://www.bezier.ru
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Pedro Kostelec
You mean you want to update it all the time(the image size)?

Try sth like this:




private function init():void {

stage.addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
private function onEnterFrame(event:Event):void {
var picRatio:Number=picture_mc.width / picture_mc.height; //i
took kenneths code!!
var stageRatio:Number=stage.stageWidth / stage.stageHeight;
if (picRatio  stageRatio) {
picture_mc.width=stage.stageWidth;
picture_mc.height=picture_mc.width / picRatio;
} else {
picture_mc.height=stage.stageHeight;
picture_mc.width=picture_mc.height * picRatio;
}

}


On Feb 3, 2008 2:11 PM, Vlado Krempl [EMAIL PROTECTED] wrote:

 Kenneth,

 Works fantastic. Thanks.
 One problem though, in the browser ( IE ) the image shows up small and
 only
 resizes when you adjust the browser.
 Is it possible to have the image in the browser and have the image
 touching
 the sides at all times.
 Here is a great example site.

 http://www.zinkmag.com

 Cheers,

 vlado


 - Original Message -
 From: Kenneth Kawamoto [EMAIL PROTECTED]
 To: Flash Coders List flashcoders@chattyfig.figleaf.com
 Sent: Sunday, February 03, 2008 11:03 PM
 Subject: Re: [Flashcoders] Resizing a background image only.And keeping
 aspectratio.


  It could be cleaner, but here we go:
 
  private function onStageResize(e:Event):void {
var picRatio:Number = picture_mc.width/picture_mc.height;
var stageRatio:Number = stage.stageWidth/stage.stageHeight;
if(picRatio  stageRatio){
   picture_mc.width = stage.stageWidth;
   picture_mc.height = picture_mc.width/picRatio;
} else {
   picture_mc.height = stage.stageHeight;
   picture_mc.width = picture_mc.height*picRatio;
}
  }
 
  Kenneth Kawamoto
  http://www.materiaprima.co.uk/
 
  Vlado Krempl wrote:
  Hello everyone,
 
 
  Question:  (Using actionscript 3)
  How to scale just the background image (photograph) fullscreen in the
  browser but still keep it's aspect ratio.
  All the solutions on the internet seem to still be in Actionscript 2.
  I'm using the code below -
 
  
 -
 
  stage.addEventListener(Event.RESIZE, onStageResize);
   function onStageResize(event:Event):void {
 
  picture_mc =  }
 
 --
 
  I've tried stage.stagewidth and scaleX = stage.width; but they all
  distort the image when resized.
 
  Anyone have a clue?
 
  Thanks.
 
 
 
  Vlado
 
 
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 


 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
Pedro D.K.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Ivan Dembicki
Hello

private function onAddedToStage(e:Event=null):void {
  private function onStageResize();
}
private function onStageResize(e:Event=null):void {
  picture_mc.width = stage.stageWidth;
  picture_mc.height = stage.stageHeight;
  picture_mc.scaleX = picture_mc.scaleY =
  Math.max (picture_mc.scaleX, picture_mc.scaleY);
}


-- 
iv
http://www.bezier.ru
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Ivan Dembicki
Hello

oops again :)

private function onAddedToStage(e:Event):void {
  onStageResize();
}
private function onStageResize(e:Event=null):void {
  picture_mc.width = stage.stageWidth;
  picture_mc.height = stage.stageHeight;
  picture_mc.scaleX = picture_mc.scaleY =
  Math.min(picture_mc.scaleX, picture_mc.scaleY);
}


-- 
iv
http://www.bezier.ru
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Save MC as JPG

2008-02-03 Thread Dave Mennenoh

Nobody?
I am still not figuring this out. Using getPixel() on certain clips is 
returning #FF when it's cleary not a white pixel. But it makes no sense. 
On one clip it works, on another it doesn't. Both are just movie clips 
containing imported bitmap images. I've searched for problems with 
getPixel() but haven't found anything regarding returning white when it 
shouldn't. This is frustrating.


Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Save MC as JPG

2008-02-03 Thread John McCormack

Has the frame definitely loaded when you read the pixel?
Have you some code to give us a clue?

John

- Original Message - 
From: Dave Mennenoh [EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 2:24 PM
Subject: Re: [Flashcoders] Save MC as JPG



Nobody?
I am still not figuring this out. Using getPixel() on certain clips is 
returning #FF when it's cleary not a white pixel. But it makes no 
sense. On one clip it works, on another it doesn't. Both are just movie 
clips containing imported bitmap images. I've searched for problems with 
getPixel() but haven't found anything regarding returning white when it 
shouldn't. This is frustrating.


Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Save MC as JPG

2008-02-03 Thread Hans Wichman
Hi,
can u put a test online? With fla that is.
greetz
JC

On Feb 3, 2008 3:24 PM, Dave Mennenoh [EMAIL PROTECTED] wrote:

 Nobody?
 I am still not figuring this out. Using getPixel() on certain clips is
 returning #FF when it's cleary not a white pixel. But it makes no
 sense.
 On one clip it works, on another it doesn't. Both are just movie clips
 containing imported bitmap images. I've searched for problems with
 getPixel() but haven't found anything regarding returning white when it
 shouldn't. This is frustrating.

 Dave -
 Head Developer
 http://www.blurredistinction.com
 Adobe Community Expert
 http://www.adobe.com/communities/experts/

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Save MC as JPG

2008-02-03 Thread Dave Mennenoh
OK -it seems to be the BitmapData.draw() method that is failing. On just 
certain images (though all are jpeg's imported into Flash and turned into 
MC's) draw() is copying an all white image, and on some it works. It doesn't 
seem to be a size issue since some rather large images are working.



Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Save MC as JPG

2008-02-03 Thread Hans Wichman
Hi,
are you loading all images from the same domain?

greetz
JC

On Feb 3, 2008 4:00 PM, Dave Mennenoh [EMAIL PROTECTED] wrote:

 OK -it seems to be the BitmapData.draw() method that is failing. On just
 certain images (though all are jpeg's imported into Flash and turned into
 MC's) draw() is copying an all white image, and on some it works. It
 doesn't
 seem to be a size issue since some rather large images are working.


 Dave -
 Head Developer
 http://www.blurredistinction.com
 Adobe Community Expert
 http://www.adobe.com/communities/experts/

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Save MC as JPG

2008-02-03 Thread John McCormack
Might it be this...

public checkPolicyFile : Boolean

Specifies whether Flash Player should attempt to download a cross-domain policy 
file from the loaded object's server before beginning to load the object 
itself. 

Set this flag to true when you are loading an image (JPG, GIF, or PNG) from 
outside the calling SWF file's own domain and you expect to access the content 
of that image using BitmapData.draw(). If you attempt this operation without 
having specified checkPolicyFile at loading time, you may encounter a security 
error because the needed policy file has not been downloaded yet.

John

- Original Message - 
From: Dave Mennenoh [EMAIL PROTECTED]
To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 3:00 PM
Subject: Re: [Flashcoders] Save MC as JPG


 OK -it seems to be the BitmapData.draw() method that is failing. On just 
 certain images (though all are jpeg's imported into Flash and turned into 
 MC's) draw() is copying an all white image, and on some it works. It doesn't 
 seem to be a size issue since some rather large images are working.
 
 
 Dave -
 Head Developer
 http://www.blurredistinction.com
 Adobe Community Expert
 http://www.adobe.com/communities/experts/ 
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Save MC as JPG

2008-02-03 Thread Dave Mennenoh
Sorry... I have it figured out now. Some of the clips I was given had their 
registration points at bottom left, instead of top left. Changing them all 
to top-left cured the issue. Funny how those little things can trip you up 
for a day!



Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Kenneth Kawamoto

Vlado,

The site you're referring is slightly different, i.e. my code shows ALL
regions of the image while maintaining the aspect ratio, but the site
fills the Stage and crops the image if the Stage aspect ratio does not
match the image's. There is also a minimum width/height of the image 
and the image does not get smaller than that width.


Ivan's approach is good but it's Math.max(), not Math.min() I believe.

Here's the revised code:


private const MINW:uint = 1024;
private const MINH:uint = 768;

private function onStageResize(e:Event = null):void {
   picture_mc.width = Math.max(stage.stageWidth, MINW);
   picture_mc.height = Math.max(stage.stageHeight, MINH);
   picture_mc.scaleX = picture_mc.scaleY = Math.max(picture_mc.scaleX, 
picture_mc.scaleY);

   picture_mc.x = Math.floor((stage.stageWidth - picture_mc.width)/2);
   picture_mc.y = Math.floor((stage.stageHeight - picture_mc.height)/2);
}

(You could add where to anchor the image too, so that eyes are always 
seen, for example.)


Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:

Kenneth,

Works fantastic. Thanks.
One problem though, in the browser ( IE ) the image shows up small and 
only resizes when you adjust the browser.
Is it possible to have the image in the browser and have the image 
touching the sides at all times.

Here is a great example site.

http://www.zinkmag.com

Cheers,

vlado


- Original Message - From: Kenneth Kawamoto 
[EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 11:03 PM
Subject: Re: [Flashcoders] Resizing a background image only.And 
keeping aspectratio.




It could be cleaner, but here we go:

private function onStageResize(e:Event):void {
  var picRatio:Number = picture_mc.width/picture_mc.height;
  var stageRatio:Number = stage.stageWidth/stage.stageHeight;
  if(picRatio  stageRatio){
 picture_mc.width = stage.stageWidth;
 picture_mc.height = picture_mc.width/picRatio;
  } else {
 picture_mc.height = stage.stageHeight;
 picture_mc.width = picture_mc.height*picRatio;
  }
}

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:

Hello everyone,


Question:  (Using actionscript 3)
How to scale just the background image (photograph) fullscreen in 
the browser but still keep it's aspect ratio.
All the solutions on the internet seem to still be in Actionscript 
2. I'm using the code below -
 - 



stage.addEventListener(Event.RESIZE, onStageResize);
 function onStageResize(event:Event):void {

picture_mc =  }
-- 



I've tried stage.stagewidth and scaleX = stage.width; but they all 
distort the image when resized.


Anyone have a clue?

Thanks.



Vlado 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Dynamic upload of bunch of images with automatic smooth.

2008-02-03 Thread Irene Johansson
Hello all you fine people!
I have a big problem with uploading smooth images.

What I do is, i load XML file, parse it loop through it, create movieclips,
and load images into thos movieclips (if image is specified in xml)

for(var k:Number=1; k=itemNr; k++){
usrNr++;
var walker1:MovieClip = new walker();
walker1.x = k*150+ Math.random()*40;
//walker1.y = Math.random()*5;
walker1.name = walker+k;
walker1.i = i;
walker1.k = k;
this[row+i].addChild(walker1);
var walkerMc:MovieClip = this[rad+i].getChildByName(walker+k) as
MovieClip;
if(xml..epic[usrNr-1].text()!= undefined){
//upload picture
var loader:Loader = new Loader();
walkerMc.figure.head.imgholder.addChild(loader);

loader.load(new URLRequest(theURL+img/+xml..epic[usrNr-1].text()));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleComplete,
false, 0, true);
}else{
//show random face
walkerMc.figure.head.faces.gotoAndStop(xml..spic[brukerNr-1].text());
}

}



function handleComplete(event:Event){
var ldr:Loader = LoaderInfo(event.currentTarget).loader as Loader;
ldr.contentLoaderInfo.content.width=43;
ldr.contentLoaderInfo.content.height=43;


var image:Bitmap = Bitmap(ldr.contentLoaderInfo.content);
image.smoothing = true;

}



I get to load images, but they are not allways smooth :(
What am i doing wrong :(

Thanks in advance
Irene
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] AS3 dynamic scrollbar that resizes onStageResize, but is not fullscreen- script?

2008-02-03 Thread Irene Johansson
Hello again :)
I was googling a lot but i could not find any as3 scrollbar that
automatically resizes when windows is bigger.
Has anyone seen/ is a proud owner, and does not mind to share that kind of
script.

Cheers
Irene
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic upload of bunch of images with automaticsmooth.

2008-02-03 Thread Muzak

Check the example in the docs.
You need to create a copy of the original (loaded) image, add it to the display 
list and remove the (original) loaded image

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Bitmap.html

Here's an example of loading an image and displaying a copy next to it:

import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.Bitmap;

var loader:Loader;
var req:URLRequest;
var orig_mc:MovieClip;
var copy_mc:MovieClip;

function loaderCompleteHandler(evt:Event) {
var ldr:Loader = evt.currentTarget.loader as Loader;
var origImg:Bitmap = (ldr.content as Bitmap)
origImg.width = 200;
origImg.height = 150;

var image:Bitmap = new Bitmap(origImg.bitmapData, auto, true);
image.width = 200;
image.height = 150;
copy_mc.addChild(image);
}

loader = new Loader();
req = new URLRequest(2.jpg);
loader.load(req);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
loaderCompleteHandler);

orig_mc = new MovieClip();
orig_mc.addChild(loader);
addChild(orig_mc);

copy_mc = new MovieClip();
copy_mc.x = 210;
addChild(copy_mc);


regards,
Muzak

- Original Message - 
From: Irene Johansson [EMAIL PROTECTED]

To: flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 7:43 PM
Subject: [Flashcoders] Dynamic upload of bunch of images with automaticsmooth.



Hello all you fine people!
I have a big problem with uploading smooth images.

What I do is, i load XML file, parse it loop through it, create movieclips,
and load images into thos movieclips (if image is specified in xml)

for(var k:Number=1; k=itemNr; k++){
usrNr++;
var walker1:MovieClip = new walker();
walker1.x = k*150+ Math.random()*40;
//walker1.y = Math.random()*5;
walker1.name = walker+k;
walker1.i = i;
walker1.k = k;
this[row+i].addChild(walker1);
var walkerMc:MovieClip = this[rad+i].getChildByName(walker+k) as
MovieClip;
if(xml..epic[usrNr-1].text()!= undefined){
//upload picture
var loader:Loader = new Loader();
walkerMc.figure.head.imgholder.addChild(loader);

loader.load(new URLRequest(theURL+img/+xml..epic[usrNr-1].text()));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleComplete,
false, 0, true);
}else{
//show random face
walkerMc.figure.head.faces.gotoAndStop(xml..spic[brukerNr-1].text());
}

}



function handleComplete(event:Event){
var ldr:Loader = LoaderInfo(event.currentTarget).loader as Loader;
ldr.contentLoaderInfo.content.width=43;
ldr.contentLoaderInfo.content.height=43;


var image:Bitmap = Bitmap(ldr.contentLoaderInfo.content);
image.smoothing = true;

}



I get to load images, but they are not allways smooth :(
What am i doing wrong :(

Thanks in advance
Irene
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Simple compression algo?

2008-02-03 Thread Dave Mennenoh
Hi all, I've been working on allowing users to dowload a jpeg from a 
movieClip in AS2 and came up with a simple, yet novel compression idea, 
that's a bit like RLE but not quite.


Basically it is this - analyze the image pixel by pixel to get the hex color 
codes into an array. Then, make a new array the same length as the colors 
array, but filled with  - so it's full of nulls. I then iterate the colors 
array and if the current color is the same as the previous color, I don't 
add it to the new array - otherwise I do.


So if I have: [ff, ff, ff, aa, ff, aa, aa, aa, aa] the new array would be 
[ff, , , aa, ff, aa, , , ]


It makes it easy to reconstruct too, and it's taken about 7 seconds off in 
my tests. Saving a 300x320 image went from about 26sec to now 19sec. It's 
not huge, but everything is something...




Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Simple compression algo?

2008-02-03 Thread Juan Pablo Califano
Interesting stuff. I assume you're creating the jpeg on the server since you 
seem to be passing the raw bitmap data (compressing the pixel data with your 
algorythm).


Perhaps another approach worth trying is creating the jpef directly on the 
Flash app. Have you tried it?


I've done that with AS 3.0, using a class provided by adobe, JPGEncoder, 
that I found browsing the web. I think it could be easily ported to AS 2.0; 
the only AS 3.0 feature used in the encoder is the ByteArray, which can be 
ported to AS 2.0 as well. I've already done that and it works fine; of 
course, since it's AS and not native code (and since it runs in the AVM1 
instead of the AVM2), the performance would not be as good as the native 
ByteArray. I haven't benchmarked or stress-test it, but so far, it gets the 
job done.


The cons of this approach: it will require more processing on the client 
side (perhaps too much to consider using it in production, but the only way 
to know is testing and benchmarking, I guess). On the other hand, sending a 
~10 - ~15 Kb jpeg upstream should be way faster than posting a ~750 KB 
string (assuming 24 bits per pixel, 300 px * 320 px * 4 bytes (3 per pixel, 
1 for the each comma) * 2 (taking the max value of 'ff', 2 chars). Probably 
it's a bit less than that since your are compressing it...


Can you describe the flow of your app?

Cheers
Juan Pablo Califano

- Original Message - 
From: Dave Mennenoh [EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 8:12 PM
Subject: [Flashcoders] Simple compression algo?


Hi all, I've been working on allowing users to dowload a jpeg from a 
movieClip in AS2 and came up with a simple, yet novel compression idea, 
that's a bit like RLE but not quite.


Basically it is this - analyze the image pixel by pixel to get the hex 
color codes into an array. Then, make a new array the same length as the 
colors array, but filled with  - so it's full of nulls. I then iterate 
the colors array and if the current color is the same as the previous 
color, I don't add it to the new array - otherwise I do.


So if I have: [ff, ff, ff, aa, ff, aa, aa, aa, aa] the new array would be 
[ff, , , aa, ff, aa, , , ]


It makes it easy to reconstruct too, and it's taken about 7 seconds off in 
my tests. Saving a 300x320 image went from about 26sec to now 19sec. It's 
not huge, but everything is something...




Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

2008-02-03 Thread Kenneth Kawamoto

I don't know how you are loading/adding the image to the Stage, but just
fire image resize command as soon as the image is ready. For example:

private function fillStage():void {
  picture_mc.width = Math.max(stage.stageWidth, minW);
  picture_mc.height = Math.max(stage.stageHeight, minH);
  picture_mc.scaleX = picture_mc.scaleY = Math.max(picture_mc.scaleX,
picture_mc.scaleY);
}

private function onLoadInit(e:Event):void {
  picture_mc.addChild(e.target.content);
  minW = picture_mc.width;
  minH = picture_mc.height;
  fillStage();
}

private function onStageResize(e:Event):void {
  fillStage();
}

(this example is using Loader to load the image and adding it to picture_mc)

By the way your HTML does not display Flash content on Firefox (Mac).

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:

Kenneth,

Your script is perfect.
Except this happensclick the link.   (It doesn't resize until 
you adjust the browser.)


http://experiments.vkd.com.au/

I have set the html to percent 100% width and length.


Thanks again for all your help.

vlado

- Original Message - From: Kenneth Kawamoto 
[EMAIL PROTECTED]
To: Vlado Krempl [EMAIL PROTECTED]; Flash Coders List 
flashcoders@chattyfig.figleaf.com

Sent: Monday, February 04, 2008 3:14 AM
Subject: Re: [Flashcoders] Resizing a background image only.And 
keeping aspectratio.




Vlado,

The site you're referring is slightly different, i.e. my code shows ALL
regions of the image while maintaining the aspect ratio, but the site
fills the Stage and crops the image if the Stage aspect ratio does not
match the image's. There is also a minimum width/height of the 
image and the image does not get smaller than that width.


Ivan's approach is good but it's Math.max(), not Math.min() I believe.

Here's the revised code:


private const MINW:uint = 1024;
private const MINH:uint = 768;

private function onStageResize(e:Event = null):void {
   picture_mc.width = Math.max(stage.stageWidth, MINW);
   picture_mc.height = Math.max(stage.stageHeight, MINH);
   picture_mc.scaleX = picture_mc.scaleY = 
Math.max(picture_mc.scaleX, picture_mc.scaleY);

   picture_mc.x = Math.floor((stage.stageWidth - picture_mc.width)/2);
   picture_mc.y = Math.floor((stage.stageHeight - picture_mc.height)/2);
}

(You could add where to anchor the image too, so that eyes are 
always seen, for example.)


Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:

Kenneth,

Works fantastic. Thanks.
One problem though, in the browser ( IE ) the image shows up small 
and only resizes when you adjust the browser.
Is it possible to have the image in the browser and have the image 
touching the sides at all times.

Here is a great example site.

http://www.zinkmag.com

Cheers,

vlado


- Original Message - From: Kenneth Kawamoto 
[EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Sunday, February 03, 2008 11:03 PM
Subject: Re: [Flashcoders] Resizing a background image only.And 
keeping aspectratio.




It could be cleaner, but here we go:

private function onStageResize(e:Event):void {
  var picRatio:Number = picture_mc.width/picture_mc.height;
  var stageRatio:Number = stage.stageWidth/stage.stageHeight;
  if(picRatio  stageRatio){
 picture_mc.width = stage.stageWidth;
 picture_mc.height = picture_mc.width/picRatio;
  } else {
 picture_mc.height = stage.stageHeight;
 picture_mc.width = picture_mc.height*picRatio;
  }
}

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:

Hello everyone,


Question:  (Using actionscript 3)
How to scale just the background image (photograph) fullscreen in 
the browser but still keep it's aspect ratio.
All the solutions on the internet seem to still be in Actionscript 
2. I'm using the code below -
 - 




stage.addEventListener(Event.RESIZE, onStageResize);
 function onStageResize(event:Event):void {

picture_mc =  }
-- 




I've tried stage.stagewidth and scaleX = stage.width; but they all 
distort the image when resized.


Anyone have a clue?

Thanks.



Vlado


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Simple compression algo?

2008-02-03 Thread Glen Pike

Sounds a bit like Run Length Encoding

Dave Mennenoh wrote:
Hi all, I've been working on allowing users to dowload a jpeg from a 
movieClip in AS2 and came up with a simple, yet novel compression 
idea, that's a bit like RLE but not quite.


Basically it is this - analyze the image pixel by pixel to get the hex 
color codes into an array. Then, make a new array the same length as 
the colors array, but filled with  - so it's full of nulls. I then 
iterate the colors array and if the current color is the same as the 
previous color, I don't add it to the new array - otherwise I do.


So if I have: [ff, ff, ff, aa, ff, aa, aa, aa, aa] the new array would 
be [ff, , , aa, ff, aa, , , ]


It makes it easy to reconstruct too, and it's taken about 7 seconds 
off in my tests. Saving a 300x320 image went from about 26sec to now 
19sec. It's not huge, but everything is something...




Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




--

Glen Pike
01736 759321
www.glenpike.co.uk http://www.glenpike.co.uk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Simple compression algo?

2008-02-03 Thread Claudius Ceteras
Hi,

 Hi all, I've been working on allowing users to dowload a jpeg from a 
 movieClip in AS2 and came up with a simple, yet novel 
 compression idea, 
 that's a bit like RLE but not quite.
 
 Basically it is this - analyze the image pixel by pixel to 
 get the hex color 
 codes into an array. Then, make a new array the same length 
 as the colors 
 array, but filled with  - so it's full of nulls. I then 
 iterate the colors 
 array and if the current color is the same as the previous 
 color, I don't 
 add it to the new array - otherwise I do.
 
 So if I have: [ff, ff, ff, aa, ff, aa, aa, aa, aa] the new 
 array would be 
 [ff, , , aa, ff, aa, , , ]

you're sending a comma separated string to the server?

why not have 2 hey digits for all the data and omit the comma? this would
bring your data to 2/3 of its size, which means 26sec*2/3 = 17.3sec

when this works, you could try to send binary data - so instead if sending
the string ff you would send the binary byte 255. if this works, this
would cut the time in half again = 8.6sec

if you can't create binary data, you could still use base64 encoding
instead, which would give you 8.6*1.33 = 11.5sec.

regards

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Flex Lists

2008-02-03 Thread Andrew Sinning
Where do the folks on this list go for Flex questions.  I'm looking for 
a Flex-Newbies list.


Thanks.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Flex Lists

2008-02-03 Thread percepticon
Flexcodersof course :D
Sent via BlackBerry by ATT

-Original Message-
From: Andrew Sinning [EMAIL PROTECTED]

Date: Sun, 03 Feb 2008 21:35:45 
To:Flash Coders flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Flex Lists


Where do the folks on this list go for Flex questions.  I'm looking for 
a Flex-Newbies list.

Thanks.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Problem with datefield disabled ranges

2008-02-03 Thread JD Hoover

Hi,
I'm using a datefield component Flash 8 and want to disable dates from 
an external xml file created from a mysql db.The two instances are 
instantiated from the library. Trace of the disabled date array is:
{rangeStart: new Date(2008,2,6), rangeEnd: new 
Date(2008,7,3)},{rangeStart: new Date(2008,7,3), rangeEnd: new 
Date(2008,7,7)},{rangeStart: new Date(2007,6,5), rangeEnd: new 
Date(2007,8,7)},{rangeStart: new Date(2007,9,8), rangeEnd: new 
Date(2007,11,10)}


The AS is as follows:
stop();
var daysIn:Array = new Array();
var monthsIn:Array = new Array();
var yearsIn:Array = new Array();
var daysOut:Array = new Array();
var monthsOut:Array = new Array();
var yearsOut:Array = new Array();
var allData:Array = [];
myXml_xml = new XML();
myXml_xml.ignoreWhite = true;
myXml_xml.onLoad = function(ok) {
   if (ok) {
   allData = myXml_xml.firstChild.childNodes;
   //trace(allData);
   var i = 0;
   do {
   //create dates sub arrays
   daysIn.push(allData[i].firstChild.firstChild);
   monthsIn.push(allData[i].firstChild.nextSibling.firstChild);
   
yearsIn.push(allData[i].firstChild.nextSibling.nextSibling.firstChild);
   
daysOut.push(allData[i].firstChild.nextSibling.nextSibling.nextSibling.firstChild);
   
monthsOut.push(allData[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.firstChild);
   
yearsOut.push(allData[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild);

   i++;
   } while (iallData.length);
   }
   var disabledDates:Array = new Array();
   var f = 0;
   do {
   //create Array of disabled dates
   disabledDates.push('{rangeStart: new 
Date('+yearsIn[f]+','+monthsIn[f]+','+daysIn[f]+'), rangeEnd: new 
Date('+yearsOut[f]+','+monthsOut[f]+','+daysOut[f]+')}');

   f++;
   } while (fdaysIn.length);
   //create datefields
   _root.createClassObject(mx.controls.DateField, in_df, 1);
   in_df._x = 100;
   in_df._y = 50;
   _root.createClassObject(mx.controls.DateField, out_df, 2);
   out_df._x = 100;
   out_df._y = 150;
   // load disabled dates into datiefields
   in_df.disabledRanges = [disabledDates];
   out_df.disabledRanges = [disabledDates];
   trace(disabledDates);
};
myXml_xml.load('results03.xml');

It just doesn't disable anything.

Thanks, JD
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Properly embedding flash with html.

2008-02-03 Thread Vlado Krempl
Hello everyone,

Question:
When embedding a flash movie in HTML - 
Is everyone using the Publish settings that flash CS3 comes with  
AC_RunActiveContent.js etc or 
is the SWF OBject still the preferred way?

Cheers,

Vlado Krempl 
M 0433 781740 
Please consider the environment before printing this e-mail. 
The contents of this message should be treated as COMMERCIAL IN CONFIDENCE 
unless otherwise specified in the message
and is intended solely for the use of the individual or entity to whom it is 
addressed.
If you have received this email in error please notify the sender. If you are 
not the named addressee you should not disseminate, distribute or copy this 
e-mail.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders