//________ MENU ________
// Importing the transition class
import mx.transitions.*;
import mx.transitions.easing.*;
easeSpeed = 3; // set the ease sensetivity
MovieClip.prototype.elasticScale = function(toSize) {
easeType = mx.transitions.easing.Regular.easeInOut;
myTween = new Tween(this, "_yscale", easeType, this._yscale, toSize, easeSpeed);
myTween = new Tween(this, "_xscale", easeType, this._xscale, toSize, easeSpeed);
};
//////////////////////////////////////////////////////////////////////////
// Here the array object is created.
var rubrieken:Array = new Array();
// Here the XML object is created.
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success) {
// De data from the xml is loaded into flash
// Using a 'for' loop the data is placed inside the array
if (success) {
menuItems = this.firstChild;
for (i=0; i<menuItems.childNodes.length; i++) {
rubriek = menuItems.childNodes[i];
rubrieken.push(rubriek);
}
}
// As soon as the data is loaded int the array the function below will be executed
attachMenu();
};
myXML.load("xml/menu.xml");
// This function attaches the people figures to the stage with the right data
function attachMenu() {
// This margin variable sets the space on the right and the left. roght now 80px;
margin = (Stage.width-680)/rubrieken.length;
for (i=0; i<rubrieken.length; i++) {
loadDude = rubrieken[i].attributes.dude;
var menuItems = peopleHolder.attachMovie(loadDude, "dude"+i, 10000+i);
menuItems._x = menuItems._x+(margin)*i;
// This inline fuction executes the proximity function onEnterFrame
menuItems.onEnterFrame = function() {
proximity(this);
};
menuItems._href = rubrieken[i].attributes.href;
menuItems.idText = rubrieken[i].attributes.dudesname;
menuItems.knopTekst.text = rubrieken[i].attributes.naam;
// The events when you roll over the button
menuItems.onRollOver = function() {
this.swapDepths(10000+i);
// makes the tooltip appear
this.nameTip._alpha = 100;
// Out the name from the xml inside the tooltip
this.nameTip.idTag.text = this.idText;
};
menuItems.onRollOut = function() {
// makes the tooltip disappear
this.nameTip._alpha = 0;
};
menuItems.onRelease = function() {
getURL(this._href, "_self");
};
}
}
//////////////////////////////////////////////////////////////////////////
// This here is the function that calculates the size of each item depending on the proximity of the mouse position
// You could play a little with these number but it is kinda tricky.
function proximity(clip) {
var x:Number = peopleHolder._xmouse;
var y:Number = peopleHolder._ymouse;
var cx:Number = clip._x;
var cy:Number = clip._y-clip._height/2;
var prox:Number = Math.sqrt((x-cx)*(x-cx)+(y-cy)*(y-cy));
// if the mouse is closer to the object than 100px it increases its size
if (prox<100) {
clipx = 300-prox*2;
clip.elasticScale(clipx);
// if the mouse is futher away than 100 it keeps it original size
} else {
clipx = 100;
clip.elasticScale(clipx);
}
}