RE: [Flashcoders] Image resizer that maintains ratio
Would that optimize it? I could be wrong but I thing both these version's would compile to the same byte code. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: 29 March 2007 01:52 To: [email protected] Subject: RE: [Flashcoders] Image resizer that maintains ratio mc._width = maxW; mc._height = maxH; (mc._xscale > mc._yscale) ? mc._xscale = mc._yscale : mc._yscale = mc._xscale; > You could probably optimize a little bit by removing the Math > function... > > mc._width = maxW; > mc._height = maxH; > if ( mc._xscale > mc._yscale ) { > mc._xscale = mc._yscale; > } > else { > mc._yscale = mc._xscale; > } > > I don't think I can be done more effiently than that. Anyone? ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Image resizer that maintains ratio
mc._width = maxW;
mc._height = maxH;
(mc._xscale > mc._yscale) ? mc._xscale = mc._yscale : mc._yscale =
mc._xscale;
> You could probably optimize a little bit by removing the Math
> function...
>
> mc._width = maxW;
> mc._height = maxH;
> if ( mc._xscale > mc._yscale ) {
> mc._xscale = mc._yscale;
> }
> else {
> mc._yscale = mc._xscale;
> }
>
> I don't think I can be done more effiently than that. Anyone?
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
RE: [Flashcoders] Image resizer that maintains ratio
You could probably optimize a little bit by removing the Math function...
mc._width = maxW;
mc._height = maxH;
if ( mc._xscale > mc._yscale ) {
mc._xscale = mc._yscale;
}
else {
mc._yscale = mc._xscale;
}
I don't think I can be done more effiently than that. Anyone?
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Hans Wichman
Sent: 27 March 2007 16:06
To: [email protected]
Subject: Re: [Flashcoders] Image resizer that maintains ratio
ok, thanks joe for the explanation. Seems a lot of static / redundancy is
being generated by what you describe.
On 3/27/07, Joe Wheeler <[EMAIL PROTECTED]> wrote:
>
> I think the problem is the length of time it's taking for post to appear.
> Some of my posts have been going missing for a long time before
> showing up.
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Hans
> Wichman
> Sent: 27 March 2007 08:23
> To: [email protected]
> Subject: Re: [Flashcoders] Image resizer that maintains ratio
>
> The more I read these post, the more I wonder whether people actually
> read what others have already replied.
>
> On 3/26/07, Joe Wheeler <[EMAIL PROTECTED]> wrote:
> >
> > Here's how I do it:
> >
> > function maintainAspect ( mc:MovieClip, maxW:Number, maxH:Number )
> > :Void {
> >mc._width = maxW;
> >mc._height = maxH;
> >mc._xscale = mc._yscale = Math.min( mc._xscale, mc._yscale );
> > }
> >
> >
> >
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of
> > Guilherme Cruz
> > Sent: 26 March 2007 18:15
> > To: [email protected]
> > Subject: Re: [Flashcoders] Image resizer that maintains ratio
> >
> > The "_scale" property is a percentage value if you have a 800x600
> > image and set _xscale=50 and _yscale=50, you get a 400x300 image
> >
> >
> >
> >
> > On 3/26/07, Hans Wichman < [EMAIL PROTECTED]> wrote:
> > >
> > > Hi,
> > > that IS weird, because if your image is 800x600, you are saying:
> > >target_mc._xscale = target_mc._yscale = 800;
> > >
> > > which is probably not what you want^^
> > >
> > > greetz
> > > JC
> > >
> > >
> > > On 3/26/07, eric e. dolecki <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Ok that is SO weird. I was just thinking about this...
> > > >
> > > > myListener.onLoadInit = function( target_mc:MovieClip ):Void {
> > > >target_mc._xscale = target_mc._yscale = Math.max(
> > > > target_mc._width, target_mc._height ); };
> > > >
> > > > - Eric
> > > >
> > > >
> > > > On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > Any examples out there?
> > > > >
> > > > > I've got as far as resizing a user supplied image and am about
> > > > > to work
> > > > on
> > > > > the ratio remaining fixed. Just thought I'd throw this out
> > > > > there as I think it may be tricky.
> > > > >
> > > > > Ta.
> > > > >
> > > > > Adrian
> > > > >
> > > > > ___
> > > > > [email protected] To change your subscription
> > > > > options or search the archive:
> > > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > > > >
> > > > > Brought to you by Fig Leaf Software Premier Authorized Adobe
> > > > > Consulting and Training http://www.figleaf.com
> > > > > http://training.figleaf.com
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > eric e. dolecki
> > > > senior interactive engineer
> > > > http://www.ericd.net
> > > > ___
> > > > [email protected] To change your subscription
> > > > options or search the archive:
> > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > > >
> > > > Brought to you by Fig Leaf Software Premier Authorized Adobe
> > > > Consulting and Training http://www.figleaf.com
> > > > http://training.figleaf.com
> > >
Re: [Flashcoders] Image resizer that maintains ratio
ok, thanks joe for the explanation. Seems a lot of static / redundancy is being generated by what you describe. On 3/27/07, Joe Wheeler <[EMAIL PROTECTED]> wrote: I think the problem is the length of time it's taking for post to appear. Some of my posts have been going missing for a long time before showing up. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hans Wichman Sent: 27 March 2007 08:23 To: [email protected] Subject: Re: [Flashcoders] Image resizer that maintains ratio The more I read these post, the more I wonder whether people actually read what others have already replied. On 3/26/07, Joe Wheeler <[EMAIL PROTECTED]> wrote: > > Here's how I do it: > > function maintainAspect ( mc:MovieClip, maxW:Number, maxH:Number ) > :Void { >mc._width = maxW; >mc._height = maxH; >mc._xscale = mc._yscale = Math.min( mc._xscale, mc._yscale ); } > > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Guilherme Cruz > Sent: 26 March 2007 18:15 > To: [email protected] > Subject: Re: [Flashcoders] Image resizer that maintains ratio > > The "_scale" property is a percentage value if you have a 800x600 > image and set _xscale=50 and _yscale=50, you get a 400x300 image > > > > > On 3/26/07, Hans Wichman < [EMAIL PROTECTED]> wrote: > > > > Hi, > > that IS weird, because if your image is 800x600, you are saying: > >target_mc._xscale = target_mc._yscale = 800; > > > > which is probably not what you want^^ > > > > greetz > > JC > > > > > > On 3/26/07, eric e. dolecki <[EMAIL PROTECTED]> wrote: > > > > > > Ok that is SO weird. I was just thinking about this... > > > > > > myListener.onLoadInit = function( target_mc:MovieClip ):Void { > > >target_mc._xscale = target_mc._yscale = Math.max( > > > target_mc._width, target_mc._height ); }; > > > > > > - Eric > > > > > > > > > On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote: > > > > > > > > Any examples out there? > > > > > > > > I've got as far as resizing a user supplied image and am about > > > > to work > > > on > > > > the ratio remaining fixed. Just thought I'd throw this out there > > > > as I think it may be tricky. > > > > > > > > Ta. > > > > > > > > Adrian > > > > > > > > ___ > > > > [email protected] To change your subscription > > > > options or search the archive: > > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > > > Brought to you by Fig Leaf Software Premier Authorized Adobe > > > > Consulting and Training http://www.figleaf.com > > > > http://training.figleaf.com > > > > > > > > > > > > > > > > -- > > > eric e. dolecki > > > senior interactive engineer > > > http://www.ericd.net > > > ___ > > > [email protected] > > > To change your subscription options or search the archive: > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > Brought to you by Fig Leaf Software Premier Authorized Adobe > > > Consulting and Training http://www.figleaf.com > > > http://training.figleaf.com > > > > > ___ > > [email protected] > > To change your subscription options or search the archive: > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > Brought to you by Fig Leaf Software > > Premier Authorized Adobe Consulting and Training > > http://www.figleaf.com http://training.figleaf.com > > > ___ > [email protected] > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com http://training.figleaf.com > > ___ > [email protected] > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > B
RE: [Flashcoders] Image resizer that maintains ratio
I think the problem is the length of time it's taking for post to appear. Some of my posts have been going missing for a long time before showing up. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hans Wichman Sent: 27 March 2007 08:23 To: [email protected] Subject: Re: [Flashcoders] Image resizer that maintains ratio The more I read these post, the more I wonder whether people actually read what others have already replied. On 3/26/07, Joe Wheeler <[EMAIL PROTECTED]> wrote: > > Here's how I do it: > > function maintainAspect ( mc:MovieClip, maxW:Number, maxH:Number ) > :Void { >mc._width = maxW; >mc._height = maxH; >mc._xscale = mc._yscale = Math.min( mc._xscale, mc._yscale ); } > > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Guilherme Cruz > Sent: 26 March 2007 18:15 > To: [email protected] > Subject: Re: [Flashcoders] Image resizer that maintains ratio > > The "_scale" property is a percentage value if you have a 800x600 > image and set _xscale=50 and _yscale=50, you get a 400x300 image > > > > > On 3/26/07, Hans Wichman < [EMAIL PROTECTED]> wrote: > > > > Hi, > > that IS weird, because if your image is 800x600, you are saying: > >target_mc._xscale = target_mc._yscale = 800; > > > > which is probably not what you want^^ > > > > greetz > > JC > > > > > > On 3/26/07, eric e. dolecki <[EMAIL PROTECTED]> wrote: > > > > > > Ok that is SO weird. I was just thinking about this... > > > > > > myListener.onLoadInit = function( target_mc:MovieClip ):Void { > > >target_mc._xscale = target_mc._yscale = Math.max( > > > target_mc._width, target_mc._height ); }; > > > > > > - Eric > > > > > > > > > On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote: > > > > > > > > Any examples out there? > > > > > > > > I've got as far as resizing a user supplied image and am about > > > > to work > > > on > > > > the ratio remaining fixed. Just thought I'd throw this out there > > > > as I think it may be tricky. > > > > > > > > Ta. > > > > > > > > Adrian > > > > > > > > ___ > > > > [email protected] To change your subscription > > > > options or search the archive: > > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > > > Brought to you by Fig Leaf Software Premier Authorized Adobe > > > > Consulting and Training http://www.figleaf.com > > > > http://training.figleaf.com > > > > > > > > > > > > > > > > -- > > > eric e. dolecki > > > senior interactive engineer > > > http://www.ericd.net > > > ___ > > > [email protected] > > > To change your subscription options or search the archive: > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > Brought to you by Fig Leaf Software Premier Authorized Adobe > > > Consulting and Training http://www.figleaf.com > > > http://training.figleaf.com > > > > > ___ > > [email protected] > > To change your subscription options or search the archive: > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > Brought to you by Fig Leaf Software > > Premier Authorized Adobe Consulting and Training > > http://www.figleaf.com http://training.figleaf.com > > > ___ > [email protected] > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com http://training.figleaf.com > > ___ > [email protected] > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com http://training.figleaf.com > ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Image resizer that maintains ratio
The more I read these post, the more I wonder whether people actually read
what others have already replied.
On 3/26/07, Joe Wheeler <[EMAIL PROTECTED]> wrote:
Here's how I do it:
function maintainAspect ( mc:MovieClip, maxW:Number, maxH:Number ) :Void
{
mc._width = maxW;
mc._height = maxH;
mc._xscale = mc._yscale = Math.min( mc._xscale, mc._yscale );
}
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Guilherme
Cruz
Sent: 26 March 2007 18:15
To: [email protected]
Subject: Re: [Flashcoders] Image resizer that maintains ratio
The "_scale" property is a percentage value if you have a 800x600 image
and
set _xscale=50 and _yscale=50, you get a 400x300 image
On 3/26/07, Hans Wichman < [EMAIL PROTECTED]> wrote:
>
> Hi,
> that IS weird, because if your image is 800x600, you are saying:
>target_mc._xscale = target_mc._yscale = 800;
>
> which is probably not what you want^^
>
> greetz
> JC
>
>
> On 3/26/07, eric e. dolecki <[EMAIL PROTECTED]> wrote:
> >
> > Ok that is SO weird. I was just thinking about this...
> >
> > myListener.onLoadInit = function( target_mc:MovieClip ):Void {
> >target_mc._xscale = target_mc._yscale = Math.max(
> > target_mc._width, target_mc._height ); };
> >
> > - Eric
> >
> >
> > On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote:
> > >
> > > Any examples out there?
> > >
> > > I've got as far as resizing a user supplied image and am about to
> > > work
> > on
> > > the ratio remaining fixed. Just thought I'd throw this out there
> > > as I think it may be tricky.
> > >
> > > Ta.
> > >
> > > Adrian
> > >
> > > ___
> > > [email protected]
> > > To change your subscription options or search the archive:
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > Brought to you by Fig Leaf Software Premier Authorized Adobe
> > > Consulting and Training http://www.figleaf.com
> > > http://training.figleaf.com
> > >
> >
> >
> >
> > --
> > eric e. dolecki
> > senior interactive engineer
> > http://www.ericd.net
> > ___
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> ___
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
RE: [Flashcoders] Image resizer that maintains ratio
Here's how I do it:
function maintainAspect ( mc:MovieClip, maxW:Number, maxH:Number ) :Void
{
mc._width = maxW;
mc._height = maxH;
mc._xscale = mc._yscale = Math.min( mc._xscale, mc._yscale );
}
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Guilherme
Cruz
Sent: 26 March 2007 18:15
To: [email protected]
Subject: Re: [Flashcoders] Image resizer that maintains ratio
The "_scale" property is a percentage value if you have a 800x600 image and
set _xscale=50 and _yscale=50, you get a 400x300 image
On 3/26/07, Hans Wichman < [EMAIL PROTECTED]> wrote:
>
> Hi,
> that IS weird, because if your image is 800x600, you are saying:
>target_mc._xscale = target_mc._yscale = 800;
>
> which is probably not what you want^^
>
> greetz
> JC
>
>
> On 3/26/07, eric e. dolecki <[EMAIL PROTECTED]> wrote:
> >
> > Ok that is SO weird. I was just thinking about this...
> >
> > myListener.onLoadInit = function( target_mc:MovieClip ):Void {
> >target_mc._xscale = target_mc._yscale = Math.max(
> > target_mc._width, target_mc._height ); };
> >
> > - Eric
> >
> >
> > On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote:
> > >
> > > Any examples out there?
> > >
> > > I've got as far as resizing a user supplied image and am about to
> > > work
> > on
> > > the ratio remaining fixed. Just thought I'd throw this out there
> > > as I think it may be tricky.
> > >
> > > Ta.
> > >
> > > Adrian
> > >
> > > ___
> > > [email protected]
> > > To change your subscription options or search the archive:
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > Brought to you by Fig Leaf Software Premier Authorized Adobe
> > > Consulting and Training http://www.figleaf.com
> > > http://training.figleaf.com
> > >
> >
> >
> >
> > --
> > eric e. dolecki
> > senior interactive engineer
> > http://www.ericd.net
> > ___
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> ___
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
Re: [Flashcoders] Image resizer that maintains ratio
The "_scale" property is a percentage value
if you have a 800x600 image and set _xscale=50 and _yscale=50, you get a
400x300 image
On 3/26/07, Hans Wichman < [EMAIL PROTECTED]> wrote:
Hi,
that IS weird, because if your image is 800x600, you are saying:
target_mc._xscale = target_mc._yscale = 800;
which is probably not what you want^^
greetz
JC
On 3/26/07, eric e. dolecki <[EMAIL PROTECTED]> wrote:
>
> Ok that is SO weird. I was just thinking about this...
>
> myListener.onLoadInit = function( target_mc:MovieClip ):Void
> {
>target_mc._xscale = target_mc._yscale = Math.max( target_mc._width,
> target_mc._height );
> };
>
> - Eric
>
>
> On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote:
> >
> > Any examples out there?
> >
> > I've got as far as resizing a user supplied image and am about to work
> on
> > the ratio remaining fixed. Just thought I'd throw this out there as I
> > think
> > it may be tricky.
> >
> > Ta.
> >
> > Adrian
> >
> > ___
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
>
>
>
> --
> eric e. dolecki
> senior interactive engineer
> http://www.ericd.net
> ___
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
RE: [Flashcoders] Image resizer that maintains ratio
Ah nice one Jack. That's just what I was looking for. Will let you know how I get on. Adrian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jack Doyle Sent: 26 March 2007 15:59 To: [email protected] Subject: RE: [Flashcoders] Image resizer that maintains ratio This might be overkill, but feel free to use the TransformManager and/or TransformItem class(es) available at http://www.greensock.com/ActionScript/TransformManager. You can just set the constrainScale_boolean property to true. Jack Doyle -Original Message- Date: Mon, 26 Mar 2007 13:08:09 +0100 From: "Adrian Lynch" <[EMAIL PROTECTED]> Subject: [Flashcoders] Image resizer that maintains ratio To: "Flashcoders" Message-ID: <[EMAIL PROTECTED]> Any examples out there? I've got as far as resizing a user supplied image and am about to work on the ratio remaining fixed. Just thought I'd throw this out there as I think it may be tricky. Ta. Adrian ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Image resizer that maintains ratio
My scaleToFit function. Probably not the most awesome thing, but it does
the job
private function
scaleToFit(target:Object,clipRect:Rectangle,maintainAspect:Boolean){
var w:Number = clipRect.width;
var h:Number = clipRect.height;
var ratio:Number;
var scalew:Number;
var scaleh:Number;
if(target._width>w||target._height>h){
if(maintainAspect){
//height
ratio = target._width/target._height;
scalew = w;
scaleh = scalew/ratio;
if(scaleh>h){
//width
ratio = target._height/target._width;
scaleh = h;
scalew = scaleh/ratio;
}
}else{
scalew = w;
scaleh = h;
}
target._width = scalew;
target._height = scaleh;
}
}
eric e. dolecki wrote:
Ok that is SO weird. I was just thinking about this...
myListener.onLoadInit = function( target_mc:MovieClip ):Void
{
target_mc._xscale = target_mc._yscale = Math.max( target_mc._width,
target_mc._height );
};
- Eric
On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote:
Any examples out there?
I've got as far as resizing a user supplied image and am about to
work on
the ratio remaining fixed. Just thought I'd throw this out there as I
think
it may be tricky.
Ta.
Adrian
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
RE: [Flashcoders] Image resizer that maintains ratio
This might be overkill, but feel free to use the TransformManager and/or TransformItem class(es) available at http://www.greensock.com/ActionScript/TransformManager. You can just set the constrainScale_boolean property to true. Jack Doyle -Original Message- Date: Mon, 26 Mar 2007 13:08:09 +0100 From: "Adrian Lynch" <[EMAIL PROTECTED]> Subject: [Flashcoders] Image resizer that maintains ratio To: "Flashcoders" Message-ID: <[EMAIL PROTECTED]> Any examples out there? I've got as far as resizing a user supplied image and am about to work on the ratio remaining fixed. Just thought I'd throw this out there as I think it may be tricky. Ta. Adrian *** ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Image resizer that maintains ratio
Yup, sorry for being vague. It's the maintaining of the ratio while the user resizes that I'm after. A user uploads an image, I load this image into a container and force it to fit into a maximum and minimum width and height. Within this container the user can resize the image without expanding out of the container and all the time maintaining the original ratio. The resizing will be done by dragging an anchor point like this: http://www.adrianlynch.co.uk/temp/resizer.gif I have it working but it allows the image to be resized anyway the user chooses. I also need to make the anchor stick to the bottom right hand corner of the image. I think I will work this out eventually but I wanted to see if there was anything out there already that I could glean some ideas from. Thanks. Adrian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Danny Kodicek Sent: 26 March 2007 14:03 To: [email protected] Subject: RE: [Flashcoders] Image resizer that maintains ratio > Any examples out there? > > I've got as far as resizing a user supplied image and am > about to work on the ratio remaining fixed. Just thought I'd > throw this out there as I think it may be tricky. How are they resizing? Which bit is tricky? Maintaining an aspect ratio isn't too hard - you're just losing a degree of freedom from the user input. Danny ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Image resizer that maintains ratio
Hi,
that IS weird, because if your image is 800x600, you are saying:
target_mc._xscale = target_mc._yscale = 800;
which is probably not what you want^^
greetz
JC
On 3/26/07, eric e. dolecki <[EMAIL PROTECTED]> wrote:
Ok that is SO weird. I was just thinking about this...
myListener.onLoadInit = function( target_mc:MovieClip ):Void
{
target_mc._xscale = target_mc._yscale = Math.max( target_mc._width,
target_mc._height );
};
- Eric
On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote:
>
> Any examples out there?
>
> I've got as far as resizing a user supplied image and am about to work
on
> the ratio remaining fixed. Just thought I'd throw this out there as I
> think
> it may be tricky.
>
> Ta.
>
> Adrian
>
> ___
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
--
eric e. dolecki
senior interactive engineer
http://www.ericd.net
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
Re: [Flashcoders] Image resizer that maintains ratio
Ops.. //store original sizes originalWidth = myImage._width; originalHeight = myImage._height; //get the ratio finalRatio = originalWidth/500; myImage._width = originalWidth * finalRatio; myImage._height = originalHeight * finalRatio; ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Image resizer that maintains ratio
eg. if your original image size is 800x600 and you want it to be 500 x ? : (pseudo code) //store original sizes originalWidth = myImage._width; originalHeight = myImage._width; //get the ratio finalRatio = originalWidth/500; myImage._width = originalWidth * finalRatio; myImage._height = originalHeight * finalRatio; On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote: Any examples out there? I've got as far as resizing a user supplied image and am about to work on the ratio remaining fixed. Just thought I'd throw this out there as I think it may be tricky. Ta. Adrian ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Image resizer that maintains ratio
> Any examples out there? > > I've got as far as resizing a user supplied image and am > about to work on the ratio remaining fixed. Just thought I'd > throw this out there as I think it may be tricky. How are they resizing? Which bit is tricky? Maintaining an aspect ratio isn't too hard - you're just losing a degree of freedom from the user input. Danny ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Image resizer that maintains ratio
Ok that is SO weird. I was just thinking about this...
myListener.onLoadInit = function( target_mc:MovieClip ):Void
{
target_mc._xscale = target_mc._yscale = Math.max( target_mc._width,
target_mc._height );
};
- Eric
On 3/26/07, Adrian Lynch <[EMAIL PROTECTED]> wrote:
Any examples out there?
I've got as far as resizing a user supplied image and am about to work on
the ratio remaining fixed. Just thought I'd throw this out there as I
think
it may be tricky.
Ta.
Adrian
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
--
eric e. dolecki
senior interactive engineer
http://www.ericd.net
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

