mainClass
private function init():void
{
gotoAndStop(2);
Mouse.hide();
removeChild(preLoader);
_mainBG=new mainBG();
addChild(_mainBG);
TweenMax.to(_mainBG,0,{x:stage.stageWidth/2,y:stage.stageHeight});
addMainMenu(xmlArray[0]);
_logoLine=new logoLine();
addChild(_logoLine);
TweenMax.to(_logoLine,0,{x:stage.stageWidth/2,y:stage.stageHeight-stage.stageHeight/8});
_lightBG=new lightBG();
addChild(_lightBG);
_mouseCursorMc=new mouseCursorMc();
addChild(_mouseCursorMc);
_mainFrame=new mainFrame();
addChild(_mainFrame);
TweenMax.to(_mainFrame,0,{dropShadowFilter:{color:0x000000, alpha:.5, blurX:10, blurY:10, strength:.8}});
_mouseCursorMc.mouseEnabled=_lightBG.mouseEnabled=_lightBG.mouseChildren=_mouseCursorMc.mouseChildren=false;
stage.addEventListener(MouseEvent.MOUSE_MOVE,stageMouseHandler);
}
public function addMainMenu(xml:XMLList):void
{
_mainMenu=new mainMenu();
_mainMenu.xml=xml;
TweenMax.to(_mainMenu,0,{x:stage.stageWidth/2,y:stage.stageHeight/2});
addChildAt(_mainMenu,1);
currentPage=_mainMenu;
pageNum=0;
buttonPrototype.allbutton(_mainMenu.menuArray,null,null,clickHandler);
}
private function clickHandler(evt:MouseEvent):void
{
TweenMax.to(currentPage,.3,{alpha:0, scaleX:4, scaleY:4, onComplete:removeMenu});
pageNum=evt.target.ID;
TweenMax.to(_logoLine,1,{y:stage.stageHeight+250});
if (evt.target.gallery)
{
folder=new createFolder();
folder.path=galleryPath;
folder.xml=xmlArray[1].child(pageNum);
addChild(folder);
currentPage=folder;
_goBack=new goBack;
addChild(_goBack);
_goBack.addEventListener(MouseEvent.CLICK,goBackClick);
}
}
private function goBackClick(evt:MouseEvent):void
{
if (currentPage==folder)
{
TweenMax.to(folder,1,{alpha:0, onComplete:folderRemove});
}
function folderRemove():void
{
removeChild(folder);
removeChild(_goBack);
addMainMenu(xmlArray[0]);
TweenMax.to(_logoLine,0,{x:stage.stageWidth/2,y:stage.stageHeight-stage.stageHeight/8});
}
}
private function removeMenu():void
{
removeChild(_mainMenu);
}
//Mouse Handler
private function stageMouseHandler(evt:MouseEvent):void
{
TweenMax.to(_mouseCursorMc,.5,{x:mouseX,y:mouseY,motionBlur:true,ease:Strong.easeOut});
TweenMax.to(_lightBG,0,{x:mouseX,y:mouseY});
if(currentPage==_mainMenu)
{
TweenMax.to(currentPage,0,{x:-(stage.mouseX-_mainMenu.width+(_mainMenu.width-stage.stageWidth)),
dropShadowFilter:{color:0x000000, alpha:1, blurX:30, blurY:30, strength:.8,
angle:-Math.atan2(stage.mouseY - _mainMenu.y,_mainMenu.x-stage.mouseX) / (Math.PI / 180), distance:15}});
}
else if (currentPage==folder)
{
TweenMax.to(currentPage,0,{x:-(currentPage.width+25-stage.stageWidth)/stage.stageWidth * stage.mouseX - currentPage.width + (currentPage.width-stage.stageWidth/2),
dropShadowFilter:{color:0x000000, alpha:1, blurX:30, blurY:3-0, strength:.8,
angle:-Math.atan2(stage.mouseY - currentPage.y,currentPage.x-stage.mouseX) / (Math.PI / 180), distance:15}});
}
}
subClass:
public class createFolder extends MovieClip
{
TweenPlugin.activate([TransformMatrixPlugin]);
public var xml:XMLList=new XMLList();
public var path:String=new String();
public function createFolder()
{
this.addEventListener(Event.ADDED_TO_STAGE,init);
}
private function init(evt:Event):void
{
this.removeEventListener(Event.ADDED_TO_STAGE,init);
var eff:brightnessEff=new brightnessEff();
var folderLength:int = xml.children().length();
var _folder:MovieClip;
var folderCont:MovieClip=new MovieClip();
var folderItems:Array=new Array();
var folderArray:Array=new Array();
var folderImageLoader:ImageLoader;
var xProp:Number = 0;
var i:int = 0;
loadImage();
TweenMax.to(folderCont,0,{x:stage.stageWidth/2, y:stage.stageHeight/2});
folderCont.y = stage.stageHeight - 580;
addChild(folderCont);
function loadImage():void
{
_folder=new folder();
_folder.x = xProp;
_folder.name = "_folder" + i;
_folder.ID = i;
folderArray.push(_folder);
folderItems* = [folderArray*.blackMc,folderArray*.circleMc,folderArray*.plusMc,folderArray*.title,folderArray*.desc];
TweenMax.allTo(folderItems*,0,{alpha:0});
folderImageLoader=new ImageLoader(path+xml.child(i).@img,{name:"image"+i, onComplete:loaded});
folderArray*.addChildAt(folderImageLoader.content,2);
folderImageLoader.load();
folderItems*[3].text = String(xml.child(i). @ title);
folderItems*[4].text = String(xml.child(i). @ desc);
folderCont.addChild(folderArray*);
buttonPrototype.button(folderArray*,overFolder,outFolder,clickFolder);
}
function loaded(evt:LoaderEvent):void
{
evt.target.content.parent.resizeFolder(evt.target.content.width,evt.target.content.height);
xProp = evt.target.content.parent.width + evt.target.content.parent.x + 50;
TweenMax.from(evt.target.content,1,{alpha:0});
i++;
if (i<folderLength)
{
loadImage();
}
}
function overFolder(evt:MouseEvent):void
{
eff.brightnessEffIn(evt);
TweenMax.to(folderItems[evt.target.ID][0],.5,{alpha:.9});
TweenMax.to(folderItems[evt.target.ID][1],.5,{alpha:.2});
TweenMax.to(folderItems[evt.target.ID][2],.5,{alpha:1});
TweenMax.to(folderItems[evt.target.ID][3],.5,{alpha:1});
TweenMax.to(folderItems[evt.target.ID][4],.5,{alpha:1});
TweenMax.to(folderItems[evt.target.ID][2],.2,{transformMatrix:{rotation:180,scaleX:1.2,scaleY:1.2},delay:.5});
}
function outFolder(evt:MouseEvent):void
{
eff.brightnessEffOut(evt);
TweenMax.to(folderItems[evt.target.ID][2],.2,{transformMatrix:{rotation:0,scaleX:1,scaleY:1}});
TweenMax.allTo(folderItems[evt.target.ID],.5,{alpha:0,delay:.2});
}
function clickFolder(evt:MouseEvent):void
{
//TweenMax.allTo(folderArray,.5,{alpha:0,transformAroundCenter:{scaleX:0, scaleY:0}},0,removeFolders);
/*function removeFolders():void
{
buildSlideItems(xml[0].child(evt.target.ID),galleryPath);
removeChild(galleryFolders);
}*/
}
}
Thanks