i created a xml drive movieClip thats kind a really simple gallery
i posted all the code but the part that is in red is where I am having difficulty,
I can’t get it to go to the different URLs I defined in the url child node. can anyone tell me how to get the that part to work e.event.target is not working
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.;
import flash.filters.;
import flash.geom.ColorTransform;
var i:int=0;
var xmove:Tween=new Tween(icons, “x”, Back.easeInOut, 242.35, 31.8, 2, true);
function moverL(){
var xmoveL:Tween=new Tween(icons, “x”, Back.easeInOut, icons.x, icons.x - 205, 2, true);
}
function moverR(){
var xmoveR:Tween=new Tween(icons, “x”, Back.easeInOut, icons.x, icons.x + 205, 2, true);
}
RightArrow.addEventListener(MouseEvent.CLICK, moveRight);
function moveRight(event:MouseEvent):void {
if (i<3){
moverL();
trace(icons.x)
i= i+1
trace(i);
}
}
LeftArrow.addEventListener(MouseEvent.CLICK, moveLeft);
function moveLeft(event:MouseEvent):void {
if (i !=0){
moverR();
trace(icons.x)
i= i-1
trace(i);
}
}
import flash.display.*;
var StageObj:Array = [LeftArrow, RightArrow, titleText, bg];
trace(StageObj);
// Set the “y” location on stage where the first btn will live
// Set the “x” location on stage where all btns will line up vertically
var line1xpos:int = -68;
// Set the distance each btn should be apart here
var distance:int =68;
// Initialize the XML, place the xml file name, initialize the URLRequest
// put URLRequest into a new URLLoader, and add event listener on
// myLoader listening for when the XML loading is complete
var myXML:XML = new XML();
var XML_URL:String = “settings/icon.xml”;
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener(“complete”, xmlLoaded);
// Create the xmlLoaded function
function xmlLoaded(event:Event):void {
// Place the xml data into the myXML object
myXML = XML(myLoader.data);
// Initialize and give var name to the new external XMLDocument
var xmlDoc:XMLDocument = new XMLDocument();
// Ignore spacing around nodes
xmlDoc.ignoreWhite = true;
// Define a new name for the loaded XML that is the data in myLoader
var menuXML:XML = XML(myLoader.data);
// Parse the XML data into a readable format
xmlDoc.parseXML(menuXML.toXMLString());
// Access the value of the "galleryFolder" node in our external XML file
for each (var galleryFolder:XML in myXML..galleryFolder) {
// Access the value of the "pagenum" node in our external XML file
var galleryDir:String = galleryFolder.toString();
}
trace (galleryDir);
// Set the index number of our loop, increments automatically
var i:Number = 0;
// Run the "for each" loop to iterate through all of the menu items listed in the external XML file
for each (var MenuItem:XML in myXML..MenuItem) {
// Access the value of the "pagenum" node in our external XML file
var picnum:String = MenuItem.picnum.toString();
// Access the value of the "pagetext" node in our external XML file
var Caption:String = MenuItem.Caption.toString();
// Access the value of the "thumb" node in our external XML file
var thumb:String = MenuItem.thumb.toString();
// Access the value of the "pagepicture" node in our external XML file
var listurl:String = MenuItem.urlstring.toString();
trace(listurl, Caption, picnum, thumb)
var thumbLdr:Loader = new Loader();
var thumbURLReq:URLRequest = new URLRequest(thumb);
thumbLdr.load(thumbURLReq);
// Create MovieClip holder for each thumb
var thumb_mc = new MovieClip();
thumb_mc.addChild(thumbLdr);
addChildAt(thumb_mc, 1);
line1xpos = line1xpos + distance;
thumb_mc.x = line1xpos;
var names:String = thumb_mc.name;
thumb_mc.name="thumb_mc"+picnum;
thumb_mc.buttonMode=true;
thumb_mc.addEventListener(MouseEvent.CLICK, clipClick);
thumb_mc.addEventListener(MouseEvent.ROLL_OVER, onRollover);
thumb_mc.addEventListener(MouseEvent.ROLL_OUT, onRollout);
[COLOR="DarkRed"]thumb_mc.clickToPage = listurl;
// Set the function for what happens when that button gets clicked
function clipClick(e:Event):void {
var targetURL:String = e.target.clickToPage;
var urlRequest:URLRequest = new URLRequest(targetURL);
navigateToURL(urlRequest);
}[/COLOR]
function onRollover(event:MouseEvent):void {
var colorTransform:ColorTransform = event.target.transform.colorTransform;
colorTransform.color = 0xF37431;
event.target.transform.colorTransform = colorTransform;
}
function onRollout(event:MouseEvent):void {
var colorTransform2:ColorTransform = event.target.transform.colorTransform;
colorTransform2.color = 0x005AAA;
event.target.transform.colorTransform = colorTransform2;
//event.target.y = event.target.y+3
}
icons.addChild(thumb_mc);
var theTextField:TextField = new TextField();
theTextField.type = TextFieldType.DYNAMIC;
theTextField.border = false;
theTextField.x = line1xpos - 8;
theTextField.y = 44;
theTextField.width = 60;
theTextField.multiline = false;
theTextField.wordWrap = true;
addChild(theTextField);
theTextField.htmlText=Caption;
theTextField.textColor=0x0D4A7E;
theTextField.width=60;
icons.addChild(theTextField);
trace(thumb_mc.name);
//This is the section for our text styling, first we create a TextFormat instance naming it myFormat
var myFormat:TextFormat = new TextFormat();
//Giving the format a hex decimal color code
myFormat.color = 0x0D4A7E;
//Adding some bigger text size
myFormat.size = 9;
myFormat.align = TextFormatAlign.CENTER;
//Last text style is to make it italic.
myFormat.italic = false;
myFormat.bold = false;
theTextField.setTextFormat(myFormat);
} // This closes the "for each" loop
} // And this closes the xmlLoaded function
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
icons.mask = iconMask;