Actionscript Code:
override public function transitionIn():void
{
super.transitionIn();
gotoAndPlay("in");
// Prevent main nav from being clicked in background
bgbutton.useHandCursor = false;
//Opening page animation
sectionpage.scaleX = 0.2;
sectionpage.scaleY = 0.2;
newsMask.scaleX = 0.2;
newsMask.scaleY = 0.2;
TweenLite.to(sectionpage, 0.2, {x:388,y:382,scaleX:1,scaleY:1,ease:Linear.easeOut});
TweenLite.to(newsMask, 0.2, {x:388,y:382,scaleX:1,scaleY:1,ease:Linear.easeOut});
//CLOSE BUTTON;
sectionpage.closebutton.addEventListener(MouseEvent.CLICK, closeFunction);
function closeFunction(evt:MouseEvent):void
{
TweenLite.to(sectionpage, 0.2, {alpha:0,ease:Linear.easeIn});
Gaia.api.goto(Pages.HOME);
}
//sectionpage.arrowLeft.cacheAsBitmap = true;
newsMask.cacheAsBitmap = true;
sectionpage.containerMC.cacheAsBitmap = true;
sectionpage.containerMC.mask = newsMask;
sectionpage.textBody.styleSheet = IStyleSheet(Gaia.api.getPage("index").assets.stylesheet).style;
var myXML:XML = IXml(assets.newsContent).xml;
sectionpage.textTitle.htmlText = myXML.sectionContent.title;
sectionpage.textBody.htmlText = myXML.sectionContent.body;
var dateFormat:TextFormat = new TextFormat();
dateFormat.color = 0xFFFFFF;
dateFormat.font = Gaia.api.getFontName("DIN");
dateFormat.size = 18;
//sectionpage.containerMC.columns = [];
//sectionpage.containerMC.columns.push(sectionpage.containerMC.newsColumn);
var posts:Array = [];
var lastY:Number = 0;
var columnHeight:Number = 330;
//var column:DisplayObjectContainer = sectionpage.containerMC.columns[0];
var column:DisplayObjectContainer = new Sprite();
sectionpage.containerMC.addChild(column);
sectionpage.columns = [];
sectionpage.columns.push(column);
for (var i:int = 0; i<myXML.news.length(); i++)
{
var date:String = myXML.news.newsDate[i];
var title:String = myXML.news.newsTitle[i];
var body:String = myXML.news.newsBody[i];
var newsPost:NewsPost = new NewsPost(date,title,body,dateFormat);
posts.push(newsPost);
if (lastY + newsPost.height > columnHeight)
{
var nextX:Number = column.x + column.width;
column = new MovieClip();
//column.x = nextX;
column.x = 600;
sectionpage.columns.push(column);
sectionpage.containerMC.addChild(column);
column.y = 0;
lastY = 0;
}
column.addChild(newsPost);
//sectionpage.newsColumn.addChild(newsPost);
newsPost.y = lastY;
lastY += newsPost.height + 40;
}
// Counters to help determine column position
var activeCol:Number = 0;
var nextCol:Number = 1;
var prevCol:Number = -1;
var totalPosts:Number = sectionpage.containerMC.columns.length-1;
sectionpage.arrowLeft.alpha=0;
sectionpage.arrowLeft.addEventListener(MouseEvent.CLICK, scrollLeft);
sectionpage.arrowRight.addEventListener(MouseEvent.CLICK, scrollRight);
function arrowLOFF():void{sectionpage.arrowLeft.visible=false;}
function arrowROFF():void{sectionpage.arrowRight.visible=false;}
function scrollLeft(evt:MouseEvent):void
{
TweenLite.to(sectionpage.containerMC.columns[activeCol], 0.25, {x:600,ease:Linear.easeOut});
TweenLite.to(sectionpage.containerMC.columns[prevCol], 0.25, {x:0,ease:Linear.easeOut});
activeCol--;
nextCol--;
prevCol--;
if (activeCol == 0)
{
sectionpage.arrowLeft.removeEventListener(MouseEvent.CLICK, scrollLeft);
TweenLite.to(sectionpage.arrowLeft, 0.25, {alpha:0,onComplete:arrowLOFF});
}
if (activeCol == totalPosts-1)
{
sectionpage.arrowRight.addEventListener(MouseEvent.CLICK, scrollRight);
sectionpage.arrowRight.visible=true;
TweenLite.to(sectionpage.arrowRight, 0.25, {alpha:1});
}
}
function scrollRight(evt:MouseEvent):void
{
TweenLite.to(sectionpage.containerMC.columns[activeCol], 0.25, {x:-600,ease:Linear.easeOut});
TweenLite.to(sectionpage.containerMC.columns[nextCol], 0.25, {x:0,ease:Linear.easeOut});
activeCol++;
nextCol++;
prevCol++;
if (activeCol == totalPosts)
{
sectionpage.arrowRight.removeEventListener(MouseEvent.CLICK, scrollRight);
TweenLite.to(sectionpage.arrowRight, 0.25, {alpha:0,onComplete:arrowROFF});
};
if (activeCol == 1)
{
sectionpage.arrowLeft.addEventListener(MouseEvent.CLICK, scrollLeft);
sectionpage.arrowLeft.visible=true;
TweenLite.to(sectionpage.arrowLeft, 0.25, {alpha:1,ease:Linear.easeOut});
}
}