XML text menu selecting problem
hello all
i built xml video menu displays simple text xml document in movieclip added sprite titled btncontainer, btncontainer added stage. once buttons selected load appropriate video. problem having want button selected change color. there 3 different xml files loaded depending on 3 static buttons on stage ie 2009 / 2008 / 2007. default 2009 xml file loaded in. code works fine first time script runs - when 1 of xml buttons selected changes colors, , returns other buttons default color- when click on button 2008 or 2007 , xml files load, , buttons not change color. when click on button 2009, , 2009 xml loads button changes color rest of buttons not change default state? code below
thanks in advance help
import fl.video.*;
import gs.*;
import gs.easing.*;
//----------------------------------variables--------------------------------
var vid:flvplayback;
vid = new flvplayback();
vid.source = "video/press_long_beach_2009.flv";
vid.width = 480
vid.height = 360
vid.skin = "skinunderplaystopseekmutevol.swf";
vid.skinbackgroundcolor = 0x000000;
vid.skinbackgroundalpha = .5
addchild(vid)
vid.x = 385
vid.y = 80
var myloader:loader = new loader();
var container:movieclip = new movieclip;
var xml:xml = new xml;
var xmllist:xmllist = new xmllist;
var xmlloader:urlloader = new urlloader;
var dateloader:loader
var datebtn:mcdatebtn
var items_array:array = new array();
var btncontainer:movieclip = new movieclip;
var boxcontainer:sprite = new sprite();
//-------------------------------------------add listeners------------------------------
xmlloader.load(new urlrequest("data/2009videos.xml"))
xmlloader.addeventlistener(event.complete, xmlcomplete)
yearbtncontainer.btn09.addeventlistener(mouseevent.click, showyearbtns)
yearbtncontainer.btn08.addeventlistener(mouseevent.click, showyearbtns)
yearbtncontainer.btn07.addeventlistener(mouseevent.click, showyearbtns)
//------------------------------------------functions------------------------------------
function showyearbtns(event:event):void
{
if(this.contains(btncontainer))
{
for(var i:int = 0; i< xmllist.length(); i++)
{
btncontainer.removechildat(0);
}
}
if(event.target == yearbtncontainer.btn09)
{
xmlloader.load(new urlrequest("data/2009videos.xml"))
}
else if(event.target == yearbtncontainer.btn08)
{
xmlloader.load(new urlrequest("data/2008videos.xml"))
}
else if(event.target == yearbtncontainer.btn07)
{
xmlloader.load(new urlrequest("data/2007videos.xml"))
}
}
function xmlcomplete(event:event):void
{
xml=xml(event.target.data);
xmllist=xml.children();
for(var i:int = 0; < xmllist.length(); i++)
{
trace("working")
datebtn = new mcdatebtn;
items_array.push(datebtn);
btncontainer.addchild(datebtn)
datebtn.x = 20;
datebtn.y = i*60 + 100;
datebtn.name = xmllist[i].attribute("videourl")
datebtn.datetxt.htmltext = xmllist[i];
datebtn.datetxt.wordwrap = true
datebtn.datetxt.width = 270;
datebtn.datetxt.height = 90;
datebtn.datetxt.background = true;
datebtn.datetxt.backgroundcolor = 0x333333;
datebtn.mousechildren = false;
datebtn.buttonmode = true;
datebtn.id = i;
datebtn.addeventlistener(mouseevent.click, showimage)
trace('underneath')
}
addchild(btncontainer)
}
function showimage(event:mouseevent):void
{
for(var j:int=0; j < xmllist.length();j++)
{
//trace(event.target.id)
if(j==event.currenttarget.id)
{
trace("working color")
tweenlite.to(event.target, .3, {tint:0xffdb00, ease:strong.easeout});
}
else if(!event.currenttarget.select)
{
trace("working no color")
//trace(items_array[i])
items_array[j].select=false;
items_array[j].mouseenabled=true;
tweenlite.to(items_array[j], .5, {tint:0xffffff, ease:strong.easeout});
}
}
vid.source = event.target.name
}
it doesn't you're clearing items_array()
More discussions in ActionScript 3
adobe
Comments
Post a Comment