Hello, I’d be grateful for your thoughts on this. I have an interactive floorplan with information on each store unit coming from the XML and creating a store directory. That’s all okay, as you’ll see in the link below.
http://www.iconymous.com/clients/whitewater2/directory.asp
My problem is - I need each unit to change colour and the little information panel to appear when it is rolled over on the map.
I can do this by making each mc a button and putting the code directly in the button. But I wanted to be clever and do it with some kind of array. I’ve just hit a mental brick wall! So any advice is welcome.
This is my very messy actionscript! If you’ve any ideas for improvements, I’m all ears :beer2:
scrollPane.setStyle("borderStyle", "none");
UpperLevel._visible=false;
/////////////////////////////// XML LOADING ///////////////////////////////
var xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = function(loaded) {
if (loaded) {
MainMenu();
} else { }
}
xmlData.load("pages.xml");
/////////////////////////////// MAIN PAGE CONTENT ///////////////////////////////
function GetPage() {
items = xmlData.firstChild.childNodes;
for (var i = 0; i<items.length; i++) {
if (items*.attributes.id == currentunit) {
page.id.text = items*.attributes.id;
page.pagename.text = items*.attributes.storename;
page.unitlevel = items*.attributes.level;
page.parentname.text = items*.attributes.parentname;
page.image.text = items*.childNodes[0].firstChild.nodeValue;
page.imgcontainer.loadMovie(items*.childNodes[0].firstChild.nodeValue);
if (page.unitlevel == 1){
page._x = UpperLevel[unitname]._x +20;
page._y = UpperLevel[unitname]._y +20;
}
else {
page._x = GroundLevel[unitname]._x +20;
page._y = GroundLevel[unitname]._y +20;
}
}}}
/////////////////////////////// MAIN MENU ///////////////////////////////
function MainMenu() {
var initX = 0;
var initY = 0;
var item_count = 0;
scrollPane.contentPath = "scrollMovieClip";
menu_mc=scrollPane.content;
items = xmlData.firstChild.childNodes;
//this bit creates an array for the various movieclips on the floorplan
mainArray = new Array();
for(var i=0;i<items.length;i++){
unitlevel = items*.attributes.level;
currentunit=items*.attributes.id;
storename = items*.attributes.storename;
unitname = "unit"+items*.attributes.id;
mainArray* = new Array(currentunit,unitlevel,storename,unitname);
trace(mainArray*);
}
for (var element in mainArray) {
// btn is a pointer to one of the nav buttons
var btn:MovieClip = GroundLevel.unitMandS;
currentunit = "MandS";
// assign functions to each event
btn.onRollOver = doRollOver;
btn.onRollOut = doRollOut;
btn.onRelease = doClick;
}
function doRollOver() {
if (this != activebtn) {
this._alpha = 50;
GetPage();
}
}
//this bit creates the menu
for (var i = 0; i<items.length; i++) {
item_count++;
var menuItem = menu_mc.attachMovie("menuitem","unit" + items*.attributes.id, item_count);
menuItem._x = initX;
menuItem._y = initY;
menuItem.unitid = items*.attributes.id;
menuItem.identifier.text = items*.attributes.id;
menuItem.pagename.text = items*.attributes.storename;
menuItem.unitlevel = items*.attributes.level;
menuItem.link = items*.attributes.link;
menuItem.onPress = btnOnPress;
menuItem.onRollOver = btnOnRollover;
menuItem.onRollOut = btnOnRollout;
initY +=18;
}
}
/////////////////////////////// BUTTON ON PRESS ///////////////////////////////
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
function btnOnPress(){
getURL(this.link,"_parent");
}
function btnOnRollover(){
currentunit = this.unitid;
unitname = "unit" + this.unitid;
//unitname = this._name;
//currentunit = "Debenhams";
if (this.unitlevel == 1){UpperLevel._visible=true;GroundLevel._visible=false;var trans:Transform = new Transform(_root.UpperLevel[unitname]);}
else {UpperLevel._visible=false;GroundLevel._visible=true;var trans:Transform = new Transform(_root.GroundLevel[unitname]);}
this.menubg.gotoAndPlay("_over");
_root[this.unitover].gotoAndPlay("_over");
colorTrans.rgb = 0xFF0000;
trans.colorTransform = colorTrans;
GetPage();
}
function btnOnRollout(){
_root[this.unitover].gotoAndPlay("_out");
if (this.unitlevel == 1){var trans:Transform = new Transform(_root.UpperLevel[unitname]);}
else {var trans:Transform = new Transform(_root.GroundLevel[unitname]);}
colorTrans.rgb = 0xF8B323;
trans.colorTransform = colorTrans;
this.menubg.gotoAndPlay("_out")
}