var config:XML = new XML();
config.ignoreWhite = true;
config.onLoad = loadConfig;
config.load("xml/news/config.xml");
function loadConfig(success:Boolean):Void {
if (success) {
var all:XMLNode = config.firstChild;
mainX = Number(all.childNodes[0].firstChild.nodeValue);
mainY = all.childNodes[1].firstChild.nodeValue;
noPosts = Number(all.childNodes[2].firstChild.nodeValue);
postSpacing = Number(all.childNodes[3].firstChild.nodeValue);
sumLength = all.childNodes[4].firstChild.nodeValue;
sumApend = all.childNodes[5].firstChild.nodeValue;
moreBtnNormal = all.childNodes[6].firstChild.nodeValue;
moreBtnOver = all.childNodes[7].firstChild.nodeValue;
moreBtnTextColor = all.childNodes[8].firstChild.nodeValue;
moreBtnColorSpeed = Number(all.childNodes[9].firstChild.nodeValue);
alwaysShowMore = all.childNodes[10].firstChild.nodeValue;
arrowGlowColor = Number(all.childNodes[11].firstChild.nodeValue);
arrowGlowNormalAlpha = Number(all.childNodes[12].firstChild.nodeValue);
arrowGlowInAlpha = Number(all.childNodes[13].firstChild.nodeValue);
postSlideSpeed = Number(all.childNodes[14].firstChild.nodeValue);
fadeOutOldPost = Number(all.childNodes[15].firstChild.nodeValue);
fadeInNewPost = Number(all.childNodes[16].firstChild.nodeValue);
slideOutSpeed = Number(all.childNodes[17].firstChild.nodeValue);
slideInSpeed = Number(all.childNodes[18].firstChild.nodeValue);
fadeInSpeed = Number(all.childNodes[19].firstChild.nodeValue);
fadeOutSpeed = Number(all.childNodes[20].firstChild.nodeValue);
loadEverything();
} else {
trace("XML NOT LOADED");
}
}
import mx.transitions.Tween;
import mx.transitions.easing.*;
import caurina.transitions.Tweener;
import caurina.transitions.properties.ColorShortcuts;
ColorShortcuts.init();
import flash.filters.GlowFilter;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();
loadEverything = function () {
trace(noPosts);
scope = this.createEmptyMovieClip("scope", 1);
scope._x = mainX;
scope._y = mainY;
var news:XML = new XML();
news.ignoreWhite = true;
news.onLoad = buildposts;
news.load("xml/news/news.xml");
postNum = 1;
function buildposts(success:Boolean):Void {
if (success) {
var allXML:XMLNode = news.firstChild;
postTotal = allXML.childNodes.length;
allPosts = scope.createEmptyMovieClip("allPosts", 2);
var i:Number;
for (i=0; i<postTotal; i++) {
var post:MovieClip = allPosts.attachMovie("post", "post"+i, i+100);
post.bg._alpha = 0;
post.description.t.html = true;
post.description.t.autoSize = true;
post.headline = allXML.childNodes[i].childNodes[0].firstChild.nodeValue;
post.des = allXML.childNodes[i].childNodes[1].firstChild.nodeValue;
post.num = postNum++;
post.title.t.autoSize = true;
post.title.t.text = post.headline;
newsCSS = new TextField.StyleSheet();
cssURL = "css/news/news.css";
newsCSS.load(cssURL);
newsCSS.onLoad = function(success) {
if (success) {
post.description.t.styleSheet = newsCSS;
}
};
if (post.des.length>sumLength) {
sum = post.des.substring(0, sumLength);
lastSpace = sum.lastIndexOf(" ");
post.description.t.htmlText = sum.substring(0, lastSpace)+sumApend;
} else {
post.description.t.htmlText = post.des;
if (alwaysShowMore == "false") {
post.moreBtn._visible = false;
}
}
// end of summary code
post.title.onRelease = post.moreBtn.onRelease=function () {
buildlargePost(this._parent);
};
moreColor = new Color(post.moreBtn.bg);
moreColor.setRGB(moreBtnNormal);
post.moreBtn.txt.t.textColor = moreBtnTextColor;
post.moreBtn.onRollOver = function() {
Tweener.addTween(this.bg, {_color:moreBtnOver, time:moreBtnColorSpeed, transition:"linear"});
};
post.moreBtn.onRollOut = function() {
Tweener.addTween(this.bg, {_color:moreBtnNormal, time:moreBtnColorSpeed, transition:"linear"});
};
post._y = allPosts['post'+(i-1)]._y+allPosts['post'+(i-1)]._height+postSpacing;
if (i<noPosts) {
post._alpha = 100;
} else {
post._alpha = 0;
}
}
nav = scope.attachMovie("nav", "nav", 4);
nav._y = (post.bg._height*noPosts)+(postSpacing*noPosts)-5;
navMask = scope.attachMovie("postsMask", "navMask", 10);
navMask._y = nav._y;
navMask._x = nav._x;
navMask._width = post.bg._width;
navMask._height = 30;
nav.setMask(navMask);
glowIn = new GlowFilter(arrowGlowColor, arrowGlowInAlpha, 5, 5, 5, 10, false, false);
glowOut = new GlowFilter(arrowGlowColor, arrowGlowNormalAlpha, 5, 5, 5, 10, false, false);
string manipulation
"+postTotal+" "+counterEnd;
nav.postNav.newerBtn._alpha = 30;
nav.postNav.newerBtn.enabled = false;
Tweener.addTween(nav.postNav.newerBtn, {_filter:glowOut, time:0});
Tweener.addTween(nav.postNav.olderBtn, {_filter:glowOut, time:0});
var id:Number = 0;
nav.postNav.olderBtn.onRelease = function():Void {
if (id>=0 && id<postTotal-noPosts) {
Tweener.addTween(nav.postNav.newerBtn, {_alpha:100, time:1});
nav.postNav.newerBtn.enabled = true;
endPos = ((id+1)*post.bg._height)+(postSpacing*(id+1));
slide(allPosts, allPosts._y, -endPos, postSlideSpeed, "_y", Strong.easeInOut);
fade(allPosts['post'+id], 100, 0, fadeOutOldPost, Strong.easeOut);
var newPost:Number = id+noPosts;
fade(allPosts['post'+newPost], 0, 100, fadeInNewPost, Strong.easeInOut);
ID
id++;
}
if (id == postTotal-noPosts) {
Tweener.addTween(this, {_filter:glowOut, time:3});
this.enabled = false;
Tweener.addTween(this, {_alpha:30, time:1});
}
firstPost = (id+1);
lastPost = id+noPosts;
};
nav.postNav.newerBtn.onRelease = function():Void {
if (id<postTotal && id>0) {
Tweener.addTween(nav.postNav.olderBtn, {_alpha:100, time:1});
nav.postNav.olderBtn.enabled = true;
var newPost:Number = id-1;
var oldPost:Number = id+noPosts-1;
endPos = (id-1)*(post.bg._height+postSpacing);
slide(allPosts, allPosts._y, -endPos, postSlideSpeed, "_y", Strong.easeInOut);
fade(allPosts['post'+newPost], 0, 100, fadeInNewPost, Strong.easeInOut);
fade(allPosts['post'+oldPost], 100, 0, fadeOutOldPost, Strong.easeOut);
id--;
}
button
if (id == 0) {
Tweener.addTween(this, {_filter:glowOut, time:3});
Tweener.addTween(this, {_alpha:30, time:1});
this.enabled = false;
}
text
firstPost = (id+1);
lastPost = id+noPosts;
};
nav.postNav.newerBtn.onRollOver = nav.postNav.olderBtn.onRollOver=function ():Void {
Tweener.addTween(this, {_filter:glowIn, time:3});
};
nav.postNav.newerBtn.onRollOut = nav.postNav.olderBtn.onRollOut=nav.postNav.olderBtn.onRollOut=function ():Void {
Tweener.addTween(this, {_filter:glowOut, time:3});
};
postsMask = scope.attachMovie("postsMask", "postsMask", 5);
postsMask._y = allPosts._y;
postsMask._x = allPosts._x;
postsMask._height = (post.bg._height*noPosts)+(postSpacing*noPosts);
postsMask._width = post._width;
allPosts.setMask(postsMask);
} else {
trace("XML NOT LOADED");
}
}
};
buildlargePost = function (targetPost) {
removeMovieClip(scope.largePost);
slide(nav, nav._y, nav._y-30, slideOutSpeed, "_y", Strong.easeInOut);
slide(allPosts, allPosts._x, -postsMask._width*2, slideOutSpeed, "_x", Strong.easeInOut);
fade(allPosts, 100, 0, fadeOutSpeed, Strong.easeOut);
largePost = scope.attachMovie("largePost", "largePost", scope.getNextHighestDepth());
slide(largePost, postsMask._width*2, 0, slideInSpeed, "_x", Strong.easeInOut);
fade(largePost, 0, 100, fadeInSpeed, Strong.easeInOut);
largePost.txt.title.text = targetPost.headline;
largeMask = scope.attachMovie("postsMask", "largeMask", 5000);
largeMask._height = postsMask._height+40;
largeMask._width = postsMask._width;
largeMask._y = -40;
largePost.setMask(largeMask);
largePost.txt.description.autoSize = "left";
largePost.txt.description.html = true;
largePost.txt.description.htmlText = targetPost.des;
largePost.txt.description.styleSheet = newsCSS;
Tweener.addTween(nav.largeNav.backBtn, {_filter:glowOut, time:0});
nav.largeNav.backBtn.onRelease = function() {
slide(nav, nav._y, nav._y+30, slideOutSpeed, "_y", Strong.easeInOut);
slide(largePost, 0, postsMask._width*2, slideOutSpeed, "_x", Strong.easeInOut);
fade(largePost, largePost._alpha, 0, fadeOutSpeed, Strong.easeOut);
slide(allPosts, allPosts._x, 0, slideInSpeed, "_x", Strong.easeInOut);
fade(allPosts, allPosts._alpha, 100, fadeInSpeed, Strong.easeInOut);
};
nav.largeNav.backBtn.onRollOver = function():Void {
and older buttons
Tweener.addTween(this, {_filter:glowIn, time:3});
};
nav.largeNav.backBtn.onRollOut = function():Void {
Tweener.addTween(this, {_filter:glowOut, time:3});
};
};