Hello everybody,
I am creating a flash website that is pretty much loading everything externally. I have some links that are loaded in by xml and I would like for them to change color when you rollover them.
Ok I will give you the full actionscript and then the few excerpts from that actionscript where I think it should go, but hey I could be wrong it hasn’t worked for me yet. heh.
stop();
desc_txt.embedFonts = true;
rollover = new Sound(this);
rollover.attachSound("click.mp3")
click = new Sound(this);
click.attachSound("click2.mp3");
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
/* image = [];
gallerytitle = [];
menutitle = [];
copy = [];*/
for (i=0; i<xmlNode.childNodes.length; i++) {
/* image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
gallerytitle* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
menutitle* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
copy* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;*/
menutitle_fn(i);
}
_root.attachMovie("TopBar","Bar",_root.getNextHighestDepth())
Bar._x = -100
g = 0;
n = 0;
Info_mc.onRollOver = function(){
this.onEnterFrame = function(){
if(n < 10){this._y -= 0
this.spinArrow._rotation += 9
n++
}else{this.onEnterFrame = null}
}}
Info_mc.onRollOut = function(){
this.onEnterFrame = function(){
if(n > 0){this._y += 0
this.spinArrow._rotation -= 9
n--
}else{this.onEnterFrame = null}
}}
Info_mc.createTextField("comment_text",1,-Info_mc._width/2,20-Info_mc._height/7,Info_mc._width,Info_mc._height)
//Format the gallery buttons
infofrmt = new TextFormat()
infofrmt.font = "Arial";
infofrmt.size = 14;
infofrmt.bold = false;
infofrmt.italic = false;
//end info text formatting
Info_mc.comment_text.multiline = true;
Info_mc.comment_text.wordWrap = true;
Info_mc.comment_text.background = false;
Info_mc.comment_text.border = false;
Info_mc.comment_text.selectable = false;
Info_mc.comment_text.setTextFormat(infofrmt);
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("printfolio.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
click.start();
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
click.start();
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
cols = 1; //the number of columns you want
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
gallerytitle_txt.text = xmlNode.childNodes[g].attributes.name;
Info_mc.comment_text.text = xmlNode.childNodes[g].childNodes[p].attributes.info;
Info_mc.comment_text.setTextFormat(infofrmt);
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
/* picture.onRelease = function(){
getURL(xmlNode.childNodes[g].childNodes[p].attributes.source,_blank)
}*/
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 7;
}
}
};
function nextImage() {
if (p<(xmlNode.childNodes[g].childNodes.length-1)) {
p++;
} else {
p = 0; // Resets to first image
}
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(xmlNode.childNodes[g].childNodes[p].attributes.source,1);
Info_mc.comment_text.text = xmlNode.childNodes[g].childNodes[p].attributes.info;
//gallerytitle_txt.text = gallerytitle[p];
picture_num();
}
}
function prevImage() {
if (p>0) {
p--;
//picture._alpha = 0;
//picture.loadMovie(xmlNode.childNodes[g].childNodes[p].attributes.source, 1);
//gallerytitle_txt.text = gallerytitle[p];
//picture_num();
} else {
p = xmlNode.childNodes[g].childNodes.length-1; // resets to last image
}
picture._alpha = 0;
picture.loadMovie(xmlNode.childNodes[g].childNodes[p].attributes.source,1);
Info_mc.comment_text.text = xmlNode.childNodes[g].childNodes[p].attributes.info;
//gallerytitle_txt.text = gallerytitle[p];
picture_num();
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(xmlNode.childNodes[g].firstChild.attributes.source,1);
Info_mc.comment_text.text = xmlNode.childNodes[g].firstChild.attributes.info;
gallerytext_txt.text = xmlNode.childNodes[g].attributes.name;
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+xmlNode.childNodes[g].childNodes.length;
}
function nextGallery() {
if (loaded == filesize) {
picture._alpha = 0;
/* if(g < xmlNode.childNodes.length){g++
}else{g = 0}*/
p = 0;
picture.loadMovie(xmlNode.childNodes[g].firstChild.attributes.source, 1);
Info_mc.comment_text.text = xmlNode.childNodes[g].childNodes[p].attributes.info;
gallerytext_txt.text = xmlNodes.childNodes[g].attributes.name;
picture_num();
}
}
function menutitle_fn(k) {
target_mc = _root.createEmptyMovieClip("t"+k, _root.getNextHighestDepth());
target_mc.createTextField("txt",1,0,0,90,40);
//Format the gallery buttons
btntxtstyle = new TextFormat()
btntxtstyle.font = "times";
btntxtstyle.size = 18;
btntxtstyle.bold = false;
btntxtstyle.italic = false;
btntxtstyle.color = 0x000000 //hexadecimal RGB color of button text
overColor = new TextFormat();
//create standardColor textFormat
target_mc.txt.border = false;
target_mc.txt.backgroundColor = 0xFFFFFF //hexadecimal RGB color of button
target_mc.txt.autoSize = "right"
//end gallery button formatting
target_mc.txt.background = false;
target_mc.txt.selectable = false;
target_mc.txt.text = xmlNode.childNodes[k].attributes.name
target_mc.txt.setTextFormat(btntxtstyle);
/* tlistener = new Object();
tlistener.onLoadInit = function(target_mc)
{*/
target_mc._x = (slider_mc._x + (k%cols)*(target_mc._width+7));
target_mc._y = slider_mc._y + Math.floor(k/cols)*(target_mc._height+7);
target_mc.pictureValue = k;
target_mc.onEnterFrame = function(){
this._y = slider_mc._y + slider_mc.menu_mc._y + Math.floor(this.pictureValue/cols)*(this._height+7)}
target_mc.onRelease = function() {
click.start();
g = this.pictureValue;
nextGallery();
this.txt._alpha = 30;
};
target_mc.onRollOver = function() {
rollover.start();
this.txt._alpha = 50;
};
target_mc.onRollOut = function() {
this.txt._alpha = 100;
};
};/*
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip("images/menu_cat.jpg", "slider_mc.menu_mc.t"+k);
}*/
aaaand…I thin that something either goes here (this controls the sounds of the menu buttons)
rollover = new Sound(this);
rollover.attachSound("click.mp3")
click = new Sound(this);
click.attachSound("click2.mp3");
or here…(this controls the color of the menu buttons)
//Format the gallery buttons
btntxtstyle = new TextFormat()
btntxtstyle.font = "times";
btntxtstyle.size = 18;
btntxtstyle.bold = false;
btntxtstyle.italic = false;
btntxtstyle.color = 0x000000 //hexadecimal RGB color of button text
overColor = new TextFormat();
//create standardColor textFormat
target_mc.txt.border = false;
target_mc.txt.backgroundColor = 0xFFFFFF //hexadecimal RGB color of button
target_mc.txt.autoSize = "right"
//end gallery button formatting
target_mc.txt.background = false;
target_mc.txt.selectable = false;
target_mc.txt.text = xmlNode.childNodes[k].attributes.name
target_mc.txt.setTextFormat(btntxtstyle);
Please help anyone!!
Thanks.
-ashley