Hey guys,
I just can figure out how to make my navigation mc (named navBAR) always stay on the top layer, highest depth. Everytime the slideshow image reloads, when the navBAR is showing, it immediately becomes not visible.
Is there anyway to make it so that navBAR is on the top level even if the slideshow is building progessive layers behind?
Any help is much appreciated. You rule!
M
My code:
stop();
//
Stage.scaleMode = “noScale”;
Stage.align = “TL”;
//
import mx.transitions.Tween;
import flash.display.BitmapData;
//
var root:MovieClip = this;
var totalItems:Number = imgArray.length;
var autoStart:String = s_autoStart;
var imageScale:String = s_imageScale;
var mvSec:Number = s_slideSpeed;
var mvEase:Object = mx.transitions.easing.Regular.easeOut;
var totalRounds:Number = 51000/50;
var timerInc:Number = 100/totalRounds;
var leftrightgap:Number = 100;
var gapinmyCP:Number = 6;
var curImage:Number = 0;
//---------------------------------------------------
//stage resize function
//---------------------------------------------------
var listner:Object = new Object();
listner.onResize = function() {
sh = Stage.height;
sw = Stage.width;
//
//navBAR resizers
root.navBAR.navRollover._width = sw;
root.navBAR.greynav._width = sw;
root.navBAR.greysubnav._width = sw;
root.navBAR.d_hitArea._width = sw;
root.navBAR.navFADEIN._width = sw;
root.navBAR.navFADEIN._height = sh+sh+sh+sh;
root.navBAR.navFADEIN._y = -sh-sh;
//
//control panel resizers
root.myCP._y = sh-root.myCP.t_bg11._height;
root.myCP.t_bg11._width = root.myCP.t_bg._width=root.myCP.t_hitArea._width=root.myCP.about_page.a_bg._width = sw;
root.myCP.t_bg._x = root.myCP.t_bg2._x=root.myCP.t_hitArea._x=0;
root.myCP.t_copy._x = sw-root.myCP.t_copy._width-gapinmyCP;
root.myCP.t_timer._x = gapinmyCP+root.myCP.t_stop._width-10;
root.myCP.t_play._x = root.myCP.t_stop._x=gapinmyCP;
root.myCP.t_hol._x = gapinmyCP+root.myCP.t_stop._width+root.myCP.t_timer._width;
root.myCP.t_hol.t_mask._width = 300;
root.myCP.d_head._x = sw-root.myCP.d_head._width-gapinmyCP;
//
if (root.myCP.t_hol.t_mask._width>root.totalbtnwidth) {
root.myCP.t_hol.buttonsbg._width = root.totalbtnwidth;
} else {
root.myCP.t_hol.buttonsbg._width = root.myCP.t_hol.t_mask._width;
}
root.lil_img._y = root.myCP._y-root.lil_img._height;
//
root.max = root.myCP.t_hol.t_mask._width;
root.myCP.t_hol.buttonsbg.onRollOver = root.moveLilImg;
var tbg:Tween = new Tween(root.myCP.t_hol.buttons, “_x”, root.mvEase, root.myCP.t_hol.buttons._x, 0, root.mvSec, true);
//
//image resizers
if (root.imageScale == “true”) {
if (sw>1000 or sh>600) {
imageHolderDone._width = sw;
imageHolderDone._yscale = imageHolderDone._xscale;
}
//
if (sw>1000) {
if (imageHolderDone._width<sw) {
imageHolderDone._width = sw;
imageHolderDone._yscale = imageHolderDone._xscale;
}
}
if (sh>600) {
if (imageHolderDone._height<sh) {
imageHolderDone._height = sh;
imageHolderDone._xscale = imageHolderDone._yscale;
}
}
}
//
imageHolderDone._x = sw/2-root.imageHolderDone._width/2;
imageHolderDone._y = sh/2-root.imageHolderDone._height/2;
//
//preloader resizer
myCP.t_preloader._x = 0;
myBarBgWidth = sw;
myCP.t_preloader._width = myPercentmyBarBgWidth/100;
//
//main img preloader
root.mainpre._x = sw/2;
root.mainpre._y = sh/2;
//
//info panel pos
navBAR._x = sw-sw;
infoDestY = Math.round(sh-200);
var inf:Tween = new Tween(root.navBAR, “_y”, root.mvEase, root.navBAR._y, infoDestY, root.mvSec, true);
};
Stage.addListener(listner);
//---------------------------------------------------
//mouse wheel function function
//---------------------------------------------------
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta) {
root.myCP.t_hol.buttons[“b”+root.curImage].gotoAndPlay(“out”);
if (delta == 3) {
if (root.curImage<root.totalItems-1) {
root.curImage = root.curImage+1;
} else {
root.curImage = 0;
}
} else {
if (root.curImage>0) {
root.curImage = root.curImage-1;
} else {
root.curImage = root.totalItems-1;
}
}
root.showImage(root.curImage);
};
Mouse.addListener(mouseListener);
//---------------------------------------------------
//button’s function
//---------------------------------------------------
rollIn = function () {
var trg:MovieClip = root.lil_img.t_img;
var dest:Number = -(this.no*(root.s_thumbWidth+5)-5);
var myTween:Tween = new Tween(trg, “_x”, root.mvEase, trg._x, dest, root.mvSec, true);
//
if (root.curImage != this.no) {
this.gotoAndPlay(“in”);
}
};
rollOt = function () {
if (root.curImage != this.no) {
this.gotoAndPlay(“out”);
}
};
root.myCP.about_page.a_btn.onRollOver = root.myCP.t_play.onRollOver = root.myCP.t_stop.onRollOver=root.myCP.t_fs.onRollOver=function () {
this.gotoAndPlay(“in”);
};
root.myCP.about_page.a_btn.onRollOut = root.myCP.t_play.onRollOut = root.myCP.t_stop.onRollOut=root.myCP.t_fs.onRollOut=function () {
this.gotoAndPlay(“out”);
};
root.myCP.t_play.onRelease = root.myCP.t_play.onReleaseOutside=function () {
this.gotoAndPlay(“out”);
root.startTimer();
root.autoStart = “true”;
this._visible = false;
this._parent.t_stop._visible = true;
};
root.abtOn = “false”;
root.myCP.about_page.a_btn.onRelease = function(){
showAbout();
}
root.myCP.t_stop.onRelease = root.myCP.t_stop.onReleaseOutside=function () {
this.gotoAndPlay(“out”);
if (root.timerId) {
this._parent.t_timer.bar._width = 1;
root.stopTimer();
}
root.autoStart = “false”;
this._visible = false;
this._parent.t_play._visible = true;
};
if (root.autoStart == “true”) {
root.myCP.t_play._visible = false;
} else {
root.myCP.t_stop._visible = false;
}
//
//---------------------------------------------------
//main functions
//---------------------------------------------------
showAbout = function(){
if(root.abtOn == “false”){
var showAbt = new Tween(root.myCP.about_page, “_y”, root.mvEase, root.myCP.about_page._y, -(root.myCP.about_page.a_bg._height), root.mvSec, true);
root.abtOn = “true”;
}else{
var showAbt = new Tween(root.myCP.about_page, “_y”, root.mvEase, root.myCP.about_page._y, 0, root.mvSec, true);
root.abtOn = “false”;
}
}
showImage = function (goto:Number) {
root.mainpre._visible = false;
//stop running timer
stopTimer();
trace(root.myCP.t_hol.buttons[“b”+root.curImage]);
//if none, set 0 as 1st image;
if (goto != undefined) {
this = root.myCP.t_hol.buttons[“b”+goto];
} else {
//unhiglight prev btn
root.myCP.t_hol.buttons[“b”+root.curImage].gotoAndPlay(“out”);
}
//set cur image
root.curImage = this.no;
//load image
myLoader.loadClip(imgArray[root.curImage][0], root.imageHolder);
//set cur image info
root.myCP.t_hol.buttons[“b”+root.curImage].gotoAndPlay(“in”);
//
};
showControls = function () {
var showC = new Tween(root.myCP, “_y”, root.mvEase, root.myCP._y, Stage.height-root.myCP.t_hitArea._height, root.mvSec, true);
delete this.onRollOver;
this.onEnterFrame = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
} else {
delete this.onEnterFrame;
root.myCP.t_hitArea.onRollOver = showControls;
var showC = new Tween(root.myCP, “_y”, root.mvEase, root.myCP._y, Stage.height-root.myCP.t_bg11._height, root.mvSec, true);
}
};
};
root.myCP.t_hitArea.onRollOver = showControls;
//
showInfo = function () {
var showI = new Tween(root.navBAR, “_alpha”, root.mvEase, root.navBAR._alpha, 100, root.mvSec, true);
delete this.onRollOver;
this.onEnterFrame = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
} else {
delete this.onEnterFrame;
root.navBAR.d_hitArea.onRollOver = showInfo;
var showI = new Tween(root.navBAR, “_alpha”, root.mvEase, root.navBAR._alpha, 0, root.mvSec, true);
}
};
};
root.navBAR.d_hitArea.onRollOver = showInfo;
//
moveLilImg = function () {
var tg2:MovieClip = root.myCP.t_hol.buttons;
var tg:MovieClip = root.lil_img;
var myTween:Tween = new Tween(tg, “_alpha”, root.mvEase, tg._alpha, 100, 1.2, true);
//
delete this.onRollOver;
if (tg2._width>root.max) {
var leng:Number = Math.abs(tg2._width-root.max);
this.onEnterFrame = function() {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
ms = this._parent._xmouse;
stagecur = ms/root.max100;
tg2._x = -(Math.ceil(stagecur/100leng));
//
var dest:Number = _root._xmouse-root.lil_img.t_bg._width/2;
tg._x += (dest-tg._x)/4;
} else {
this.onRollOver = root.moveLilImg;
var myTween0:Tween = new Tween(tg, “_alpha”, root.mvEase, tg._alpha, 0, 0.2, true);
var myTween1:Tween = new Tween(tg, “_x”, root.mvEase, tg._x, _root._xmouse-100, 0.2, true);
delete this.onEnterFrame;
}
};
} else {
this.onEnterFrame = function() {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
var dest:Number = _root._xmouse-root.lil_img.t_bg._width/2;
tg._x += (dest-tg._x)/4;
} else {
this.onRollOver = root.moveLilImg;
var myTween0:Tween = new Tween(tg, “_alpha”, root.mvEase, tg._alpha, 0, 0.2, true);
var myTween1:Tween = new Tween(tg, “_x”, root.mvEase, tg._x, _root._xmouse-100, 0.2, true);
delete this.onEnterFrame;
}
};
}
};
//---------------------------------------------------
//countdown function
//---------------------------------------------------
tickTock = function () {
root.myCP.t_timer.bar._width += timerInc;
if (_root.secinc<totalRounds) {
_root.secinc++;
} else {
clearInterval(root.timerId);
//
var m11:MovieClip = root.myCP.t_hol.buttons[“b”+root.curImage];
m11.gotoAndPlay(“out”);
//
if (root.curImage<totalItems-1) {
root.curImage++;
} else {
root.curImage = 0;
}
//
var m1:MovieClip = root.myCP.t_hol.buttons[“b”+root.curImage];
m1.gotoAndPlay(“in”);
//
var myTween2:Tween = new Tween(root.myCP.t_timer.bar, “_width”, root.mvEase, root.myCP.t_timer.bar._width, 1, root.mvSec, true);
myLoader.loadClip(imgArray[root.curImage][0], imageHolder);
}
};
stopTimer = function () {
var myTweenSS:Tween = new Tween(root.myCP.t_timer.bar, “_width”, root.mvEase, root.myCP.t_timer.bar._width, 1, root.mvSec, true);
//trace(“clear”);
clearInterval(root.timerId);
delete root.timerId;
};
startTimer = function () {
clearInterval(root.timerId);
_root.secinc = 0;
root.timerId = setInterval(root, “tickTock”, 35);
};
//
//---------------------------------------------------
//movieClip loader functions
//---------------------------------------------------
var myLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
myLoaded = Math.round(bytesLoaded);
myTotal = Math.round(bytesTotal);
myPercent = Math.round(myLoaded/myTotal100);
if (target == root.imageHolder) {
myCP.t_preloader._alpha = 100;
myCP.t_preloader._width = myPercentmyBarBgWidth/100;
}
root.mainpre._x = Stage.width/2;
root.mainpre._y = Stage.height/2;
};
listener.onLoadStart = function(target:MovieClip):Void {
if (target == root.imageHolder) {
root.mainpre._visible = true;
//
root.navBAR._alpha = 30;
root.navBAR.d_hitArea.enabled = false;
//
var stgp:MovieClip = root[“pre”];
var t_mhol1:Tween = new Tween(root.imageHolderDone, “_alpha”, root.mvEase, root.imageHolderDone._alpha, 50, root.mvSec, true);
var t_pre2:Tween = new Tween(mcp, “_alpha”, root.mvEase, mcp._alpha, 100, root.mvSec, true);
} else {
var mcp:MovieClip = target._parent[“pre”];
var t_pre2:Tween = new Tween(mcp, “_alpha”, root.mvEase, mcp._alpha, 100, root.mvSec, true);
}
};
listener.onLoadInit = function(target:MovieClip):Void {
if (target == root.imageHolder) {
root.mainpre._visible = false;
//
myCP.t_preloader._alpha = 0;
//
bmp = new BitmapData(target.getBounds().xMax, target.getBounds().yMax, true, 0);
bmp.draw(target);
root.imageHolderDone.attachBitmap(bmp, 1);
//
root.imageHolderDone._alpha = 0;
if (root.imageScale == "true") {
root.imageHolderDone._width = Stage.width;
root.imageHolderDone._yscale = root.imageHolderDone._xscale;
}
root.imageHolderDone._x = Stage.width/2-root.imageHolderDone._width/2;
root.imageHolderDone._y = Stage.height/2-root.imageHolderDone._height/2;
//
var t_mhol2:Tween = new Tween(root.imageHolderDone, "_alpha", root.mvEase, root.imageHolderDone._alpha, 100, root.mvSec, true);
var t_mhol3:Tween = new Tween(root.imageHolder, "_alpha", root.mvEase, root.imageHolder._alpha, 0, root.mvSec, true);
var t_mpre:Tween = new Tween(root.myCP.t_preloader, "_width", root.mvEase, root.myCP.t_preloader._width, 1, root.mvSec, true);
if (root.autoStart == "true") {
startTimer();
}
//
if (imgArray[root.curImage][2] == null && imgArray[root.curImage][3] == null) {
root.navBAR._alpha = 100;
root.navBAR.d_hitArea.enabled = false;
root.myCP.d_head.text = "Untitled";
root.myCP.d_desc.text = "No info available";
//
} else if (imgArray[root.curImage][2] or imgArray[root.curImage][3]) {
root.navBAR._alpha = 0;
root.navBAR.d_hitArea.enabled = true;
//
if (imgArray[root.curImage][2] != undefined) {
root.myCP.d_head.text = imgArray[root.curImage][2];
}else{
root.myCP.d_head.text = "Untitled";
}
if (imgArray[root.curImage][3] != undefined) {
root.myCP.d_desc.text = imgArray[root.curImage][3];
}else{
root.myCP.d_desc.text = "No info available";
}
}
root.myCP.d_head.autoSize = true;
root.myCP.d_desc.autoSize = true;
root.myCP.d_desc._y = root.myCP.d_head._y + root.myCP.d_head._height;
root.navBAR.d_bg._height = root.myCP.d_head._height+root.myCP.d_desc._height;
root.navBAR.d_foot._y = root.navBAR.d_bg._y+root.navBAR.d_bg._height;
//
} else {
var mcp:MovieClip = target._parent["pre"];
var t_pre:Tween = new Tween(mcp, "_alpha", root.mvEase, mcp._alpha, 0, root.mvSec, true);
var t_pre1:Tween = new Tween(mcp, "_xscale", root.mvEase, mcp._xscale, 0, root.mvSec, true);
var t_pre2:Tween = new Tween(mcp, "_yscale", root.mvEase, mcp._yscale, 0, root.mvSec, true);
//remove preloader mc when finished
t_pre.onMotionFinished = function() {
removeMovieClip(mcp);
//trace("KILL: " + mcp);
};
}
};
myLoader.addListener(listener);
//
//---------------------------------------------------
//initiate
//---------------------------------------------------
var image:MovieClip = root.createEmptyMovieClip(“image”, root.getNextHighestDepth());
var imageHolder:MovieClip = image.createEmptyMovieClip(“imageHolder”, image.getNextHighestDepth());
var imageHolderDone:MovieClip = image.createEmptyMovieClip(“imageHolderDone”, image.getNextHighestDepth());
var mainpre:MovieClip = root.attachMovie(“pre”, “mainpre”, root.getNextHighestDepth());
trace("mainpre: "+mainpre);
var buttons:MovieClip = root.myCP.t_hol.createEmptyMovieClip(“buttons”, root.myCP.t_hol.getNextHighestDepth());
var mask:MovieClip = root.myCP.t_hol.attachMovie(“mask”, “t_mask”, root.myCP.t_hol.getNextHighestDepth());
mask.cacheAsBitmap = true;
buttons.cacheAsBitmap = true;
buttons.setMask(mask);
root.myCP.swapDepths(root.getNextHighestDepth());
root.lil_img.swapDepths(root.getNextHighestDepth());
root.navBAR.swapDepths(root.getNextHighestDepth());
root.imageHolder._alpha = 0;
root.imageHolderDone._alpha = 0;
//
root.lil_img.t_img._x = root.lil_img.t_msk._x=5;
root.lil_img.t_img._y = root.lil_img.t_msk._y=5;
root.lil_img.t_msk._width = root.s_thumbWidth;
root.lil_img.t_msk._height = root.s_thumbHeight;
root.lil_img.t_bg._width = root.s_thumbWidth+9;
root.lil_img.t_bg._height = root.s_thumbHeight+10;
root.lil_img.t_pointer._y = root.lil_img.t_bg._y+root.lil_img.t_bg._height;
root.lil_img.t_pointer._x = root.s_thumbWidth/2;
root.lil_img._alpha = 0;
//
for (i=0; i<totalItems; i++) {
var th:MovieClip = root.lil_img.t_img.createEmptyMovieClip(“t”+i, root.lil_img.t_img.getNextHighestDepth());
var img:MovieClip = th.createEmptyMovieClip(“img”, th.getNextHighestDepth());
var pre:MovieClip = th.attachMovie(“pre”, “pre”, th.getNextHighestDepth());
//img.loadMovie(root.imgArray*[1]);
//trace(img);
myLoader.loadClip(root.imgArray*[1], img);
th._x = (root.s_thumbWidth+5)*i;
pre._x = (root.s_thumbWidth+5)/2;
pre._y = (th._y+root.s_thumbHeight)/2;
pre._alpha = 0;
//
var b:MovieClip = buttons.attachMovie(“button”, “b”+i, buttons.getNextHighestDepth());
if (i<9) {
b.txt.text = “0”+(i+1);
} else {
b.txt.text = i+1;
}
b._x = (b._width+gapinmyCP)*i;
b.no = i;
b.onRollOver = rollIn;
b.onRollOut = b.onReleaseOutside=rollOt;
b.onRelease = showImage;
}
root.totalbtnwidth = b._x+b._width;
root.myCP.t_hol.attachMovie(“inv”, “buttonsbg”, buttons.getNextHighestDepth());
root.myCP.t_hol.buttonsbg.onRollOver = moveLilImg;
root.myCP.t_hol.buttonsbg._y -= root.myCP.t_hol._y-root.myCP.t_bg11._height;
root.myCP.t_hol.buttonsbg._height = root.myCP.t_bg._height;
root.myCP.t_hol.buttonsbg._width = root.totalbtnwidth;
root.myCP.t_hol.buttonsbg._alpha = 0;
//
showImage(root.curImage);
listner.onResize();