PDA

View Full Version : auto resizing movie clip


acry
12-24-2005, 08:26 AM
Hi,
I'm an actionscripting novice and I've been working on having an MC resize itself when a picture is loaded into it. I have the code and understand it (for the most part) but I don't get why, when I move the code to another flash project that does not have a square stage, everything goes haywire and the picture loads in the wrong position.

Is there something about having a square stage that is needed in doing this? The only part of the code that I don't grasp is the use of 'this._[value]' in the scripting.
I hope that was clear to some degree, and sorry if this has been posted before. :)
Any help would be appreciated.
-Sean

Billy T
12-24-2005, 01:13 PM
post your code

acry
12-24-2005, 05:05 PM
spacing = 0;
containerMC._alpha = 0;
var pArray = new Array();
var tArray = new Array();

MovieClip.prototype.loadPic = function(pic) {
containerMC._alpha = 0;
cur = pic;
this.loadMovie(pArray[pic]);
this._parent.onEnterFrame = function() {
var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
bar._visible = 1;
per = Math.round((l/t)*100);
if (t != 0 && Math.round(l/t) == 1 && containerMC._width != 0) {
var w = containerMC._width+spacing, h = containerMC._height+spacing;
border.resizeMe(w, h, pic);
shadow.resizeMe(w, h, pic);
bar._visible = 0;
loadText.text = "";
delete this.onEnterFrame;
} else {
bar._width = per;
loadText.text = per+"%";
}
};
};

MovieClip.prototype.resizeMe = function(w, h, pic) {
var speed = 3;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
picinfo.info.text = tArray[pic];
if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1) {
this._width = w;
this._height = h;
containerMC._x = border._x-(border._width/2);
containerMC._y = border._y-(border._height/2);
containerMC._alpha += 5;
if (containerMC._alpha>90) {
containerMC._alpha = 100;
delete this.onEnterFrame;
}
}
};
};

var gallery_xml = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success) {
if (success) {
var gallery = this.firstChild;
for (var i = 0; i<gallery.childNodes.length; i++) {
tArray.push(gallery.childNodes[i].attributes.title);
pArray.push(gallery.childNodes[i].attributes.source);
}
containerMC.loadPic(0);
} else {
title_txt.text = "Error!";
}
};
gallery_xml.load("gallery.xml");

sorry 'bout that
-Sean