/******************************************
Data Typing and Instantiations
******************************************/
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
/******************************************
load Method
******************************************/
xmlLoader.load(new URLRequest("homeflash.xml"));
/******************************************
Complete Event
******************************************/
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
//trace(xmlData);
var xpos:Number = 0;
for (var i:int = 0; i < xmlData.project.length(); i++) {
trace("------------ project " + i+" ------------");
trace("imageName: " + xmlData.project.imageName.text()[i]);
trace("theURL: " + xmlData.project.theURL.text()[i]);
//Create an object for each project and put it in the container
var newTitle:MovieClip = new myTitle();
container.addChild(newTitle);
//image
var request:URLRequest = new URLRequest("homegallery/"+xmlData.project.imageName.text()[i]);
var loader:Loader = new Loader()
loader.load(request);
newTitle.placeholder.addChild(loader);
newTitle.placeholder.buttonMode = true;
//Position each one to the right of the previous one
newTitle.x = xpos;
xpos = xpos + newTitle.width;
//add button click
var theURL:URLRequest = new URLRequest(xmlData.project.theURL.text()[i]);
function gotoSite(event:MouseEvent):void {
navigateToURL((theURL), "_self");
}
newTitle.addEventListener(MouseEvent.CLICK, gotoSite);
}
}
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
/******************************************
Timer Event
******************************************/
var containerTimer:Timer=new Timer(10);
containerTimer.addEventListener(TimerEvent.TIMER, movecontainer);
function movecontainer(myevent:TimerEvent):void {
//distanceToTravel is the mouse position minus the center of the stage.
//Right side = positive number.
//Left side = negative number.
var distanceToTravel = this.mouseX-300;
//The closer the mouse is to the center, the slower
//it moves because there's less added or subtracted.
container.x -= distanceToTravel/40;
//If its' too far to the left or right then stop it.
var leftBounds = (container.width -497)*-1;
if (container.x0) {
container.x = 0;
}
}
containerTimer.start();
///Here is the XML:
blank.gif
http://www.kelliegraphicdesign.com/jsa
mtn.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-mountain.html
des.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-desert.html
urb.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-urban.html
com.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-community.html
grn.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-green.html
eat.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-eat.html
ply.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-play.html
wrk.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-work.html
pln.jpg
http://www.kelliegraphicdesign.com/jsa/portfolio/portfolio-plan.html
|