Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loadMovie into empty movie clip load progress

Status
Not open for further replies.

dfinley

Programmer
Oct 8, 2003
2
US
I am trying to create a 'popup' window effect for viewing a full size jpg file selected from a slide viewer. The idea is that the user selects a thumbnail image on the main movie which in turn display a larger version in the viewer window. Once this is done, the user can click the larger image version which attaches the 'popup' mc on the main stage at a high level than the main movie. Once the 'popup' is attached, I create an empty mc as a container for the image. After the empty mc is created, I then loadMovie the jpg into this empty mc within the 'popup' mc. When I test for totalBytes of the empty container mc from my browser I get a '-1'. I've check the file path an it looks correct and the image loads. However, as part of the functionality, I want to determine the size of the loaded jpg so that I can position it in the center of the 'popup' stage.

This works great when testing the movie locally from Flash MX. However, when I run the same code on a browser (IE), it returns '-1' which supposedly indicates the loadMovie's file was not found.

Any ideas on why it doesn't work from a browser? Could the be another loadMovie in my script which is causing the conflict?

Here is the main timeline's actionscript:

// Function "clickMe": Activated on current images mouse click from myGallery.

function clickMe(id) {
var imageNode = myGallery_mc.getXMLNode().firstChild.childNodes[id - 1];
var imageDir = myGallery_mc.getXMLNode().firstChild.attributes.directory;
var imageFile = imageDir + '/' + imageNode.attributes.jpegURL;
var popupWin = this.attachMovie("popup_id","popup_stageid",500);
var imageHolder = popup_stageid.createEmptyMovieClip('imageHolder_mc',500);

imageHolder.loadMovie(imageFile,'imageHolder_mc');

popup_stageid.onEnterFrame = function() {
var ready = imageHolder.getBytesLoaded();
var tot = imageHolder.getBytesTotal();
// Find clicked image's width & height.
var imageWidth = imageHolder._width;
var imageHeight = imageHolder._height;
// Place image in the middle of "popupWin" stage.
var stageWidth = 780;
var stageHeight = 600;
//var stageWidth = _root._width;
//var stageHeight = _root._height;
imageHolder._x = Math.round((stageWidth - imageWidth)/2);
imageHolder._y = Math.round((stageHeight - imageHeight)/2);

delete popup_stageid.onEnterFrame;
}
}
 
Never mind! I added a 'preloader' check in the onEnterFrame loop for this specific loadMovie action. This seems to have fixed the problem. Definitely something to keep in mind when attaching external files even when you think load time is not an issue!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top