I know I should reposotion the contentHolder mc when the content is loaded.
I`d do this with this script here:
contentHolder._x = Stage.width/2 - (contentHolder._width / 2);
contentHolder._y = Stage.height/2 - (contentHolder._height / 2);
I placed the function on almost possible spot in the FLA, but I can`t figure it out. Also I tried to call the relocate function from the loaded content .swf.
I`m using this gallery script:
onClipEvent (load) {
function executeAction(action)
{
//loadMovie(action, _parent.contentHolder);
//_root.createEmptyMovieClip("leer", this.getNextHighestDepth());
//loadMovie("leer", contentHolder);
mc.changeAlpha(0, false, action);
//
// Uncomment the above line to get the menu working
// and add a content mc on the stage (with the instance name "content") to
// load in your stuff (swf's, jpg's, etc).
//
}
MovieClip.prototype.changeAlpha = function(alphaTo, theLoader, action)
{
this.onEnterFrame = function()
{
if(this._alpha > alphaTo)
{
this._alpha -= 10;
if(this._alpha <= alphaTo)
{
if(!theLoader)preload(action);
delete this.onEnterFrame;
}
}
else if(this._alpha < alphaTo)
{
this._alpha += 10;
if(this._alpha >= alphaTo) delete this.onEnterFrame;
}
}
}
function preload(thePath)
{
mc.loadMovie(thePath);
_parent.attachMovie("loader", "loader", 101);
_parent.loader._x = 390;//loader x position
_parent.loader._y = 270;//loader y position
this._parent.onEnterFrame = function()
{
l = Math.round(mc.getBytesLoaded());
t = Math.round(mc.getBytesTotal());
getPercent = l/t;
trace (t);
trace (l);
//this._parent.loader.loadText = Math.round(getPercent*100)+"%";
if (l>0 && l>=t)
{
_parent.loader.changeAlpha(0, true);
mc.changeAlpha(100);
delete this.onEnterFrame;
}
}
}
function selectItem(item) {
if (this[item].action != null && curItem != item) {
executeAction(this[item].action);
}
if (this[item].sub == false || curItem == item) {
curItem = null;
removeSub();
} else {
curItem = item;
buildSub(item);
}
}
function buildSub(item) {
var i;
var s;
var j;
var d = 0;
this.attachMovie("subholder", "subholder", 100);
var k = this.subholder;
var total_subs = 0;
var correct_item = (Number_Items-item)+1;
for (i in menuObj["item"+correct_item]) {
if (typeof (menuObj["item"+correct_item]) == "object" && i != "sub" && i != "action") {
total_subs++;
}
}
var Present_sub = total_subs-1;
for (i=1; i<total_subs; i++) {
k.attachMovie("sub", i, d);
s = k*;
s.name = menuObj["item"+correct_item]["sub"+Present_sub].name;
s.action = menuObj["item"+correct_item]["sub"+Present_sub].action;
s._x = 20;
s._y = (s._height+subSpacer)*d;
d++;
Present_sub--;
}
k._y = this[item].basey+this[item]._height+menuSpacer;
var u = 1;
for (i in menuObj) {
j = this[u];
if (this[item]._y<j._y) {
j.target = j.basey+k._height+menuSpacer;
} else {
j.target = j.basey;
}
u++;
}
subs = total_subs;
onenterframe = menuAnimation;
}
function removeSub() {
this.subholder.removeMovieClip();
depth = 1;
for (i in menuObj) {
this[depth].target = this[depth].basey;
depth++;
}
onenterframe = menuAnimation;
}
function menuAnimation() {
var i;
var j;
var k = true;
var depth = 1;
for (i in menuObj) {
j = this[depth];
j._y = j._y+(j.target-j._y)/menuSpeed;
if (menuTolerance<Math.abs(j.target-j._y)) {
k = false;
} else {
j._y = j.target;
}
depth++;
}
if (k) {
onenterframe = null;
if (curItem != null) {
activateSub();
}
}
}
function activateSub() {
var d = 0;
for (i=1; i<subs; i++) {
subholder*.start = getTimer();
subholder*.delay = subDelay*d;
subholder*.gotoAndPlay(2);
d++;
}
}
MovieClip.prototype.activateMenu = function() {
var d = 0;
for (i=1; i<Number_Items+1; i++) {
this*.start = getTimer();
this*.delay = itemDelay*d;
this*.gotoAndPlay(3);
d++;
}
};
mc = _parent.contentHolder;
var menuSpacer = 1;
// sets the vertical space between main items
var subSpacer = 1;
// sets the vertical space between sub items
var menuSpeed = 5;
// sets the menu animation speed
var menuTolerance = 1;
var subDelay = 170;
// set the delay for the sub items entering the stage
var itemDelay = 100;
// set the delay for the main items entering the stage
var curItem = null;
var menuObj = _parent.menuObj;
var onenterframe = null;
var Present_item = Number_Items;
var loop_condition = Number_Items+1;
for (d=1; d<loop_condition; d++) {
this.attachMovie("item", d, d);
k = this[d];
k._x = 20;
k._y = (k._height+menuSpacer)*d;
k.name = menuObj["item"+Present_item].name;
k.action = menuObj["item"+Present_item].action;
k.sub = menuObj["item"+Present_item].sub;
k.basey = k._y;
if (k.sub == false) {
k.icon._visible = false;
}
Present_item--;
}
activateMenu();
//this._parent.contentHolder._alpha = 100;
}
onClipEvent (enterFrame) {
onenterframe();
}
helping to find the right line to insert the center function is greatly appreciated. thx,
m.