I don’t know how to explain this in any easy way so please bear with me and sorry for the long text.
I’m creating a webpage where all the content is within the same swf. In order to get things to work I have all my different content in different MC’s. Each of those separate MC’s have two frames inside. One where it’s empty and the other where the content is displayed. To make this work I have a variable name ‘page’. My menu is supposed to pass a string to this variable and at the same time trigger a transition to be played (‘doors’ sliding over and hiding the stage). Then the transition sets all my content MC’s to the hide position. Then it checks what the page variable is and sets the corresponding content MC to show before the ‘doors’ open again. At least that’s how it’s supposed to work in theory. But I haven’t figured out how to do all this. First off I don’t know how to get my menu to pass that string to the ‘page’ variable. Here’s my menu with the problem area marked:
stop();
// link variables
var urls = ['hjemFrm', 'guttaFrm', 'sponsorFrm', 'bussenFrm', 'http://gjestebok.nuffe.net/11668'];
// Button labels
var labels = ['HJEM', 'GUTTA', 'SPONSOR', 'BUSSEN', 'CHAT'];
for (var i = 0; i<labels.length; i++)
{
var btn = this['l'+i+'_btn'];
var mc = this['l'+i+'_mc'];
mc.textLabel.text = labels*;
btn.defaultPos = mc._x;
btn.id = i;
// assign a lnk variable from the urls array
btn.lnk = urls*;
btn.onRollOver = function()
{
var mc = this._parent['l'+this.id+'_mc'];
mc.targetx = this.defaultPos+9;
mc.dx = 3;
mc.onEnterFrame = moveMe;
};
btn.onRollOut = function()
{
var mc = this._parent['l'+this.id+'_mc'];
mc.targetx = this.defaultPos;
mc.dx = -3;
mc.onEnterFrame = moveMe;
};
btn.onRelease = function()
{
if(this.id==4)
{
getURL(this.lnk);
}
else
{
// PROBLEM !!!!
page(this.lnk);
}
}
}
function moveMe()
{
if (this._x == this.targetx)
{
delete this.onEnterFrame;
}
else
{
this._x += this.dx;
}
}
The other problem is, how do I get my menu to do nothing if it is on the page which button was clicked. The rest I think I might be able to do but if anyone wants to spell it out for me it would be grately appriciated. thx in advance guys.
EDIT!
This is all the code that’s at my _root timeline at the moment:
stop();
// Create page varialbe
var page:String;
// Initially set page value
// page = 'main'
trace (page);
Then, the first code exists on a separate layer inside an MC called ‘menu.MC’. meny.MC is placed on the main timeline. I changed the code in menu.MC to this:
else
{
// PROBLEM !!!!
_root.page = this.lnk;
//trace(this.lnk)
}
The trace on the main timeline still comes out as undefined even when I click the different buttons. Somehow it still dosn’t work. what am I doing wrong?