View Full Version : help me with comboBox
egoldy
03-15-2005, 01:05 AM
hi everyone
I use comboBox make a links.the code like this:
stop();
import mx.controls.ComboBox;
import mx.transitions.Tween;
import mx.transitions.easing.*;
Stage.scaleMode = "noscale";
createClassObject(ComboBox,"my_combo",this.getNextHighestDepth(),{_x:90,_y:30});
my_combo.setSize(200);
my_combo.setStyle("openEasing",Elastic.easeOut);
my_combo.setStyle("openDuration",800);
//loadxml
myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("http://www.webstudio.com.cn/wsswf/c...nks/example.xml");
myXML.onLoad =function(success){
// --
if(success){
links = new Array();
// --
for (var i = 0; i<myXML.firstChild.childNodes.length; i++) {
links.addItem({label:myXML.firstChild.childNodes[i].childNodes, data:myXML.firstChild.childNodes[i].attributes.url});
}
}else{
trace("cannot load xml");
}
// --
//add listenerobject
listenerObject = new Object();
listenerObject.change = function(event) {
//
//getURL(links[my_combo.selectedIndex].data,"_blank");
getURL(event.target.getValue(),"_blank");
trace(event.target.getValue());
};
// --
my_combo.addEventListener("change", listenerObject);
my_combo.dataProvider = links;
}
the demo is here:
the demo is here:
http://www.webstudio.com.cn/wsswf/c...nks/combxml.swf
the xml file is here:
http://www.webstudio.com.cn/wsswf/c...nks/example.xml
but why the first link is not work?and when you first click another links then click the first link ,It is work why?
thanks a lot.
SrinivasSM
03-15-2005, 09:40 AM
Hi,
Give a Trace Statement inside
myXML.onLoad =function(success){
trace(my_combo)
}
After the Result I hope U would Have understood what the problem is?!
egoldy
03-15-2005, 01:41 PM
Hi,
Give a Trace Statement inside
myXML.onLoad =function(success){
trace(my_combo)
}
After the Result I hope U would Have understood what the problem is?!
hi.SrinivasSM
thanks for you reply.
I have done it .like your said.
It is output "_level0.my_combo",however,I can't find where the problem is?
I hope you can help me..thanks.
SrinivasSM
03-16-2005, 06:36 AM
Hey
I could Not access neither the demo swf file or ur example.xml file.So please if u can send me the XML File and your Fla File I will try to load it locally and then find solution for ur problem.
egoldy
03-17-2005, 12:42 AM
hi SrinivasSM
here is the fla files ,include the xml file.
http://www.webstudio.com.cn/comboxml.rar
the demo here:
http://www.webstudio.com.cn/wsswf/combolinks/combxml.swf
the xml file here:
http://www.webstudio.com.cn/wsswf/combolinks/example.xml
thanks a lot
egoldy
03-18-2005, 03:57 PM
hi SrinivasSM
do you have check out the flas :(
SrinivasSM
03-21-2005, 05:30 AM
Sorry,Guy I was On Leave For These Days.I Mean I went to for trip so i could not answer you don't worry by the end of the Day i mean Today I will post it to you.
SrinivasSM
03-21-2005, 06:41 AM
HI eGoldy!
Hey Bellow is the Code which you have to replace ur myXML.onLoad() function.
Which will do ur job.
myXML.onLoad = function(success) {
// --
listenerObject = new Object();
listenerObject.change = function(event) {
//使用这一行同样可以达到目的。
//getURL(links[my_combo.selectedIndex].data,"_blank");
getURL(event.target.getValue(), "_blank");
trace(event.target.getValue());
};
my_combo.addEventListener("change", listenerObject);
if (success) {
links = new Array();
// --
for (var i = 0; i<myXML.firstChild.childNodes.length; i++) {
links.addItem({label:myXML.firstChild.childNodes[i].childNodes, data:myXML.firstChild.childNodes[i].attributes.url});
}
my_combo.dataProvider = links;
my_combo.dispatchEvent({type:"change"});
} else {
trace("cannot load xml");
}
// --
//加入侦听对象
// --
};
I hope This is What Your are asking For.!
egoldy
03-29-2005, 03:48 PM
hi. SrinivasSM
thanks for you reply. I am very bussy for these days.
I have checked out your code.and test it .
but I found when the swf run ,it will auto open the first link.
I only want to click the first link then open the link .
Thanks a lot.sorry for my bad english :confused:
HI eGoldy!
Hey Bellow is the Code which you have to replace ur myXML.onLoad() function.
Which will do ur job.
myXML.onLoad = function(success) {
// --
listenerObject = new Object();
listenerObject.change = function(event) {
//使用这一行同样可以达到目的。
//getURL(links[my_combo.selectedIndex].data,"_blank");
getURL(event.target.getValue(), "_blank");
trace(event.target.getValue());
};
my_combo.addEventListener("change", listenerObject);
if (success) {
links = new Array();
// --
for (var i = 0; i<myXML.firstChild.childNodes.length; i++) {
links.addItem({label:myXML.firstChild.childNodes[i].childNodes, data:myXML.firstChild.childNodes[i].attributes.url});
}
my_combo.dataProvider = links;
my_combo.dispatchEvent({type:"change"});
} else {
trace("cannot load xml");
}
// --
//加入侦听对象
// --
};
I hope This is What Your are asking For.!
SrinivasSM
03-30-2005, 05:17 AM
Hi,
I did not get you even now...actually you said that the first link is not working when it is opened first time.I hope now it opens.If this is not the one you require then tell what actually you want in simple english so that i can help you.
egoldy
03-30-2005, 01:16 PM
ok.
like my first thread question
when the swf run,you can click the first link and you will find it is not work.
After you click the second link,then click the first link ,it works fine.
that is my question.
Hi,
I did not get you even now...actually you said that the first link is not working when it is opened first time.I hope now it opens.If this is not the one you require then tell what actually you want in simple english so that i can help you.
SrinivasSM
03-31-2005, 01:15 PM
Hi,
The Problem is when you go and choose the same option,the combo box does not dispatch the change event as the value of the combo box text is not changed hence when u click it first time the same link it won't work when you change it some thing else and then come back to the first link the event change has occured and so it works...I hope you got my point..
egoldy
04-01-2005, 05:28 PM
ye,that is my question. as your said. it cannot chang :(
Thanks very very much for your reply.
Hi,
The Problem is when you go and choose the same option,the combo box does not dispatch the change event as the value of the combo box text is not changed hence when u click it first time the same link it won't work when you change it some thing else and then come back to the first link the event change has occured and so it works...I hope you got my point..
SrinivasSM
04-03-2005, 09:00 AM
Hi,
So for the above problem what you have to do is just have function which takes in the previous value of the combo box and the currently changed item and then dispatch the event change.
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.