Movie Clip Resize Not Working When Image Is Loaded
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:
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
SitePoint > Design Your Site > Flash and Actionscript
Posted on: Oct 26, 2007, 07:31
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Movie Clip Resize Not Working When Image Is Loaded
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:
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
Movie Clip Resize Not Working When Image Is Loaded
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:
[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');
[/code]
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___
[/code]
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);
};
[/code]
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
Movie Clip Resize Not Working When Image Is Loaded
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:
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
Movie Clip Resize Not Working When Image Is Loaded
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:
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');
How Do I Resize Image Loaded In A Movie Clip ?
Hi All,
I'm facing to an annoying problem with flash, I'm trying to resize an image loaded in a movie clip, so that any image I load will always fit correctly in my movie.
The script is pretty simple, it reads an xml file where they should be 6 records. Loads the image in the Thumb attribute in on of the 6 containers eg. _root.screen.Event1
Code:
for (i=0; i < 6; i++){
MyEvent = Event[i].attributes ;
_root.screen["Event"+i].Title.text = MyEvent.Title ;
_root.screen["Event"+i].Date.text = MyEvent.Date ;
_root.screen["Event"+i].Description.text = MyEvent.Description ;
loadMovie(MyEvent.Path+MyEvent.Thumb,_root.screen["Event"+i].Thumb);
redim(100,100,_root.screen["Event"+i].Thumb);
}
As you can see I try to resize the movie clip directly by using this function :
Code:
function redim(maxheight,maxwidth,clip){
if (clip._height > maxheight) {
ratio = clip._height / maxheight;
clip._height = clip._height / ratio;
clip._width = clip._width / ratio;
}
if (clip._width > maxwidth ) {
ratio = clip._width / maxwidth;
clip._height = clip._height / ratio;
clip._width = clip._width / ratio;
}
}
It works but not as expected. It looks like only the container is scaled down not the image really.
How Can I achieve my goal ?
Regards,
Vde
Resize Not Working On Loaded Image?
I'm trying to dynamically create a mc, load an image, place it on the stage and resize it. It works fine until I add the 2 lines to set the width & height of the image.
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
loadMovie("someFile.jpg", image_mc);
image_mc._x = 150;
image_mc._y = 150;
//problem lines
image_mc._width = 50;
image_mc._height = 50;
With this code, the image never appears. If I comment out the last two lines, the image appears full-size. If I put those 2 lines on a button and click it after the mc is created, it works. Is it because the image might not be loaded yet? Doesn't seem to be, since I can trace the height and width right after the loadMovie line??
Thanks!!
How To Resize Clip To Loaded Image
hi all
sorry for my english. it's not my native
so i have flash clip and every time when i call clip in HTML page
i send into clip path to jpg file
and inside clip i need to load this image file to movie (loadMovie(blablabla))
so all images have different size for examle one 100x200px another 150x300px
i need that in html page flash clip have the same size as loaded image
if i just set "image" size for flash clip when i call flash clip in HTML
Image inside clip don't have correct size
is question clear or not?
as example - on www.ofoto.com crop effect made like this
the same flash clip always have size like loaded JPG and it looks correctly
Preloader In Externally Loaded Swf Stops Working (loaded Into An Empty Movie Clip)
SEE BOTTOM OF THREAD FOR CURRENT PROBLEM
1. I have my navigation buttons in level0
2. When a button is pressed it loads an external .swf into the highest empty level
3. There is an MC in this loaded .swf called loadmovie and inside that another MC called empty.
4. Inside the 'loadmovie' MC, there is a frame action that loads another external .swf file into the 'empty' MC.
The problem I am having is that the preloader that is on the external .swf that is loaded into the 'empty' MC does not work.
It works fine if you test it on its own. But not when loaded into a Movie Clip.
MY SCRIPT:
iBytesTotal = _root.getBytesTotal();
iBytesLoaded = _root.getBytesLoaded();
iBytes = (iBytesLoaded/iBytesTotal)*100;
percentageNumber = Math.round(iBytes)+"%";
setProperty("progressBar", _xscale, iBytes);
Do I have to refrence it differently? Because of where it is situated?
e.g
iBytesTotal = _level32._root.loadmovie.empty.getBytesTotal();
confesed!
Auto Resize Image To Movie Clip Size?
How can i make a movieclip load an external .jpg image and resize the image to fit the moviclip? or set the image to a certain size like 50x50 pixels? The movieclip is called "image".
I've put the code below inside the moveclip on frame 1 and that loads the image, but how can i resize it?
Code:
this.loadMovie("pic1.jpg");
Thanks
Form Mailer Not Working When Loaded Into Movie Clip
I followed this tutorial for a form mailer http://www.kirupa.com/developer/acti..._php_email.htm and it works great. However when I try to load this from my main swf into a movie clip holder, it no longer works. It only wants to work by itself, im a novice at flash/actionscript but im wondering if this is causing the problem by trying to get to the root of my main movie instead of the actual mailer.swf?
onClipEvent(data){
_root.nextFrame();
}
Form Mailer Not Working When Loaded Into Movie Clip
I followed this tutorial for a form mailer http://www.kirupa.com/developer/acti..._php_email.htm and it works great. However when I try to load this from my main swf into a movie clip holder, it no longer works. It only wants to work by itself, im a novice at flash/actionscript but im wondering if this is causing the problem by trying to get to the root of my main movie instead of the actual mailer.swf?
onClipEvent(data){
_root.nextFrame();
}
How To Prevent Image From Scaling When Loaded Into Movie Clip
I loaded some image into a movie clip on the stage, but when I load the image (which is larger than the size of the movie clip) it expands to it's full size. How do I make it so the image stays within the movie clip and doesn't scale? Thanks.
Attach Code
var myLoader:Loader = new Loader();
var url:String = "image.jpg";
var urlReq:URLRequest = new URLRequest(url);
myLoader.load(urlReq);
imageHint_mc.addChild(myLoader);
//imageHint_mc.height = 152.0; //
this doesn't work
//imageHint_mc.width = 235.9; //
this doesn't work
Dynamically Loaded Image ..border And Center Of Movie Clip
Hi all,
I am working on a image gallery where i am loading the images from xml. Now my problem is On click of the thumbnails a larger image should load...I like to give a outline to the image based on the orientation horizontal and vertical and should fit to the image loaded.
I am using the following script to load images.
/*Scrip starts here*/
import flash.filters.DropShadowFilter;
var dropShadow:DropShadowFilter = new DropShadowFilter(3, 45, 0x000000, 0.4, 7, 7, 2, 3);
big1.frm.filters = [dropShadow];
big1._visible = 0;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
th = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
th = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
}
loadmc(); // will assign the th to the movie clip name th_loader//
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
Any help will be appreciated.
Thanks & Regards,
kakas
Centering A Dynamically Loaded Image File In A Movie Clip
Hi all,
I followed a tutorial on kirupa.com (this is the link to the tutorial http://www.kirupa.com/developer/mx2004/thumbnails.htm)
I've learned from that and created my own image gallery, the only problem is that when the image loads, it loads to the top left, so my image hangs off the side of the page.
All my images are different sizes, so i firstly need the thumbnail pannel to recognise the size of each thumbnail and bunch them up centre aligned (on the horizontal axis) so that there are no massive black gaps in between.
Second, i need the image in the main 'picture' movie clip to aligne to the centre registration point instead of its top left corner aligning to the reg point.
This is the code that I am using at the moment
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
picname = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
picname [i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
thumbnails_fn(i);
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
//
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
//
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
name_txt.text = picname [p];
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
name_txt.text = picname [p];
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
name_txt.text = picname [0];
}
}
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 5;
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._heig ht)) {
if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}
I understand that this is all about timing or somethign as the image has to load before it can be centered. But this is starting to annoy me now.
I've seen some topics on this on other pages, but they make no sense... i need to know where the code goes and how it works etc... i'm not a total actionscript wizz (as you might have noticed).
This is the rough layout of the scene if you need it.
On the left is two dynamic text boxes which load with the information for the image, then all the way along the bottom is the thumbnail slider with the image box beign at the right of the stage.
In time i'd like to put effects and more animated things on the gallery, but right now i just need to get this sorted before it drives me totally mad.
thanks
Desperately needing help
CI
Resize Bounding Box After Image Is Loaded
I am developing a gallery and am really close to being done... I am using the movie clip loader class to determine when the image is fully loaded before fading it in. Below is the code I have for the image border to resize...however, it does not transition to it (http://www.rainnetworks.com/betasites/rn/gallery/ )... anyone with thoughts?
Attach Code
function onLoadInit(_mc:MovieClip) {
w = _mc._width;
h = _mc._height;
//check to see if the border width & height are the same
if(imgBorder._width != w){
imgBorder._width = Math.round(imgBorder._width +(w - imgBorder._width)*.9);
}
if(imgBorder._height != h){
imgBorder._height = Math.round(imgBorder._height +(h - imgBorder._height)*.9);
}
};
Resize MC Based On Loaded Image...
Hi all,
I'm not really sure how this works but I've seen a lot of examples online. There is a gallery in which a black background resizes and an image of the same aspect ratio loads on top of it. When a new image is selected, the background changes shape to accomodate the new dimensions.
Any direction would be greatly appreciated. Thanks in advance!
Woody
Loaded Image Resize Problem
Hi,
I am loading a jpg into an empty movieClip. The jpg is 300X300 pixels. However, when I test my movie, the dimensions are distorted and the jpg looks more like 150x300. I've made the empty movieClip 300x300 also. I've tried coding the image dimensions after it is loaded, setting the image width and height to 300 doesn't fix the problem. Why is Flash distorting the image?
Thanks
This Shouldn't Be Too Difficult - Resize Loaded Image
I'm loading several images inside a frame, but the images will have different aspect ratios. My goal is to load all images so that the width or height does not exceed the frame.
The 'difficult' part is to maintain the aspect ratio of the image.
Does anyone have a script I can work with? I'm not aware of any _scale function that scales both the height and width of an image (so the aspect ratio is maintained), something like that would be usefull!
Thanks in advance.
Resize Loaded Image To The Size Of The Constantly Resized Container
Hi all!
Here's my problem:
I have a function that redraws the container clip every frame. While the function is running I need to download an image inside the container and to resize the image to the size of the container. The particular problem is that if the picture is bigger than the container, when it'll be downloaded the size of the container will be the same that of the picture.
Here's a simplified code:
Code:
var MCL:MovieClipLoader = new MovieClipLoader();
var MCLL:Object = {};
MCLL.onLoadComplete = function(mc:MovieClip){
/*
When this is called, the mc's width and height are 0
*/
}
MCL.addListener(MCLL);
var container:MovieClip = _root.createEmptyMovieClip("container", 0);
container.h=5;
container.w=5;
_root.onEnterFrame = function(){
container.clear();
container.beginFill(0, 100);
container.moveTo(0, 0);
container.lineTo(container.w, 0);
container.lineTo(container.w, container.h);
container.lineTo(0, container.h);
container.lineTo(0, 0);
container.endFill();
container.w+=5;
container.h+=5;
}
MCL.loadClip(container, "image.jpg");
Thank you for any help.
Display Part Of Loaded Image (crop/resize Without Mask)
Ok. My first thread... Hope someone can help.
I'm trying to display thumbnails in an image gallery. The new thumbs I create are 37x37 pixels large and I load these dynamically into the movie using loadMovie().
I would like to be able to use the thumbs I've created for previous galleries (larger non-square thumbs). I know how to resize the thumbs to fit the area (37x37) but I don't want them to get stretched or squeezed. I would simply like to show the part of these thumbs that fits within the area.
I know I could use a mask of 37x37 pixels and apply it to the thumb but I would like to avoid this as I have a lot going on... Anyone know an easy/another way to do this?
/erik
Resize A Dynamicaly Loaded Image Of X Hieght And Width Any Idea
Resize a Dynamicaly Loaded Image of x hieght and width !!!! Any idea !!!!
Hi guys, i need ur head and hands
I need to resize a dynamicaly loaded image, keeping there aspect ratio, ... when the size of the image can be any thing
Like u load an image in an html frame and the image gets adjusted according to the frame with the same aspect ratio..
Any ideas ?
Resize A Dynamicaly Loaded Image Of X Hieght And Width Any Idea
Resize a Dynamicaly Loaded Image of x hieght and width !!!! Any idea !!!!
Hi guys, i need ur head and hands
I need to resize a dynamicaly loaded image, keeping there aspect ratio, ... when the size of the image can be any thing
Like u load an image in an html frame and the image gets adjusted according to the frame with the same aspect ratio..
Any ideas ?
Resize A Dynamicaly Loaded Image Of X Hieght And Width Any Idea
Resize a Dynamicaly Loaded Image of x hieght and width !!!! Any idea !!!!
Hi guys, i need ur head and hands
I need to resize a dynamicaly loaded image, keeping there aspect ratio, ... when the size of the image can be any thing
Like u load an image in an html frame and the image gets adjusted according to the frame with the same aspect ratio..
Any ideas ?
Function Not Working After Clip Is Loaded, Unloaded And Then Loaded Again
I have a Movie Clip in my Library that I'm loading on to my stage using the attachMovie command. Within that movie clip, I have actions set on the first frame.
From the root level of my movie, I call "profile-section" clip by pressing a button in my nav and it loads properly and works. The functions and handlers all work correctly within it. Then when I press another button from the root level, I have code to removeMovieClip. That works and removes the "profile-section" clip.
My problem is when i click on the button to re-load the "profile-section", the function doesn't work properly anymore. I'm attaching the function for you guys to look over. Any help would be greatly appreciated. Thanks.
//
// Variables
//
var speed = 3;
//
// Sub-Section Rollover Red Bar Function
//
function subSectionRollOverLoop(movieClip, speed, distance, callBack):Void {
if (speed > 0 && movieClip._width <= distance) {
movieClip._width += speed;
} else if (speed < 0 && movieClip._width >= distance) {
movieClip._width += speed;
} else if (movieClip.__interval) {
clearInterval(movieClip.__interval);
movieClip.__interval = 0;
if (callBack) {
callBack(movieClip, speed, distance);
}
}
}
function subSectionRollOverStart(movieClip, speed, distance, callBack):Void {
if (movieClip.__interval) {
clearInterval(movieClip.__interval);
movieClip.__interval = 0;
}
movieClip.__interval = setInterval(subSectionRollOverLoop, 10, movieClip, speed, distance, callBack);
}
joan_btn.onRollOver = joan_btn.onDragOver = function ():Void {
subSectionRollOverStart(joanRoll_mc, 30, 140);
};
Input Text In A Clip That Is Loaded Inside Another Clip Not Working
Hello,
I have an input text field inside a clip that works as it should but when I load that same clip inside a parent clip I am unable to edit the input text, and any text that I had inside it doesn't display.
This occurs even when I use just plain _serif fonts instead of the embedded fonts from my library. I'm not sure if this is a font issue or if it's a limitation of flash, and i'm seeing the same sort of thing happen with a compiled component that I downloaded.
I'm compiling for Flash player 7 and AS 2.0 using MX 2004 7.2
I would greatly appreciate your suggestions, (god willing) fixes. I am about to pull my hair out...
Cheers,
Drew
Need To Resize Loaded Movie
I'm modifying a template created using AS1. I have a SWF that I load into the index page using LoadMovie, and it works fine. (This alone surprises me because the loaded SWF was created using AS3.) But I digress. The loaded SWF is too large. I have the original FLA file. I need to resize the dimensions of that SWF preferable after I load it in using LoadMovie, but I'll resize it beforehand if I have to. I also need to change the coordinates of the loaded SWF. How? Any help appreciated.
How Do I Resize An External Loaded Movie?
Hey, I'm working with a friend to put a video function in his flash site. I can load an external video file from youtube (we want it to run through that for bandwidth reasons, and youtube has a fully functional video preloader and such).
The only problem is, we need to resize it >.>
The file location is "http://www.youtube.com/v/o091EpFTVn0" i can use a simple loadMovieNum("http://www.youtube.com/v/o091EpFTVn0", 1); function and it works, BUT the video is HUGE, and we want to scale it down to 320x240 or smaller.
I saw some "resize" function in flash but can't find a darn thing googling about it.
Can anyone tell me how to have flash resize the loadMovieNum command?
Strange Resize Of Loaded Movie Problem
I am loading an swf that was made with flash 8's video components into my main movie. The dimensions of the video are 640x520 but I want to scale this down a bit so I'm using a standard code to load the movie, fade it in and resize it. Now if I plug in a number like 480x320, it loads very small, not those dimensions at all! So look at the width&height in my code to see where I had to set this to make it work. It's set to 1800x400, why is this happening??
Code:
stop();
loadMovie("live1.swf", "_root.videoholder");
_root.videoholder._alpha = 0;
this.onEnterFrame = function(){
if(_root.videoholder.getBytesTotal() >= _root.videoholder.getBytesLoaded() && _root.videoholder.getBytesLoaded()>10000){
_root.videoholder._width = 1800;
_root.videoholder._height = 400;
if(_root.videoholder._alpha < 100){
_root.videoholder._alpha +=5;
} else {
_root.videoholder._alpha = 100;
delete this.onEnterFrame;
_root.play();
}
}
};
Thanks,
Mike
Loaded Swf Video Disappears On Movie Resize
My base flash movie loads a video (video1.swf) into level 1. When I resize the browser the video disappears but I can still hear the sound from it.
If you alter the browser size the base movie is set to alter accordingly, (the stage elements staying in relative positions). Have attached code in case needed.
Any ideas to keep the video displayed - or where it's gone? Thanks in advance if anyone can help.
Attach Code
Stage.scaleMode = "noScale";
Stage.align = "TL";
///////////REPOSITION ELEMENTS WHEN STAGE IS RESIZED////////////
this.onResize();
function onResize() {
newPosition();
}
Stage.addListener(this);
function newPosition() {
stageH = Stage.height;
stageW = Stage.width;
bkgrnd_mc._width = stageW;
bkgrnd_mc._height = stageH;
myMovieClip_mc._x = (stageW-myMovieClip_mc._width)/2;
myMovieClip_mc._y = (stageH-myMovieClip_mc._height)/2;
}
///////////////
myMovieClip_mc.onRelease = function() {
loadMovieNum("video1.swf", 1);
};
Sound Is Not Working In Loaded Clip
Hi.
I have this code in a swf and works fine...
ActionScript Code:
var radio:Sound = new Sound();
radio.attachSound("sound_id.mp3");
radio.start();
but when i load it into another swf it doesnt sound.
What could it be the problem?
thanks in advance
Setmask Not Working On Dynamil Loaded Image
hey guys hope you can help with this one.
I am loading in a dynamic image from an external file, now I am loading it into an existing movieclip btu when I do the masking on the MC doesn't work :S
PHP Code:
product_shadow.setMask(masker);
thats the code I am using to set the masker inside the MC, this code is contained in the movieclip itself
PHP Code:
loadMovie("padlock_big.png", _root.b0.product);
loadMovie("padlock_big.png", _root.b0.product_shadow);
thats the code that loads the images in, anyone know of a way to get this working?
Image Scroller Not Working When Loaded Externally
I used the Kirupa Image scroller turorial and modified it a bit , I am loading as an external SWF in to my main movie when you click that button. but it does not scroll once in side my main movie WHY WHY WHY.
I am thinking it has to do with _root and this. but I have been playing with it for so long it is driving me crazy
Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnails_fn(i);
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 10;
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+20)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
Any Ideas Please
Events Not Working With Dynamically Loaded Image
I have a script which dynamically loads an image into a empty movie clip in flash but I can not seem able to make it clickable. The code is as follows
ActionScript Code:
//create a new movieclip on the _root timeline
this.createEmptyMovieClip("mymovieclip",1);
loadMovie("stef.jpg","mymovieclip");
mymovieclip.onRelease = function() { trace("I've been clicked");}
normally the mouse pointer would change to indicate a clickable object but this does not happen.
I am finding this very frustrating and so any help or suggestions would be gratefully recieved.
Thanks
Phantom_web
Resize Movie Clip
well i have loaded an external swf into my movie but the external swf's size is larger than the host swf so it does'nt display nice.
i want to know how to resize the loaded movie clip to a smaller size so it will fit into a the host movie.
the external file is msft_logo.swf and the target to load to is _root.tv please help.
Resize Movie Clip Using A S
Hey guys,
i came across this problem while trying to resize Movie clip using _height or _yscale. When i am resizing movie clip it is resized both ways (up and down). In other words it keeps the center in the same spot and moves the bottom part down and top part up. Is there a way to make it resize only down/ only up.
_____
|_____|
Anyone Know Why I Can't Resize A Movie Clip?
I have a movie clip on the first frame of my flash document and when I go to transform it (to make it smaller - I'm using the constrain dialog box) and it's telling me that the dimensions are 200% x 200%.
when I go to resize, it wont let me make the movie clip any smaller ie; if I enter 125% x 125% and hit return or enter it actually filles in 250% automatically in the left (horizontal size) box.
I can make the movie clip larger without any problems. Anyone know what's going on here?
Resize A Movie Clip
I just want to know how I can make a button so that I can resize a movie clip that I made. If it is possible. The reason why I ask this is because I a few movie clips that will load on a web page, and I have them dragable, and you can close them, now all I want is to be able to resize them. (Make them smaller, and not any bigger then they are
Resize A Movie Clip
I just want to know how I can make a button so that I can resize a movie clip that I made. If it is possible. The reason why I ask this is because I a few movie clips that will load on a web page, and I have them dragable, and you can close them, now all I want is to be able to resize them. (Make them smaller, and not any bigger then they are
Resize Movie At Image Size (while Loading) ?
Hello you all...
I was wondering if there is a sample out there or if someone could help me out. I am trying to load a single image into a swf, while it loads the height and length of the movie will resize itself to the image. I want to use this for friend of my that loads his images up to his webpage without copyright protection but he really needs some...
Although I know something about actionscripting but this is going over my head for now... Still learning though!
Hopefully someone can help me out with this one i'd be greatly thankfull!
Many thanks in advance...
Dennis
Easy: Resize Movie Clip?
Hey guys,
All i'm trying to do is resize the movie clip after I add it (or before, if necessary). But in debug, it's width and height are still set to 0. Are movieclip.width and movieclip.height not the right commands to use? I also tried onResize() but it says that that's not a function....
heres the code:
Code:
var galBox:MovieClip = new MovieClip();
function drawImages(evt:Event):void
{
this.addChild (galBox);
galBox.x = 20;
galBox.y = 45;
galBox.width = 800;
galBox.height = 500;
var setx:uint = 0;
var sety:uint = 0;
for(var i:uint = 0; i < imageCount; i++)
{
this.galBox.addChild(imageArray[i]);
imageArray[i].x = setx;
imageArray[i].y = sety;
setx = setx + 125;
} //End for
} //End function drawImages
At the bottom there I'm just trying to add images that are stored in an Array. When I don't use the galBox instance, and add them directly to the stage, it works just dandy. But they don't show up in the galBox, which I'm assuming is because it has no width/height. Ideas? Seems like it should be real simple...
--L
Resize, Or Startdrag On Movie Clip
im trying to resize or setproperty on a mc from a small size to a larger size on(release) of a button
on (release) {
setProperty(main, _width, "600");
setProperty(main, _height, "366");
}
this works without a smooth transition and the button is in the middle of the resized mc, would startdrag be better.
I want to keep all buttons on that layer to adjust accordingly. So, is there a way to adjust the whole layer to a desired size
thanks in advance
Gradually Resize Movie Clip
Hello,
I am trying to make a site for myself and I would like to make a movie clip which will be changed in size (scaled) when specific buttons are pressed. I would like to make a gradual transition from one size to the other using actionscript . I tried to find a tutorial on this but nothing came up, can anyone give me any advice on how to do this? Any information wil be very helpfull. Thanks.
Resize Attached Movie Clip
Hi,
I have a movie clip to which I attach several others always at the same depth so one replaces the other. I was trying to change the size of the attached movies by setting the ._width and ._height properties and also by using the xscale without any luck. I finally experimented with a tutorial example and got it to work and saw that the only difference between the code in the example and my own was the depth which I had set to 1 and the tutorial had set to 0. I changed my depth to 0 and it worked.
I didn't see anything specifying that the depth had to be 0 and believe I am still missing something. If anyone cna help me figure out what's going on I would appreciate it.
Thanks
Chris
OnClick Resize Movie Clip
I have searched this forum for any threads that may help with this and can't seem to find what I am looking for. I have a movie clip that is linked when you click on a button it appears on the stage. What I would like to do is when you click and drag on a button in the corner of the menu movie clip the movie clip will resize just like a window in WINDOWS XP. I am pretty sure it would involve creating a loop of some sort but I have yet to grasp loops within actionscript. Can someone point me in the right direction.
Thanks
Can't Resize Movie Clip In Level - Can In Movieclip
I'm have a function that loads external swfs. It accepts the name of the file, width, and height as parameters, and it should load and resize the clip.
It is working perfectly when I load the movie into a movieclip on the stage, but it doesn't resize it when the swf is loaded into a level.
I read somewhere that it won't work right if the movie isn't fully loaded, so I am calling the resize function via setInterval from the MovieClipLoader's init event. Still no luck.
Does anyone know how I can resize external movies loaded into a level?
Thanks. Here's the code:
var intFlashWidth=0;
var intFlashHeight=0;
var intInterval_resizeFlashClip:Number;
var my_mcl = new MovieClipLoader();
myListener = new Object();
myListener.onLoadInit = function(target_mc) {
_root.intInterval_resizeFlashClip=setInterval(resi zeFlashClip(target_mc),1000);
};
my_mcl.addListener(myListener);
resizeFlashClip = function (target_mc) {
target_mc._width =intFlashWidth;
target_mc._height = intFlashHeight;
target_mc._x=0;
target_mc._y=0;
clearInterval(_root.intInterval_resizeFlashClip);
}
function loadFlash(strMovieFileName,intWidth,intHeight){
intFlashWidth=intWidth;
intFlashHeight=intHeight;
my_mcl.loadClip(strMovieFileName, '_level2');
}
How Do You Resize A Dynamically Created Movie Clip
So I have a movieclip that I am dynamically adding to the stage when a user clicks a particular button. There are multiple button that each result in the movieclip getting attached to the staged and scaled to a different particular size. Instead of attaching a new instance of the movieclip every time a button is clicked, I only want to attach a new movieclip the first time one of the buttons are clicked and then scale the dynamically added movie to the size specified in the functions for all of the subsequent button clicks. To be clear, I want to attach the movieclip on the first click and then scale it for all of the subsequent clicks.
Here is the code I am using for the buttons:
ActionScript Code:
stop();
videosBTN.onRelease= function() {
_root.cover.spaceships.attachMovie("boxBg", "Bg", 01, {_x:5, _y:127, _xscale:92,_yscale:100} );
}
photosBTN.onRelease= function() {
_root.cover.spaceships.attachMovie("boxBg", "Bg", 01, {_x:5, _y:140, _xscale:93,_yscale:123} );
}
Here is what I am using for the moviclip I want to scale:
ActionScript Code:
onClipEvent (enterFrame) {
//this scales our clip along the x axis 10% every frame until it reaches a certain width
if (this._xscale< 100) {
this._xscale += 10;
}
}
onClipEvent (enterFrame) {
//this scales our clip along the x axis 10% every frame until it reaches a certain width
if (this._yscale< 100) {
this._yscale += 10;
}
}
Is there a way to do this?
|