Groups | Blog | Home
all groups > flash (macromedia) > april 2007 >

flash (macromedia) : accessing dynamic created clips


chironisis
4/15/2007 8:43:19 PM

I am having trouble accessing the clips for applying actions.

photAmount, thumb1xpo, thumb1ypo, sm_photo are variables.
thumbLdr is a mc holding the mc's which are created. I know they are being
created as they show their respective pics. I just can't seem to apply any
actions to them.

Thanks





var i:Number;
for (i = 1; i < photAmount; i++)
{
_root.thumbLdr.createEmptyMovieClip ("thumb" + i, i);
_root.thumbLdr["thumb" + i]._x = (i - 1) * thumb1xpo;
_root.thumbLdr["thumb" + i]._y = thumb1ypo;
_root.thumbLdr["thumb" + i].loadMovie (_root["sm_photo" + i]);
_root.thumbLdr["thumb" + i].onRelease = function(){
trace("release" + i);
};
}
mforsberg
4/15/2007 10:30:55 PM
When the image has been loaded into the clip you're loading it to, that clip
will reset any actions applied to it. two ways to solve this:

1. Apply the action when the image has been fully loaded to the clip. This
would require a pulse (either an onenterframe or interval) that checks to see
when the movieclip has been fully loaded (getBytesLoaded()>=getBytesTotal(), or
in your case, a simple and actually more safe way would be checking _width>0).

2. Load that image into a holder clip within the holder, in other words:
...
_root.thumbLdr.createEmptyMovieClip ("thumb" + i, i);
_root.thumbLdr["thumb" + i]._x = (i - 1) * thumb1xpo;
_root.thumbLdr["thumb" + i]._y = thumb1ypo;
_root.thumbLdr.thumb.createEmptyMovieClip ("imageholder", 1);
_root.thumbLdr["thumb" + i].thumb.loadMovie (_root["sm_photo" + i]);
_root.thumbLdr["thumb" + i].onRelease = function(){
trace("release" + i);
};
...

I would definately go for option nr 2 in your case :)
chironisis
4/15/2007 11:09:16 PM
MANY MANY THANKS!!!!

AddThis Social Bookmark Button