Hey everyone,
I am working on a website, however, it only works locally. I was wondering if anyone could help me out here. I am using Actionscript2. Here is the URL for the test site location:
http://www.techgogreen.org/everite/everite_products.swf
For some reason the images wont show up. Here is the code for it:. Everything works except when I call the firstImage function, I guess it cannot find the images and I don’t know why. I tried it with and without the fade in preloader. I’m hoping its just a syntax error from changing from a local address to an online address. Thanks in advance
globvar=0;
_global.item=0;
_global.product=0;
var menuButtons:Array = [“Products”];
var chosenMenu:Array = new Array();
var subMenuOpened:Boolean = false;
var whichSubMenu:Number = new Number();
var currentPosition:Number = new Number();
var menuSpeed:Number = 6;
var menuDown:Button = menuDown_btn;
var menuUp:Button = menuUp_btn;
var firstLook:Boolean = true;
menuUp._alpha = 0;
menuUp.enabled = false;
galleryMask._height = 280;
var menuButtonsMC:MovieClip = galleryMenu_mc.buttonsHolder_mc;
var descMC:MovieClip = descMenu_mc.descHolder_mc;
var galleryMask:MovieClip = galleryMenu_mc.galleryMask_mc;
var scrollHeight:Number;
var movedOver:Boolean = false;
var tester:Boolean = true;
var mouseListener:Object = new Object();
var my_events = new Object();
my_events.target = my_mc;
Mouse.addListener(my_events);
descMenu_mc.descHolder_mc.info_txt.width = 190;
descMenu_mc.descHolder_mc.info_txt.autoSize = true;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
productname = [];
description = [];
thumbnails = [];
rounds = [];
color = [];
subMenu = [];
total = xmlNode.childNodes[0].childNodes.length;
loadMenu();
generateMenu();
loadpictures();
for(i=0; i<subMenu.length; i++) {
rounds* = 0;
}
menu_fn();
firstImage(item);
scrollHeight = descMenu_mc.descHolder_mc._height;
scrolling(scrollHeight);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“gallery.xml”);
/////////////////////////////////////
listen = new Object();
RollClipListener = 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 = 1;
this.onEnterFrame = function() {
filesize = picture_mc.getBytesTotal();
loaded = picture_mc.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture_mc._alpha<100) {
picture_mc._alpha += 10;
}
}
};
this.createEmptyMovieClip(RollClip, 1);
this.RollClip._x = 20;
this.RollClip._y = 110;
this.RollClip._height = ((xmlNode.childNodes.length) * 32)+60;
this.RollClip._width = 160;
function nextImage() {
if (p<(totalimages)) {
p++;
if (loaded == filesize) {
picture_mc._alpha = 0;
picture_mc.loadMovie(“gallery/” + subMenu[product] + “/” + productname[item] + “/” + p + “.jpg”);
desc_txt.text = productname[item];
color_txt.text = color[p-1];
descMenu_mc.descHolder_mc.info_txt.text = description[item];
picture_num();
}
}
}
function prevImage() {
if (p>1) {
p–;
picture_mc._alpha = 0;
picture_mc.loadMovie(“gallery/” + subMenu[product] + “/” + productname[item] + “/” + p + “.jpg”);
desc_txt.text = productname[item];
color_txt.text = color[p-1];
descMenu_mc.descHolder_mc.info_txt.text = description[item];
picture_num();
}
}
function firstImage(item) {
if (loaded == filesize) {
picture_mc._alpha = 0;
picture_mc.loadMovie(“gallery/” + subMenu[product] + “/” + productname[item] + “/” + 1 + “.jpg”);
desc_txt.text = productname[0];
color_txt.text = color[0];
descMenu_mc.descHolder_mc.info_txt.text = description[item];
picture_num();
}
if (Round[product] != true) {
picture_mc._alpha = 0;
picture_mc.loadMovie(“gallery/” + subMenu[product] + “/” + productname[item] + “/” + 1 + “.jpg”);
desc_txt.text = productname[0];
color_txt.text = color[0];
descMenu_mc.descHolder_mc.info_txt.text = description[item];
picture_num();
}
}
function picture_num() {
current_pos = p;
pos_txt.text = current_pos+" / "+ totalimages;
}
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip(“tscroller”, 1000);
scroll_speed = 6;
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) {
k++;
thumbnail_mc.createEmptyMovieClip(“t”+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = -69+((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);
thumbnaillocation = “gallery/” + subMenu[product] + “/” + productname[item] + “/thumbs/” + k + “.jpg”;
image_mcl.loadClip(thumbnaillocation, “thumbnail_mc.t”+k);
}
function menu_fn() {
for (i=0; i<xmlNode.childNodes[product].childNodes.length; i++) {
currentGalleryButton = galleryMenu_mc.buttonsHolder_mc.attachMovie(“menu section button”, “galleryButton”+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());
currentGalleryButton._x = 0;
currentGalleryButton._y = 35i;
currentGalleryButton.sectionTitle_txt.text = xmlNode.childNodes[product].childNodes.childNodes[0].firstChild.nodeValue;
}
numberOfGalleries = i;
enableButtons(numberOfGalleries);
}
function enableButtons(numberOfGalleries:Number):Void {
for (i=0; i < numberOfGalleries; i++) {
pressedButton = galleryMenu_mc.buttonsHolder_mc[“galleryButton”+i];
pressedButton.onRollOver = function():Void {
this.gotoAndPlay(2);
};
pressedButton.onRollOut = function():Void {
this.gotoAndStop(1);
};
pressedButton.onPress = function() {
currentitem = item;
currentitemgallery = “t”;
clickedGallery = Number(this._name.substr(13));
item = clickedGallery;
picture_mc.unloadMovie();
for (j=0; j < xmlNode.childNodes[product].childNodes[currentitem].childNodes[2].childNodes.length+1; j++) {
currentitemgallery = “t”+j;
thumbnail_mc[currentitemgallery].unloadMovie();
}
p = 1;
loadpictures();
firstImage(item);
descMenu_mc.descHolder_mc._y = 0;
scrollHeight = descMenu_mc.descHolder_mc._height;
thumbnail_mc._x = 213;
scrolling(scrollHeight);
};
}
enableGalleryNavigation();
}
function loadMenu() {
for (i=0; i<xmlNode.childNodes.length; i++) {
subMenu* = xmlNode.childNodes*.attributes.title;
}
}
function loadpictures() {
totalimages = xmlNode.childNodes[product].childNodes[item].childNodes[2].childNodes.length;
productname[item] = xmlNode.childNodes[product].childNodes[item].childNodes[0].firstChild.nodeValue;
description[item] = xmlNode.childNodes[product].childNodes[item].childNodes[1].firstChild.nodeValue;
for (i=0; i<totalimages; i++) {
color* = xmlNode.childNodes[product].childNodes[item].childNodes[2].childNodes*.firstChild.nodeValue;
thumbnails_fn(i);
};
}
function generateMenu() {
menuButton.onRollOver = function():Void {
currentPosition = menuButton._x;
if (!subMenuOpened) {
subMenuOpened = true;
openSubMenu(currentPosition);
} else {
closeSubMenu();
openSubMenu(currentPosition);
}
};
////////// SLAVA EDIT START //////////
menuButton.onRollOut = function():Void
{
movedOver = true;
};
////////// SLAVA EDIT END //////////
}
function openSubMenu(currentPosition):Void {
chosenMenu = eval(“subMenu”);
for (j=0; j<chosenMenu.length; j++) {
this.createEmptyMovieClip("subMenuHolder_mc", this.getNextHighestDepth());
if(j == chosenMenu.length-1){
subMenuHolder_mc.attachMovie("menu button end", "subMenuButton"+j, this.getNextHighestDepth());
}
if(j != chosenMenu.length-1){
subMenuHolder_mc.attachMovie("menu button", "subMenuButton"+j, this.getNextHighestDepth());
}
subMenuHolder_mc["subMenuButton"+j]._x = currentPosition;
subMenuHolder_mc["subMenuButton"+j]._y = 140+(j*30);
subMenuHolder_mc["subMenuButton"+j].label_txt.text = chosenMenu[j];
subMenuHolder_mc["subMenuButton"+j].num = j;
var subMenuStartColor:Color = new Color(subMenuHolder_mc["subMenuButton"+j].bkgColor_mc);
subMenuStartColor.setRGB(0x0C74B8);
//_________________________________________________________
// Release & ReleaseOutside event handler
//_________________________________________________________
subMenuHolder_mc["subMenuButton"+j].onRelease = subMenuHolder_mc["subMenuItem"+j].onReleaseOutside=function ():Void {
currentitem = item;
currentproduct = product;
clickedGallery = Number(this._name.substr(13));
picture_mc.unloadMovie();
for (i=0; i < xmlNode.childNodes[currentproduct].childNodes[currentitem].childNodes[2].childNodes.length+1; i++) {
currentitemgallery = "t"+i;
thumbnail_mc[currentitemgallery].unloadMovie();
}
for (i=0; i < xmlNode.childNodes[product].childNodes.length+1; i++) {
currentitemgallerytmp = "galleryButton"+i;
removeMovieClip(galleryMenu_mc.buttonsHolder_mc[currentitemgallerytmp]);
}
p = 1;
product = this.num;
item = 0;
rounds[product]++;
descMenu_mc.descHolder_mc._y = 0;
scrollHeight = descMenu_mc.descHolder_mc._height;
thumbnail_mc._x = 213;
scrolling(scrollHeight);
loadpictures();
menu_fn();
firstImage(item);
descMenu_mc.descHolder_mc._y = 0;
scrollHeight = descMenu_mc.descHolder_mc._height;
scrollTrack._y = 165;
scrolling(scrollHeight);
closeSubMenu();
};
//_________________________________________________________
// RollOver event handler
//_________________________________________________________
subMenuHolder_mc["subMenuButton"+j].onRollOver = function():Void {
var subMenuRollOverColor:Color = new Color(this.bkgColor_mc);
subMenuRollOverColor.setRGB(0x58B6F3);
//movedOver = true;
////////// SLAVA EDIT START //////////
movedOver = false;
////////// SLAVA EDIT END //////////
};
//_________________________________________________________
// RollOut event handler
//_________________________________________________________
subMenuHolder_mc["subMenuButton"+j].onRollOut = function():Void {
var subMenuRollOutColor:Color = new Color(this.bkgColor_mc);
subMenuRollOutColor.setRGB(0x0C74B8);
//movedOver = false;
////////// SLAVA EDIT START //////////
movedOver = true;
////////// SLAVA EDIT END //////////
};
}
}
function enableGalleryNavigation():Void {
menuDown.onPress = function() {
if (firstLook) {
menuUp._alpha = 100;
menuUp.enabled = true;
firstLook = false;
}
var menuTop:Number = menuButtonsMC._height-Math.abs(menuButtonsMC._y);
if (menuButtonsMC._y<=0 && menuTop>=galleryMask._height) {
var targetPos:Number = menuButtonsMC._y-galleryMask._height;
menuDown.enabled = false;
menuUp.enabled = false;
menuButtonsMC.onEnterFrame = function():Void {
menuButtonsMC._y += (targetPos-menuButtonsMC._y)/menuSpeed;
if (menuButtonsMC._y<=(targetPos+0.8)) {
menuButtonsMC._y = Math.round(targetPos);
delete menuButtonsMC.onEnterFrame;
menuDown.enabled = true;
menuUp.enabled = true;
}
};
}
};
menuUp.onPress = function() {
var menuTop:Number = menuButtonsMC._height-Math.abs(menuButtonsMC._y);
if (menuButtonsMC._y<0 && menuTop>0) {
var targetPos:Number = menuButtonsMC._y+galleryMask._height;
menuDown.enabled = false;
menuUp.enabled = false;
menuButtonsMC.onEnterFrame = function():Void {
menuButtonsMC._y += (-menuButtonsMC._y+targetPos)/menuSpeed;
if (menuButtonsMC._y>=(targetPos-0.8)) {
menuButtonsMC._y = Math.round(targetPos);
delete menuButtonsMC.onEnterFrame;
menuDown.enabled = true;
menuUp.enabled = true;
}
};
}
};
}
function closeSubMenu():Void {
removeMovieClip(subMenuHolder_mc);
}
var mouseout = new Object();
mouseout.onMouseMove = function() {
if(!(this.RollClip.hitTest(_root._xmouse, _root._ymouse, true)))
if(movedOver == true) {
{
// we’re outside the x/y width/height bounds of the menu
closeSubMenu();
trace(‘movedOver’);
movedOver = false;
}
}
}
Mouse.addListener(mouseout);
function scrolling(Height) {
var scrollHeight:Number = scrollTrack._height;
var contentHeight = Height;
var scrollFaceHeight:Number = scrollFace._height;
var maskHeight:Number = descMenu_mc.maskedView._height;
var initPosition:Number = scrollFace._y=scrollTrack._y;
var initContentPos:Number = descMenu_mc.descHolder_mc._y;
var finalContentPos:Number = maskHeight-contentHeight+initContentPos;
var left:Number = scrollTrack._x;
var top:Number = scrollTrack._y;
var right:Number = scrollTrack._x;
var bottom:Number = scrollTrack._height-scrollFaceHeight+scrollTrack._y;
var dy:Number = 0;
var speed:Number = 10;
var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
scrollFace.onPress = function() {
var currPos:Number = this._y;
startDrag(this, false, left, top, right, bottom);
this.onMouseMove = function() {
dy = Math.abs(initPosition-this._y);
descMenu_mc.descHolder_mc._y = Math.round(dy*-1*moveVal+initContentPos);
};
};
scrollFace.onMouseUp = function() {
stopDrag();
delete this.onMouseMove;
};
btnUp.onPress = function() {
this.onEnterFrame = function() {
if (descMenu_mc.descHolder_mc._y+speed<descMenu_mc.maskedView._y) {
if (scrollFace._y<=top) {
scrollFace._y = top;
} else {
scrollFace._y -= speed/moveVal;
}
descMenu_mc.descHolder_mc._y += speed;
} else {
scrollFace._y = top;
descMenu_mc.descHolder_mc._y = descMenu_mc.maskedView._y;
delete this.onEnterFrame;
}
};
};
btnUp.onDragOut = function() {
delete this.onEnterFrame;
};
btnUp.onRelease = function() {
delete this.onEnterFrame;
};
btnDown.onPress = function() {
this.onEnterFrame = function() {
if (descMenu_mc.descHolder_mc._y-speed>finalContentPos) {
if (scrollFace._y>=bottom) {
scrollFace._y = bottom;
} else {
scrollFace._y += speed/moveVal;
}
descMenu_mc.descHolder_mc._y -= speed;
} else {
scrollFace._y = bottom;
descMenu_mc.descHolder_mc._y = finalContentPos;
delete this.onEnterFrame;
}
};
};
btnDown.onRelease = function() {
delete this.onEnterFrame;
};
btnDown.onDragOut = function() {
delete this.onEnterFrame;
};
if (contentHeight<maskHeight) {
scrollFace._visible = false;
btnUp.enabled = false;
btnDown.enabled = false;
} else {
scrollFace._visible = true;
btnUp.enabled = true;
btnDown.enabled = true;
}
};