stop ();
//import flash.system.System;
//system.usecodepage = true;
Stage.align = "TL"
Stage.scaleMode = "noScale";
//
//variables
var totalClipNumber : Number;
var currentYear : Number = 0;
var myData : Array = new Array ();
var container : MovieClip = this.createEmptyMovieClip ("container", this.getNextHighestDepth ());
var bl : MovieClip = this.createEmptyMovieClip ("bl", this.getNextHighestDepth ());
var br : MovieClip = this.createEmptyMovieClip ("br", this.getNextHighestDepth ());
//
_global.setStage = function ()
{
sliding = new Object ();
sliding.onResize = function ()
{
removeMovieClip (masca);
removeMovieClip (hmenu);
createMask ();
createHMenu ();
bLeft._x = 0;
bLeft._y = Stage.height - 20;
bRight._x = Stage.width - 40;
bRight._Y = Stage.height - 20
}
Stage.addListener (sliding);
sliding.onResize ();
}
////
setStage ();
///
myXML = new XML ();
myXML.ignoreWhite = true;
myXML.load ("content.xml" );
myXML.onLoad = function (_status)
{
if (_status)
{
xmlItems = myXML.firstChild.childNodes;
totalClipNumber = xmlItems.length;
for (var i = 0; i < totalClipNumber; i ++)
{
myData.push (new Info (xmlItems [i].attributes.year, "images/" + xmlItems [i].attributes.pic, xmlItems [i].attributes.text));
}
buttonEvents ();
loadingMenuItems ();
attachText (0);
dataLoad (0);
scrolling ();
}
};
///
//
//initialising button events
buttonEvents = function ()
{
bLeft.swapDepths(bl);
bRight.swapDepths(br);
removeMovieClip(bl);
removeMovieClip(br);
//
bLeft.onRelease = bLeft.onReleaseOutside = function ()
{
if (hmenu._x + 30 < 40)
{
hmenu._x += 30;
}
else
{
if (hmenu._x < 40)
{
hmenu._x = 40;
}
}
}
bRight.onRelease = bRight.onReleaseOutside = function ()
{
if (hmenu._x - 30 > Stage.width - totalClipNumber * 30 - 40)
{
hmenu._x -= 30;
}
else
{
if (hmenu._x > Stage.width - totalClipNumber * 30 - 40)
{
hmenu._x = Stage.width - totalClipNumber * 30 - 40;
}
}
}
}
//
loadingMenuItems = function ()
{
for (var i = 0; i < totalClipNumber; i ++)
{
var itemh = hmenu.attachMovie ("itemH", "year" + i, i ,
{
_x : 30 * i, _y : 0
});
itemh.h_text.text = myData [i].year;
itemh.loc = i;
//initialising events
itemh.onRollOver = function ()
{
if (currentYear != this.loc)
{
this.itemHMask.tween ("_y", 0,.5, "easeOutCubic" );
}
}
//
itemh.onRollOut = function ()
{
if (currentYear != this.loc)
{
this.itemHMask.tween ("_y", 20, 1, "easeOutCubic" );
}
}
//
itemh.onRelease = itemh.onReleaseOutside = function ()
{
if (currentYear != this.loc)
{
container.tween ("_x", 0 - container ["t" + this.loc]._x, 2, "easeOutExpo" );
hmenu ["year" + currentYear].itemHMask.tween ("_y", 20,.5, "easeOutCubic" );
currentYear = this.loc;
}
}
//
}
/////
hmenu ["year" + currentYear].itemHMask.tween ("_y", 0,.5, "easeOutCubic" );
}
//////// creating the mask
function createMask ()
{
this.createEmptyMovieClip ("masca", 300);
masca._x = 0;
masca._y = 0;
masca.beginFill (0x000000, 100);
masca.lineTo (Stage.width, 0);
masca.lineTo (Stage.width, Stage.height - 20);
masca.lineTo (0, Stage.height - 20);
masca.lineTo (0, 0);
masca._alpha = 0;
}
//
///// creating the menu
function createHMenu ()
{
this.createEmptyMovieClip ("hmenu", 298);
hmenu._x = 40;
hmenu._y = Stage.height - 20;
hmenu.beginFill (0xFFFFFF, 100);
hmenu.lineTo (Stage.width - 80, 0);
hmenu.lineTo (Stage.width - 80, 20);
hmenu.lineTo (0, 20);
hmenu.lineTo (0, 0);
this.createEmptyMovieClip ("hmenuMask", 299);
hmenuMask._x = 40;
hmenuMask._y = Stage.height - 20;
hmenuMask.beginFill (0x667E38, 100);
hmenuMask.lineTo (Stage.width - 80, 0);
hmenuMask.lineTo (Stage.width - 80, 20);
hmenuMask.lineTo (0, 20);
hmenuMask.lineTo (0, 0);
hmenu.setMask (hmenuMask);
loadingMenuItems ();
}
/////// scrolling function
scrolling = function ()
{
this.onEnterFrame = function ()
{
xval = _xmouse;
yval = _ymouse;
///
if (masca.hitTest (xval, yval, true) == true)
{
d = Math.cos (((masca._xmouse) / masca._width) * Math.PI) * 15;
if (d < 0)
{
if (masca._width / 2 - container ["t" + (currentYear + 1)]._x > container._x)
{
hmenu ["year" + currentYear].itemHMask.tween ("_y", 20,.5, "easeOutCubic" );
currentYear ++;
hmenu ["year" + currentYear].itemHMask.tween ("_y", 0,.5, "easeOutCubic" );
}
}
else
{
if (masca._width / 2 - container ["t" + currentYear]._x < container._x)
{
hmenu ["year" + currentYear].itemHMask.tween ("_y", 20,.5, "easeOutCubic" );
currentYear --;
hmenu ["year" + currentYear].itemHMask.tween ("_y", 0,.5, "easeOutCubic" );
}
}
}
else
{
d = 0;
}
container._x += d;
if (container._x > masca._x)
{
container._x = masca._x;
}
if (container._x < (masca._x - (container._width - masca._width)))
{
container._x = masca._x - (container._width - masca._width);
}
};
};
//
// load data on stage function
dataLoad = function (picNr)
{
var my_mcl : MovieClipLoader = new MovieClipLoader ();
var mclListener : Object = new Object ();
mclListener.onLoadError = function (target_mc : MovieClip, errorCode : String, status : Number)
{
};
mclListener.onLoadStart = function (target_mc : MovieClip) : Void
{
};
mclListener.onLoadProgress = function (target_mc : MovieClip, numBytesLoaded : Number, numBytesTotal : Number) : Void
{
};
mclListener.onLoadComplete = function (target_mc : MovieClip, status : Number) : Void
{
};
mclListener.onLoadInit = function (target_mc)
{
if (picNr < totalClipNumber - 1)
{
if (myData [picNr + 1].picPath == "images/" )
{
do
{
attachText (picNr + 1);
picNr ++;
}
while (myData [picNr].picPath == "images/" );
//
dataLoad (picNr);
} else
{
attachText (picNr + 1);
picNr ++;
dataLoad (picNr);
}
} else
{
//trace ("am terminat" );
}
};
my_mcl.addListener (mclListener);
var imgholder : MovieClip = container.createEmptyMovieClip ("p" + picNr, picNr * 2);
imgholder._x = container._width;
my_mcl.loadClip (myData [picNr].picPath, container ["p" + picNr]);
};
//
attachText = function (i)
{
var itemt = container.attachMovie ("itemT", "t" + i, i * 2 + 1 ,
{
_x : container._width, _y : 0
});
itemt.title_text.text = myData [i].year;
itemt.text_text.text = myData [i].text;
}