You could use a movie clip loader too.
Code below:
init();
function init(){
trace("code init");
this.createEmptyMovieClip("holder", this.getNextHighestDepth());
this.imageLoader = new MovieClipLoader();
this.imageLoader.addListener(this);
loadImg("MyImageName.jpg");
}
function loadImg(src:String):Void{
this.imageLoader.loadClip(src, this.holder);
}
function onLoadStart(target:MovieClip){
target._xscale = target._yscale = 50;
}
function onLoadInit(target:MovieClip){
var maxWidth = 163;
if (this._width > maxWidth)
{
scaleFactor = maxWidth / target._width;
trace("Scale Factor : "+scaleFactor);
this._xscale = Math.floor (100 * scaleFactor);
this._yscale = Math.floor (100 * scaleFactor);
}
}
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of MJorge
Sent: Wednesday, February 08, 2006 6:54 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Dynamic width of image...
I had to go with another solution...
I have the same code at my Clip but now i have it at my lybrary and i´m
using attachMovie to load it to my stage...
Thanks.
On 2/8/06, Éric Thibault <[EMAIL PROTECTED]> wrote:
>
> And if you rescale the emptyclip back to 100% before loading another
> image...
>
>
> :-)
>
> Eric.
>
> MJorge wrote:
>
> >I know that my approach is working, the prob is that i have a button to
> load
> >another image to the clip. That´s when all the problems come...
> >
> >The width value is not respected anymore. That´s my prob.
> >
> >
> >
> >On 2/8/06, erixtekila <[EMAIL PROTECTED]> wrote:
> >
> >
> >>_xscale and _yscale should be your friends.
> >>Your approach is good btw.
> >>
> >>
> >>
> >>>I am loading dynamically some images to a emptyClip. The images have
> >>>different width anh height values each one. What i wanted is that my
> >>>Clip
> >>>(or image after loading) had a maximum width of 163....
> >>>
> >>>I am using this code at my Clip but it´s not working correctly. Can
> >>>anyone
> >>>help?
> >>>
> >>>onClipEvent (data) {
> >>> maxWidth = 163;
> >>> if (this._width > maxWidth)
> >>> {
> >>> scaleFactor = maxWidth / this._width;
> >>> this._width = Math.floor (this._width * scaleFactor);
> >>> this._height = Math.floor (this._height * scaleFactor);
> >>> }
> >>>}
> >>>
> >>>
> >>>
> >>-----------
> >>erixtekila
> >>http://blog.v-i-a.net/
> >>
> >>_______________________________________________
> >>Flashcoders mailing list
> >>[email protected]
> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> >>
> >>
> >
> >
> >
> >--
> >------------------------------------------------------------
> >Mário Jorge
> >Icq: 164987050
> >Msn + Mail: [EMAIL PROTECTED]
> >Web: http://www.beedigital.net
> >Blog: http://www.beedigital.net/blog
> >_______________________________________________
> >Flashcoders mailing list
> >[email protected]
> >http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> >
> >
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
--
------------------------------------------------------------
Mário Jorge
Icq: 164987050
Msn + Mail: [EMAIL PROTECTED]
Web: http://www.beedigital.net
Blog: http://www.beedigital.net/blog
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders