Hello,
I'm having some strange luck in building an image slide show. I load the image paths into an array from an XML
page and then step through the array elements w/ forward and back buttons.
I have an empty image clip on the stage where I create an empty movie clip inside each time a new image is loaded. I load the
image into the second movie clip like this:
The load_movie_and_stop function is as follows:
After the image is loaded into the movie clip, I then resize the image to be a specific width.
The image resizing is done w/ this function:
Now, 98% of the time this works perfectly, but there is some certain times where the image resizing is completely ignored and the image gets loaded as it's normal size.
Can anyone see why the image sizing get's ignored in some instance?
Thanks for any help,
Clem
I'm having some strange luck in building an image slide show. I load the image paths into an array from an XML
page and then step through the array elements w/ forward and back buttons.
I have an empty image clip on the stage where I create an empty movie clip inside each time a new image is loaded. I load the
image into the second movie clip like this:
Code:
_root.picsPage_mc.mc_pic_loader.mc_individual_pic_loader.unloadMovie();
_root.picsPage_mc.mc_pic_loader.createEmptyMovieClip( 'mc_individual_pic_loader', 1 );
_root.load_movie_and_stop( _root.picsPage_mc.mc_pic_loader.mc_individual_pic_loader, _root.photo_array[_root.photo_index].image, _root.picsPage_mc.mc_pbar, 'regular_load');
The load_movie_and_stop function is as follows:
Code:
function load_movie_and_stop( target_mc:MovieClip, movie_clip_to_load:String, p_bar:MovieClip, action:String )
{
mc_loader._width = 0;
mc_slider_bar.mc_drag_pan._x = 0;
if( action != 'simple_load' )
{
p_bar._visible = true;
p_bar.bar._width = 0;
}
var mclListener:Object = new Object();
mclListener.onLoadStart = function( target_mc )
{
if( action != 'simple_load' && action != 'regular_load' ){ target_mc.stop(); }
if( action == 'load_and_play' ){ target_mc.play(); }
}
mclListener.onLoadInit = function( target_mc )
{
_root.resize_movie_clip(target_mc, 160, 120, 250, 190);
if( action == 'load_and_stop' ){ target_mc.stop(); }
}
mclListener.onLoadProgress = function( target_mc )
{
if( action != 'simple_load' )
{
percentLoaded = Math.floor( ( target_mc.getBytesLoaded()/target_mc.getBytesTotal() )*100);
p_bar.bar._xscale = percentLoaded;
p_bar.txt_percent = percentLoaded + "% loaded.";
}
}
mclListener.onLoadComplete = function( target_mc ){ p_bar._visible = false; }
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.addListener(mclListener);
my_mcl.loadClip( movie_clip_to_load, target_mc );
}//___endFunc___
After the image is loaded into the movie clip, I then resize the image to be a specific width.
The image resizing is done w/ this function:
Code:
function resize_movie_clip(clip_loader_name:MovieClip, max_width:Number, max_height:Number )
{
orig_width = clip_loader_name._width;
orig_height = clip_loader_name._height;
aspect_ratio = orig_width / orig_height;
if( (orig_width > max_width) || ( orig_height > max_height ) ) // If either dimension is too big...
{
if( orig_width > orig_height ) // For wide images...
{
new_width = max_height;
new_height = new_width / aspect_ratio;
}
else if( orig_width < orig_height )
{
new_height = max_height;
new_width = new_height * aspect_ratio;
}
else if( orig_width == test_height )
{
new_width = max_width;
new_height = max_width;
}
else { trace( "Error reading image size."); return false; }
}
else { new_width = orig_width; new_height = orig_height; }
clip_loader_name._width = Math.round(new_width);
clip_loader_name._height = Math.round(new_height);
};
Now, 98% of the time this works perfectly, but there is some certain times where the image resizing is completely ignored and the image gets loaded as it's normal size.
Can anyone see why the image sizing get's ignored in some instance?
Thanks for any help,
Clem