package be.quietkillah
{
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.system.Capabilities;
import flash.utils.Timer;
public class Impress extends MovieClip
{
private var background:Background;
private var navigation:Navigation;
private var copyright:Copyright;
private var contact:Contact;
private var logoimpress:Impresslogo;
private var slideshow:Slideshow;
private var home:ContentHome;
private var yHome:int;
private var yBedr:int;
private var yPrijs:int;
private var yInfo:int;
private var picture:uint = 1;
private var active:String;
private var timer:Timer;
public function Impress()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
this.addEventListener( Event.ADDED_TO_STAGE, initStage);
}
/********** POSITIONERING EN PLAATSING ITEMS **********/
//STAGE RESIZE
private function resizeHandler(event:Event):void{
//BACKGROUND
background.width = stage.stageWidth;
background.height = stage.stageHeight;
if(stage.stageWidth >= 1024){
//COPYRIGHT
copyright.x = stage.x;
copyright.y = stage.stageHeight;
//NAVIGATION
navigation.x = (stage.stageWidth/2) - (navigation.width/2) + 32;
//SLIDESHOW
slideshow.x = (stage.stageWidth/2) - (slideshow.width/2) + 15;
//CONTACT
contact.x = stage.stageWidth;
contact.y = stage.stageHeight;
//LOGO
logoimpress.x = stage.x + 25;
logoimpress.y = 10;
}
//NAVIGATION
yHome = navigation.home.y;
yBedr = navigation.bedrukking.y;
yInfo = navigation.informatie.y;
yPrijs = navigation.prijsvraag.y;
}
//INIT STAGE AT STARTUP
private function initStage(e:Event):void{
//STAGE
trace("Impress :: initStage :: Added To Stage");
//BACKGROUND
background = new Background();
background.x = stage.x;
background.width = stage.stageWidth;
background.height=stage.stageHeight;
addChild(background);
//LOGO
logoimpress = new Impresslogo();
logoimpress.width *= 0.6;
logoimpress.height *= 0.6;
logoimpress.x = stage.x + 25;
logoimpress.y = 10;
stage.addChild(logoimpress);
//SLIDESHOW
slideshow = new Slideshow();
slideshow.x = (stage.stageWidth/2) - (slideshow.width/2) + 15;
slideshow.y = 80;
stage.addChild(slideshow);
timer = new Timer(5000);
timer.start();
timer.addEventListener(TimerEvent.TIMER,onTick);
//COPYRIGHT
copyright = new Copyright();
addChild(copyright);
copyright.x = stage.x;
copyright.y = stage.stageHeight;
//CONTACT
contact = new Contact();
stage.addChild(contact);
contact.x = stage.stageWidth;
contact.y = stage.stageHeight;
//NAVIGATION
navigation = new Navigation();
navigation.y -=200;
navigation.x = (stage.stageWidth/2) - (navigation.width/2)+30;
stage.addChild(navigation);
navigation.addEventListener(MouseEvent.MOUSE_OVER,onNavHover);
navigation.addEventListener(MouseEvent.MOUSE_OUT,onNavHoverOut);
navigation.addEventListener(MouseEvent.CLICK,onNavClick);
yHome = navigation.home.y;
yBedr = navigation.bedrukking.y;
yInfo = navigation.informatie.y;
yPrijs = navigation.prijsvraag.y;
resizeHandler(null);
stage.addEventListener(Event.RESIZE, resizeHandler);
}
/********** SLIDESHOW **********/
private function onTick(event:TimerEvent):void{
trace(picture);
picture +=1;
TweenPlugin.activate([TintPlugin]);
TweenLite.to(slideshow, 1, {tint:0x000000,onComplete:onTweenKlaar});
}
private function onTweenKlaar():void{
if (picture < 19){
slideshow.gotoAndStop(picture);
}else{
slideshow.gotoAndStop(1);
}
TweenPlugin.activate([TintPlugin]);
TweenLite.to(slideshow, 1, {tint:null});
}
/********** NAVIGATIE **********/
//HOVERS
private function onNavHover(event:MouseEvent):void{
switch(event.target.name){
case "home":
TweenLite.to(navigation.home, 1, {y:(yHome+190), ease:Cubic.easeOut});
break;
case "bedrukking":
TweenLite.to(navigation.bedrukking, 1, {y:(yBedr+190), ease:Cubic.easeOut});
break;
case "informatie":
TweenLite.to(navigation.informatie, 1, {y:(yInfo+190), ease:Cubic.easeOut});
break;
case "prijsvraag":
TweenLite.to(navigation.prijsvraag, 1, {y:(yInfo+190), ease:Cubic.easeOut});
break;
}
}
private function onNavHoverOut(event:MouseEvent):void{
switch(event.target.name){
case "home":
TweenLite.to(navigation.home, 1, {y:(yHome), ease:Cubic.easeOut});
break;
case "bedrukking":
TweenLite.to(navigation.bedrukking, 1, {y:(yBedr), ease:Cubic.easeOut});
break;
case "informatie":
TweenLite.to(navigation.informatie, 1, {y:(yInfo), ease:Cubic.easeOut});
break;
case "prijsvraag":
TweenLite.to(navigation.prijsvraag, 1, {y:(yPrijs), ease:Cubic.easeOut});
break;
}
}
//CLICKS
private function onNavClick(event:MouseEvent):void{
//overal checken welke pagina actief is!
trace(event.target.name);
switch(event.target.name){
case "home":
if(active != "home"){
active = "home";
home = new ContentHome;
stage.addChildAt(home,2);
home.y = stage.stageHeight + 10;
home.x = (stage.stageWidth/2) - (home.width/2);
stage.addEventListener(Event.RESIZE, homeResize);
TweenLite.to(home, 1, {y:(stage.stageHeight/2 - home.height/2), ease:Expo.easeInOut});
}
break;
case "bedrukking":
if (active != "bedrukking"){
active = "bedrukking";
}
break;
case "informatie":
if(active != "informatie"){
active = "informatie";
}
break;
case "prijsvraag":
if(active != "prijsvraag"){
active = "prijsvraag";
}
break;
}
}
private function homeResize(event:Event):void{
if (stage.stageHeight >= 900){
home.y = (stage.stageHeight/2 - home.height/2);
home.x = (stage.stageWidth/2) - (home.width/2);}
}
}
}