PDA

View Full Version : Setting dynamic image width - need help !!!


Mo11
05-02-2004, 07:24 AM
Hello all,

I've been fighting with that for a while now, I've red all I could find but nothing seems to work...
I'm sure there's something I'm missing here.

my problem :

I'm loading pics (jpg) with loadMovie into movie clips that had just been created (createEmptyMovieClip). I want to set the size of the pics after they've bee loaded.

here's the code:
for (i=1;i<=myData.count;i++)
{
name = "holder" + i;
//create a empty movie clip for holding the Jpg pics
createEmptyMovieClip(name, i);
eval(name).loadMovie("../../images/prods/thumb/" + eval("myData.pic" + i));
eval(name)._x = 80*i;
eval(name)._y = 120*i;
eval(name).onEnterFrame = function()
{
if (eval(name)._width > 0)
{
eval(name)._width=50;
delete eval(name).onEnterFrame;
}
}
}
I know you should wait for the pic to be loaded before you can acces the _width property, but I think that tha's what I'm doing ...

any help would be greatly apreciated.

Thanks in advance,

Billy T
05-02-2004, 07:54 AM
does the eval(name) bit work? try putting in some traces

also try

eval(name).onEnterFrame = function()
{
if (this._width > 0)
{
this._width=50;
delete this.onEnterFrame;
}
}

Mo11
05-02-2004, 07:58 AM
Hey Billy T,

Thanks for your reply. I'll try to do as you suggested.

Apparently, the eval(name) works because the pictures are loading, and the positionning is well done.

The only thing I don't manage to do is to resize the pictures (the movieclip)...

Mo11
05-02-2004, 08:02 AM
just tried :
eval(name).onEnterFrame = function()
{
if (this._width > 0)
{
this._width=50;
delete this.onEnterFrame;
}
}
doesn't work ...

any other sudggestions?

pom
05-02-2004, 08:24 AM
You can't use the container clip as a preloader clip, because loading erases everything in your clips, including the onEnterFrame (that's my guess anyway). Try this: if I'm right, it shouldn't trace anything (if I'm wrong, I'll just go back to pottery).for (i=1;i<=myData.count;i++)
{
name = "holder" + i;
//create a empty movie clip for holding the Jpg pics
var clip = this.createEmptyMovieClip(name, i);
clip.loadMovie("../../images/prods/thumb/" + eval("myData.pic" + i));
clip._x = 80*i;
clip._y = 120*i;
clip.onEnterFrame = function()
{
trace ("Hello, my name is " + this._name) ;
if (this._width > 0)
{
this._width=50;
delete this.onEnterFrame;
}
}
}pom :)