Filtering Data Out Of DataSet
peepz, i want to set the first item out of the dataset. I know how to do it with arrays (arrayname[1]) but its not working with datasets.
my script is:
Code:
stop();
this.myReceiveXMLConnector.trigger();
listener = new Object ();
listener.afterLoaded = function (evt) {
trace ("ready");
dataSet = evt.target;
dataSet.first();
i = 0;
_root.mcPullDownMenu.mcTitleBarTextHolder.titleBarText.text = dataSet.categoryName;
while (dataSet.hasNext() ) {
trace (dataSet.categoryName.id[1]);
var temp_mc = e_mc.attachMovie("catbutton", "b" + i, i);
temp_mc.titleText.text = dataSet.categoryName;
temp_mc._y = - 100 + i * 21;
_root.temp_mc2height=Math.round(temp_mc._height);
temp_mc.category = dataSet.categoryID;
temp_mc.onRollOver = function () {
this.mcRollOver.gotoAndPlay(2);
}
temp_mc.onRollOut = temp_mc.onReleaseOutside = function () {
this.mcRollOver.gotoAndPlay(16);
}
dataSet.next ();
i ++;
}
}
this.myDataSet.addEventListener ("afterLoaded", listener);
i thought i have to do this:
temp_mc.titleText.text = dataSet.categoryName[1];
but it's not working, getting undefined :S
please help?
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-17-2005, 11:05 AM
View Complete Forum Thread with Replies
Sponsored Links:
Filtering Data Out Of DataSet
peepz, i want to set the first item out of the dataset. I know how to do it with arrays (arrayname[1]) but its not working with datasets.
my script is:
Code:
stop();
this.myReceiveXMLConnector.trigger();
listener = new Object ();
listener.afterLoaded = function (evt) {
trace ("ready");
dataSet = evt.target;
dataSet.first();
i = 0;
_root.mcPullDownMenu.mcTitleBarTextHolder.titleBarText.text = dataSet.categoryName;
while (dataSet.hasNext() ) {
trace (dataSet.categoryName.id[1]);
var temp_mc = e_mc.attachMovie("catbutton", "b" + i, i);
temp_mc.titleText.text = dataSet.categoryName;
temp_mc._y = - 100 + i * 21;
_root.temp_mc2height=Math.round(temp_mc._height);
temp_mc.category = dataSet.categoryID;
temp_mc.onRollOver = function () {
this.mcRollOver.gotoAndPlay(2);
}
temp_mc.onRollOut = temp_mc.onReleaseOutside = function () {
this.mcRollOver.gotoAndPlay(16);
}
dataSet.next ();
i ++;
}
}
this.myDataSet.addEventListener ("afterLoaded", listener);
i thought i have to do this:
temp_mc.titleText.text = dataSet.categoryName[1];
but it's not working, getting undefined :S
please help?
View Replies !
View Related
Filtering Data Out Of DataSet
peepz, i want to set the first item out of the dataset. I know how to do it with arrays (arrayname[1]) but its not working with datasets.
my script is:
Code:
stop();
this.myReceiveXMLConnector.trigger();
listener = new Object ();
listener.afterLoaded = function (evt) {
trace ("ready");
dataSet = evt.target;
dataSet.first();
i = 0;
_root.mcPullDownMenu.mcTitleBarTextHolder.titleBarText.text = dataSet.categoryName;
while (dataSet.hasNext() ) {
trace (dataSet.categoryName.id[1]);
var temp_mc = e_mc.attachMovie("catbutton", "b" + i, i);
temp_mc.titleText.text = dataSet.categoryName;
temp_mc._y = - 100 + i * 21;
_root.temp_mc2height=Math.round(temp_mc._height);
temp_mc.category = dataSet.categoryID;
temp_mc.onRollOver = function () {
this.mcRollOver.gotoAndPlay(2);
}
temp_mc.onRollOut = temp_mc.onReleaseOutside = function () {
this.mcRollOver.gotoAndPlay(16);
}
dataSet.next ();
i ++;
}
}
this.myDataSet.addEventListener ("afterLoaded", listener);
[this is the rule where it's all about:
Code:
temp_mc.titleText.text = dataSet.categoryName;
i thought i have to do this:
temp_mc.titleText.text = dataSet.categoryName[1];
but it's not working, getting undefined :S
please help?
View Replies !
View Related
Issues Filtering DataSet Data
I am having some serios issues writing a function to filter the data displayed in a dataGrid linked to a dataSet. We are filtering the data using the dataSet.filterFunc method. The following code successfully filters the content:
Code:
_root.Zengarden.screenName.goals_ds.filtered = true;
_root.Zengarden.screenName.goals_ds.filterFunc = function(item:Object) {
return(item.Nature != "qg");
}
goals_ds is the instance name of the dataSet
Now, here is the function that i wrote to do the same thing but in a more dynamic manner:
Code:
_global.filterDataSet = function(dataSetName:String, colName:String, operator:String, match:String):Void {
_global.filterOperator=new String();
_global.filterOperator=operator;
_global.matchDS=new String();
_global.matchDS=match;
_global.colNameDS=new String();
_global.colNameDS=colName;
_root.Zengarden[dataSetName].filtered=true;
_root.Zengarden[dataSetName].filterFunc=function(item:Object) {
if(filterOperator == "==") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] == matchDS);
} else if(filterOperator == "!=") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] != matchDS);
} else if(filterOperator == ">") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] > matchDS);
} else if(filterOperator == "<") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] < matchDS);
} else if(filterOperator == ">=") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] >= matchDS);
} else if(filterOperator == "<=") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] <= matchDS);
}
}
}
then the function is called like this:
filterDataSet("goals_ds", "Nature", "!=", "qg");
in this case the output window displays "filterOperator is equal to !=" 6 times(the number of records in the dataSet)which means that the correct else if block has been entered into. Any help whatsoever with this issue would be GREATLY appreciated. I spent 4 hours tonight trying to get this working, but with no success. TIA for any help.
View Replies !
View Related
Multiple Filtering Dataset
I was wondering with the filtering dataset how would i filter the data with multiple filtering. Lets say you have a XML doc that has information that contain city people state. What i want to do is have the ability to filter people who are located in that city under that state.
Thanks...
I know you use the code like this but how do i filter on multiple items
Code:
employee_ds.filtered = true;
employee_ds.filterFunc = function (item:Object) {
// Filter out employees who are managers.
return(item.empType != "management");
};
View Replies !
View Related
Dataset Filtering Issues
I'm trying to convince a dataset to sort, and having many problems. I'm using hte following function:
Code:
function selectCoverage( option:String ):Void {
//xmlDataSet.filtered = false;
if( dataFilter == option ) {
dataFilter = "";
} else {
xmlDataSet.filtered = true;
xmlDataSet.filterFunc = function( item:Object ) {
trace( item.coverage.attributes.type == option );
return( item.coverage.attributes.type == option );
}
dataFilter = option;
}
ListBox.removeAll();
//xmlDataSet.refreshDestinations();
ListBox.refreshFomSources();
ListBox.sortItemsBy( "label", "ASC" );
}
I know it's returning the proper boolean values, but the list the receives the results isn't changing at all. If I uncomment the "xmlDataSet.filtered = false" line, it doesn't filter, but toggles the alphabetical sorting on and off. Anyone have any thoughts?
Rys
View Replies !
View Related
Dataset Filtering Issues
I'm trying to convince a dataset to sort, and having many problems. I'm using hte following function:
Code:
function selectCoverage( option:String ):Void {
//xmlDataSet.filtered = false;
if( dataFilter == option ) {
dataFilter = "";
} else {
xmlDataSet.filtered = true;
xmlDataSet.filterFunc = function( item:Object ) {
trace( item.coverage.attributes.type == option );
return( item.coverage.attributes.type == option );
}
dataFilter = option;
}
ListBox.removeAll();
//xmlDataSet.refreshDestinations();
ListBox.refreshFomSources();
ListBox.sortItemsBy( "label", "ASC" );
}
I know it's returning the proper boolean values, but the list the receives the results isn't changing at all. If I uncomment the "xmlDataSet.filtered = false" line, it doesn't filter, but toggles the alphabetical sorting on and off. Anyone have any thoughts?
Rys
View Replies !
View Related
Dataset Filtering. Advice Needed. Please Help
In the following example, filtering is enabled on the DataSet object named employee_ds. Suppose that each record in the DataSet collection contains a field named empType. The following filter function returns true if the empType field in the current item is set to "management"; otherwise, it returns false.
code:
employee_ds.filtered = true;
employee_ds.filterFunc = function(item:Object) {
// filter out employees who are managers...
return(item.empType != "management");
}
Say the 'item.empType' contains 3 managers and 2 assisstants.Would it be possible to modify this code to look through the empType node and if it finds one manager include it.. but filter out the other 2 managers and include 1 assisstant and filter out the other one.Basically what i want to create is a combobox/datagrid/listbox that lists every type of 'empType' ONCE.
Its for an application that im working on that requires a dynamically populated XML based menu system. I have no control over the XML file so I need it to populate this every time the application is loaded.
Anyone know if this can be achieved?? or the best way to achieve this??
I would love any help.. i'm on a tight deadline for this one. Thanks for your time.
View Replies !
View Related
Dataset Filtering. Advice Needed. Please Help
In the following example, filtering is enabled on the DataSet object named employee_ds. Suppose that each record in the DataSet collection contains a field named empType. The following filter function returns true if the empType field in the current item is set to "management"; otherwise, it returns false.
PHP Code:
employee_ds.filtered = true;employee_ds.filterFunc = function(item:Object) { // filter out employees who are managers... return(item.empType != "management");}
Say the 'item.empType' contains 3 managers and 2 assisstants.Would it be possible to modify this code to look through the empType node and if it finds one manager include it.. but filter out the other 2 managers and include 1 assisstant and filter out the other one.Basically what i want to create is a combobox/datagrid/listbox that lists every type of 'empType' ONCE.
Its for an application that im working on that requires a dynamically populated XML based menu system. I have no control over the XML file so I need it to populate this every time the application is loaded.
Anyone know if this can be achieved?? or the best way to achieve this??
I would love any help.. i'm on a tight deadline for this one. Thanks for your time.
View Replies !
View Related
Dataset Filtering. Advice Needed. Please Help
In the following example, filtering is enabled on the DataSet object named employee_ds. Suppose that each record in the DataSet collection contains a field named empType. The following filter function returns true if the empType field in the current item is set to "management"; otherwise, it returns false.
PHP Code:
employee_ds.filtered = true;employee_ds.filterFunc = function(item:Object) { // filter out employees who are managers... return(item.empType != "management");}
Say the 'item.empType' contains 3 managers and 2 assisstants.Would it be possible to modify this code to look through the empType node and if it finds one manager include it.. but filter out the other 2 managers and include 1 assisstant and filter out the other one.Basically what i want to create is a combobox/datagrid/listbox that lists every type of 'empType' ONCE.
Its for an application that im working on that requires a dynamically populated XML based menu system. I have no control over the XML file so I need it to populate this every time the application is loaded.
Anyone know if this can be achieved?? or the best way to achieve this??
I would love any help.. i'm on a tight deadline for this one. Thanks for your time.
View Replies !
View Related
Dataset Filtering. Advice Needed. Please Help
In the following example, filtering is enabled on the DataSet object named employee_ds. Suppose that each record in the DataSet collection contains a field named empType. The following filter function returns true if the empType field in the current item is set to "management"; otherwise, it returns false.
PHP Code:
employee_ds.filtered = true;
employee_ds.filterFunc = function(item:Object) {
// filter out employees who are managers...
return(item.empType != "management");
}
Say the 'item.empType' contains 3 managers and 2 assisstants.Would it be possible to modify this code to look through the empType node and if it finds one manager include it.. but filter out the other 2 managers and include 1 assisstant and filter out the other one.Basically what i want to create is a combobox/datagrid/listbox that lists every type of 'empType' ONCE.
Its for an application that im working on that requires a dynamically populated XML based menu system. I have no control over the XML file so I need it to populate this every time the application is loaded.
Anyone know if this can be achieved?? or the best way to achieve this??
I would love any help.. i'm on a tight deadline for this one. Thanks for your time.
View Replies !
View Related
Issue With Dynamically Filtering A DataSet's Output
I am having some serios issues writing a function to filter the data displayed in a dataGrid linked to a dataSet. We are filtering the data using the dataSet.filterFunc method. The following code successfully filters the content:
Code:
_root.Zengarden.screenName.goals_ds.filtered = true;
_root.Zengarden.screenName.goals_ds.filterFunc = function(item:Object) {
return(item.Nature != "qg");
}
goals_ds is the instance name of the dataSet
Now, here is the function that i wrote to do the same thing but in a more dynamic manner:
Code:
_global.filterDataSet = function(dataSetName:String, colName:String, operator:String, match:String):Void {
_global.filterOperator=new String();
_global.filterOperator=operator;
_global.matchDS=new String();
_global.matchDS=match;
_global.colNameDS=new String();
_global.colNameDS=colName;
_root.Zengarden[dataSetName].filtered=true;
_root.Zengarden[dataSetName].filterFunc=function(item:Object) {
if(filterOperator == "==") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] == matchDS);
} else if(filterOperator == "!=") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] != matchDS);
} else if(filterOperator == ">") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] > matchDS);
} else if(filterOperator == "<") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] < matchDS);
} else if(filterOperator == ">=") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] >= matchDS);
} else if(filterOperator == "<=") {
trace("filterOperator is equal to "+filterOperator);
return(item[colNameDS] <= matchDS);
}
}
}
then the function is called like this:
filterDataSet("goals_ds", "Nature", "!=", "qg");
in this case the output window displays "filterOperator is equal to !=" 6 times(the number of records in the dataSet)which means that the correct else if block has been entered into. Any help whatsoever with this issue would be GREATLY appreciated. I spent 4 hours tonight trying to get this working, but with no success. TIA for any help.
View Replies !
View Related
Filtering Data Using Flash
Hello All,
I am trying to create an interface that filters data on the client slide when users change their criteria.
I think using sliders is an interesting way to give the user a better way of filtering the data like the ones used at http://www.asfusion.com/apps/homelocator/ and http://examples.adobe.com/flex2/inpr...flexstore.html
Using check boxes and drop downs also seem to work as it can improve the users search/filter experience.
What is the best approach/methodology to use to build this sort of Flash solution? I want to build simple interfaces that can be used anytime with pre-defined data that the user can organize or filter by various different categories. Examples I can think of are product, house or holiday searches using categories such as price, quanity etc.
Any help given is greatly appreciated.
Thanks,
View Replies !
View Related
Filtering Data In Flash
Hi all
I've been developing a small application in flash using AS2.0. Generally the application accepts user input for product type and sizes, calculate the costs and display output of those calculated costs. Then I used a php script (running on localhost) to store the calculated costs with other associated info, such as operator name, date of calculation, etc. into a flat text file. So each entry takes a line of calculated data in that text file. I used '&' as delimiter for fields of each record.
Now I need to include a search feature in my application. User will search among the stored data using certain keywords and if matching record[s] are found, then it should retrieve and display on flash application screen.
I'm not sure if flash can handle it internally (i.e. to use loadVariable() to load into flash app and then search text string[s], or should I search that text file using a PHP script. What would make more sense for this case? I've been stuck here for a while since I'm pretty new to AS and PHP.
I appreciate all your advice.
View Replies !
View Related
Filtering Data In DataGrid
hi
i am new to AS3. As I was going thru live docs, i was able to load data from an xml file into a DataGrid, I want to know how to make it clickable - on clicking i want a specific data of a column display in a TextArea
Here is my xml
<sites>
<urls link="
View Replies !
View Related
Filtering Data Using Flash
Hello All,
I am trying to create an interface that filters data on the client slide when users change their criteria.
I think using sliders is an interesting way to give the user a better way of filtering the data like the ones used at http://www.asfusion.com/apps/homelocator/ and http://examples.adobe.com/flex2/inpr...flexstore.html
Using check boxes and drop downs also seem to work as it can improve the users search/filter experience.
What is the best approach/methodology to use to build this sort of Flash solution? I want to build simple interfaces that can be used anytime with pre-defined data that the user can organize or filter by various different categories. Examples I can think of are product, house or holiday searches using categories such as price, quanity etc.
Any help given is greatly appreciated.
Thanks,
View Replies !
View Related
Filtering Data In Flash
Hi
I've been developing a small application in flash using AS2.0. Generally the application accepts user input for product type and sizes, calculate the costs and display output of those calculated costs. Then I used a php script (running on localhost) to store the calculated costs with other associated info, such as operator name, date of calculation, etc. into a flat text file. So each entry takes a line of calculated data in that text file. I used '&' as delimiter for fields of each record.
Now I need to include a search feature in my application. User will search among the stored data using certain keywords and if matching record[s] are found, then it should retrieve and display on flash application screen.
I'm not sure if flash can handle it internally (i.e. to use loadVariable() to load into flash app and then search text string[s], or should I search that text file using a PHP script. What would make more sense for this case? I've been stuck here for a while since I'm pretty new to AS and PHP.
I appreciate all your advice.
View Replies !
View Related
AS2 - Filtering Data In Flash
Hi
I've been developing a small application in flash using AS2.0. Generally the application accepts user input for product type and sizes, calculate the costs and display output of those calculated costs. Then I used a php script (running on localhost) to store the calculated costs with other associated info, such as operator name, date of calculation, etc. into a flat text file. So each entry takes a line of calculated data in that text file. I used '&' as delimiter for fields of each record.
Now I need to include a search feature in my application. User will search among the stored data using certain keywords and if matching record[s] are found, then it should retrieve and display on flash application screen.
I'm not sure if flash can handle it internally (i.e. to use loadVariable() to load into flash app and then search text string[s], or should I search that text file using a PHP script. What would make more sense for this case? I've been stuck here for a while since I'm pretty new to AS and PHP.
I appreciate all your advice.
View Replies !
View Related
Filtering XML Data From Different Component Selections
I wanted to ask wich components in flash would be the best choice for this project, and would be easiest to program to achieve the desire effect?
I have started this project and used for my filter categories a LIST component, I made them filter correctly and added multiple selection. Now the time has come to filter the cards based on the two LIST component selections, not just one, and this is the place where I stopped. What concept should I use to make my XML filter based on selections from two different LIST components?
So I'm thinking maybe there is the easier way to do this than several list components. Maybe a DATA GRID?
Thnx.
To better understand my question here is the application itself http://milancvetkovic.50webs.com/CardCatalogue.html
And the code behing it:
PHP Code:
import fl.data.DataProvider;
var tError:String = "For some reason the content could not be loaded. We are sorry for the inconvenience";
var tErrorHolder:TextField = new TextField();
tErrorHolder.visible = false;
tErrorHolder.x = 200;
tErrorHolder.y = 50;
tErrorHolder.autoSize = TextFieldAutoSize.CENTER;
addChild(tErrorHolder);
var xmlLoader:URLLoader = new URLLoader();// kreiramo novi LOADER za XML
var xmlURL:URLRequest = new URLRequest("tblCard.xml");// kreiramo novi URL REQUEST
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);// dodajemo LOADERu slusac dogadjaja
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, loadError);
xmlLoader.load(xmlURL);// ucitavamo vrednost URL REQUESTa kao argument funkcije LOAD
var cardsXML:XML = new XML();// kreiramo novi XML objekat
cardsXML.ignoreWhitespace = true;// podesavamo mu svojstvo igonrisanja praznih linija
function loadError(evt:IOErrorEvent):void {
tErrorHolder.visible = true;
tErrorHolder.text = tError;
}
//xmlLoaded funkcija koja ce biti pozvana nakon LOAD COMPLETE dogadjaja - ucitavanja podataka
function xmlLoaded(evt:Event):void {
cardsXML = XML(xmlLoader.data);
var aEdition:Array = new Array();// Ovde definisemo niz u koji cemo ugurati nase XML podatke
for (var edition:String in cardsXML.tblEdition) {
var editionName:String = cardsXML.tblEdition[edition].txtEdition;// dodeljujemo privremenu promenljivu u kojoj cemo sacuvati ime kategorije
aEdition.push(editionName);// uguravamo ovu promenljivu uz pomoc metoda PUSH u niz
}
var dpEdition:DataProvider = new DataProvider(aEdition);// Ovde dodeljujemo vrednost koja je OBJEKAT u nasem slucaju NIZ, i to nakon sto smo ga izgradili u FOR LOOPu
liEdition.dataProvider = dpEdition;
liEdition.allowMultipleSelection = true;
var aCondition:Array = new Array();
for (var condition:String in cardsXML.tblCondition) {
var conditionName:String = cardsXML.tblCondition[condition].txtCondition;
aCondition.push(conditionName);
}
var dpCondition:DataProvider = new DataProvider(aCondition);
liCondition.dataProvider = dpCondition;
liCondition.allowMultipleSelection = true;
}
// Ova funkcija ce izvrsavati ucitavanje Karti nakon klika na LIST komponentu i odgovarajucu kategoriju
function selectEdition(evt:Event):void {
var drzacSelekcije:Array = new Array();
drzacSelekcije = evt.target.selectedIndices;// Niz koji cuva indexe visestrukih selekcija
//trace("Drzac Selekcije= " + drzacSelekcije);
var aCards:Array = new Array();// Niz koji ce sadrzati imena odgovarajucih karata i posluziti kao DP za Listu Cards
var karta:String;// zaprav ime same karte koje ce biti ubaceno u aCards Niz u toku FOR LOOPa
for (var card:String in cardsXML.tblCard.intCardID) {// LOOPujemo kroz sve brojeve karata intCardID
//trace("Karta= " + card);
for (var i:int = 0; i < drzacSelekcije.length; i++) {
//trace("Index Drzaca["+i+"]= " + drzacSelekcije[i]);
if (drzacSelekcije[i] == cardsXML.tblCard[card].intEditionID-1) {// Uporedjujemo Index klika sa brojem edicije od koga oduzimamo 1 jer nemamo 0 ediciju
karta = cardsXML.tblCard.txtCardName[card];
//trace(cardsXML.tblCard.intEditionID);
aCards.push(karta);
}
}
}
//trace(aCards);
var dpCards:DataProvider = new DataProvider(aCards);
liCards.dataProvider = dpCards;
}
liEdition.addEventListener(Event.CHANGE, selectEdition);
function selectCondition(evt:Event):void {
var drzacSelekcije:Array = new Array();
drzacSelekcije = evt.target.selectedIndices;
//trace("drzac= " + drzacSelekcije);
var aCards:Array = new Array();
for (var card:String in cardsXML.tblCard.intCardID) {
//trace(cardsXML.tblCard[card].intConditionID);
for (var i:int = 0; i < drzacSelekcije.length; i++) {
if (drzacSelekcije[i] == cardsXML.tblCard[card].intConditionID-1) {
var karta:String = cardsXML.tblCard[card].txtCardName;
//trace("card= "+card);
aCards.push(karta);
//trace(karta);
}
}
}
//trace(aCards);
var dpCards:DataProvider = new DataProvider(aCards);
liCards.dataProvider = dpCards;
}
liCondition.addEventListener(Event.CHANGE, selectCondition);
The XML is rather large so I'm giving the basic structure of it:
PHP Code:
<dataroot>
<tblCard>
<intCardID>NUMBER</intCardID>
<txtCardName>TEXT</txtCardName>
<intQuantity>NUMBER</intQuantity>
<tblEditionID>NUMBER</tblEditionID>
<tblColorID>NUMBER</tblColorID>
<tblConditionID>NUMBER</tblConditionID>
</tblCard>
<tblColor>
<intColorID>NUMBER</intColorID>
<txtColor>TEXT</txtColor>
</tblColor>
<tblCondition>
<intConditionID>NUMBER</intConditionID>
<txtCondition>TEXT</txtCondition>
</tblCondition>
<tblEdition>
<intEditionID>NUMBER</intEditionID>
<txtEdition>TEXT</txtEdition>
</tblEdition>
</dataroot>
View Replies !
View Related
Extracting Data From A Dataset.
Hi there,
I'm using XMLConnector to input an XML file, and have linked a dataset to store the interpreted information. Data is displayed through an XML grid.
I'm also utilising mProjector, as any new items added to the grid will need to be reflected in the xml file.
How do i access data from the dataset into an array? I'm sure there's an easy way to access it, but considering i'm a greenhorn actionscripter, such tasks are becoming more complicated than anticipated.
Thanks in advance,
joey.
View Replies !
View Related
DataSet Not Storing Any Data?
Maybe I am a bit dense, but I have been trying to make this work all day and I can't get it to, so I would kindly request some assistance.
Basically what I am trying to do is to read data from a database containing a number of products and showing them on the stage.
Of course it is a work in progress and I have a lot of lines commented for later implementations, still the problem I am facing here that the data loaded in the first part of the code fails to show up later when I try to retrieve it via the _root.datacontainer.items[j].xxx method. All I get is a number of "undefined" on the screen.
Where am I going wrong? Any help is appreciated.
Attach Code
directory="public/";
lista=new LoadVars();
lista.load("http://www.agricolabaldi.com/tuttiProdotti.php");
lista.onLoad=function(success){
function carica(){
i = 0;
var totale=lista.t;
var elenco:Array=new Array();
for (i=0; i<(lista.t); i++){
elenco.push({
id:lista["id"+i],
nome:lista["nome"+i],
descrizione:lista["descrizione"+i],
nomeFoto:directory+lista["nomeFoto"+i],
novita:lista["novita"+i],
tipologia:lista["tipologia"+i],
confezionamento:lista["confezionamento"+i]
});
}
_root.datacontainer.dataProvider=elenco;
}
carica();
}
var thumbWidth:Number = 120;
var thumbHeight:Number = 75;
var MainTL:MovieClip = this;
var selected_thumb:MovieClip;
var thumbs:Array = new Array();
var thumbMCLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
thumbMCLoader.addListener(listener);
initThumbScroller();
function initThumbScroller(targetBtn:MovieClip, workCategoryID:String){
var counter:Number = 0;
for(var j:Number=0;j<20;j++){
var thumb = MainTL.thumb.duplicateMovieClip("thumb"+counter,counter);
thumb.thumb_title_mc._visible = false;
if (j==0){
xbase = 5;
ybase = 5;
thumb._x=xbase;
thumb._y=ybase;
} else {
if (xbase == 505){
xbase = 5;
ybase = ybase + 110;
thumb._x=xbase;
thumb._y=ybase;
} else {
xbase = xbase+ 125;
thumb._x=xbase;
thumb._y=ybase;
}
}
thumb.ID = counter;
thumb.title = _root.datacontainer.items[j].nome;
thumb.pictureURL = _root.datacontainer.items[j].nomeFoto;
counter++;
thumb.titleInitializing = true;
thumb.title_mc._visible = true;
thumb.title_mc._width = thumbWidth;
thumb.title_mc.theTitle.multiline = true;
thumb.title_mc.theTitle.wordWrap = true;
thumb.title_mc.theTitle.autoSize = true;
thumb.title_mc.theTitle.text = _root.datacontainer.items[j].nome;
thumb.title_mc._x = 0+Math.round((thumb.holder._width-thumb.title_mc._width)/2);
var thumbMCLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
thumbMCLoader.addListener(listener);
thumbMCLoader.loadClip(_root.datacontainer.items[j].nomeFoto,thumb.holder.thumb);
listener.onLoadComplete = function(target:MovieClip){
target._parent.preloader._visible = false;
}
listener.onLoadInit = function(target:MovieClip){
target._width = thumbWidth;
target._height = thumbHeight;
var tempMC = target._parent._parent.createEmptyMovieClip("tempSwapMC",target._parent._parent.getNextHighestDepth());
target._parent._parent.title_mc.swapDepths(tempMC);
}
thumb.holder.onRollOver = Delegate.create(MainTL,onThumbnailOver,thumb);
thumb.holder.onRollOut = thumb.holder.onDragOut = Delegate.create(MainTL,onThumbnailOut,thumb);
thumb.holder.onRelease = Delegate.create(MainTL,onThumbnailClick,thumb);
thumbs.push(thumb);
}
MainTL.thumb._visible = false;
}
function onThumbnailOver(thumb:MovieClip){
setSelectedThumb(thumb);
}
function onThumbnailClick(thumb:MovieClip){
//if( site_xml.firstChild.childNodes[thumb.ID].attributes.link != undefined ){
//_global.mcwidth = site_xml.firstChild.childNodes[thumb.ID].attributes.mcwidth;
//_global.mcheight = site_xml.firstChild.childNodes[thumb.ID].attributes.mcheight;
//_global.picname = site_xml.firstChild.childNodes[thumb.ID].attributes.link;
//win = PopUpManager.createPopUp(_root, Window, true, {closeButton:true});
//win.title=" Azienda Agricola Baldi Paolo";
//win.contentPath=('showpic.swf');
//win.setSize(mcwidth,mcheight);
//var alto:Number = ((Stage.width-mcwidth)/2);
//var destra:Number = ((Stage.height-mcheight)/2);
//win._x = alto;
//win._y = destra;
//lo = new Object();
//lo.click = function(){
//win.deletePopUp();
//}
//win.addEventListener("click", lo)
//}
}
function setSelectedThumb(thumb:MovieClip):Void{
selected_thumb = thumb;
}
function getSelectedThumb():MovieClip{
return selected_thumb;
}
View Replies !
View Related
DataSet Not Storing Any Data?
Maybe I am a bit dense, but I have been trying to make this work all day and I can't get it to, so I would kindly request some assistance.
Basically what I am trying to do is to read data from a database containing a number of products and showing them on the stage.
Of course it is a work in progress and I have a lot of lines commented for later implementations, still the problem I am facing here that the data loaded in the first part of the code fails to show up later when I try to retrieve it via the _root.datacontainer.items[j].xxx method. All I get is a number of "undefined" on the screen.
Where am I going wrong? Any help is appreciated.
Attach Code
directory="public/";
lista=new LoadVars();
lista.load("http://www.agricolabaldi.com/tuttiProdotti.php");
lista.onLoad=function(success){
function carica(){
i = 0;
var totale=lista.t;
var elenco:Array=new Array();
for (i=0; i<(lista.t); i++){
elenco.push({
id:lista["id"+i],
nome:lista["nome"+i],
descrizione:lista["descrizione"+i],
nomeFoto:directory+lista["nomeFoto"+i],
novita:lista["novita"+i],
tipologia:lista["tipologia"+i],
confezionamento:lista["confezionamento"+i]
});
}
_root.datacontainer.dataProvider=elenco;
}
carica();
}
var thumbWidth:Number = 120;
var thumbHeight:Number = 75;
var MainTL:MovieClip = this;
var selected_thumb:MovieClip;
var thumbs:Array = new Array();
var thumbMCLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
thumbMCLoader.addListener(listener);
initThumbScroller();
function initThumbScroller(targetBtn:MovieClip, workCategoryID:String){
var counter:Number = 0;
for(var j:Number=0;j<20;j++){
var thumb = MainTL.thumb.duplicateMovieClip("thumb"+counter,counter);
thumb.thumb_title_mc._visible = false;
if (j==0){
xbase = 5;
ybase = 5;
thumb._x=xbase;
thumb._y=ybase;
} else {
if (xbase == 505){
xbase = 5;
ybase = ybase + 110;
thumb._x=xbase;
thumb._y=ybase;
} else {
xbase = xbase+ 125;
thumb._x=xbase;
thumb._y=ybase;
}
}
thumb.ID = counter;
thumb.title = _root.datacontainer.items[j].nome;
thumb.pictureURL = _root.datacontainer.items[j].nomeFoto;
counter++;
thumb.titleInitializing = true;
thumb.title_mc._visible = true;
thumb.title_mc._width = thumbWidth;
thumb.title_mc.theTitle.multiline = true;
thumb.title_mc.theTitle.wordWrap = true;
thumb.title_mc.theTitle.autoSize = true;
thumb.title_mc.theTitle.text = _root.datacontainer.items[j].nome;
thumb.title_mc._x = 0+Math.round((thumb.holder._width-thumb.title_mc._width)/2);
var thumbMCLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
thumbMCLoader.addListener(listener);
thumbMCLoader.loadClip(_root.datacontainer.items[j].nomeFoto,thumb.holder.thumb);
listener.onLoadComplete = function(target:MovieClip){
target._parent.preloader._visible = false;
}
listener.onLoadInit = function(target:MovieClip){
target._width = thumbWidth;
target._height = thumbHeight;
var tempMC = target._parent._parent.createEmptyMovieClip("tempSwapMC",target._parent._parent.getNextHighestDepth());
target._parent._parent.title_mc.swapDepths(tempMC);
}
thumb.holder.onRollOver = Delegate.create(MainTL,onThumbnailOver,thumb);
thumb.holder.onRollOut = thumb.holder.onDragOut = Delegate.create(MainTL,onThumbnailOut,thumb);
thumb.holder.onRelease = Delegate.create(MainTL,onThumbnailClick,thumb);
thumbs.push(thumb);
}
MainTL.thumb._visible = false;
}
function onThumbnailOver(thumb:MovieClip){
setSelectedThumb(thumb);
}
function onThumbnailClick(thumb:MovieClip){
//if( site_xml.firstChild.childNodes[thumb.ID].attributes.link != undefined ){
//_global.mcwidth = site_xml.firstChild.childNodes[thumb.ID].attributes.mcwidth;
//_global.mcheight = site_xml.firstChild.childNodes[thumb.ID].attributes.mcheight;
//_global.picname = site_xml.firstChild.childNodes[thumb.ID].attributes.link;
//win = PopUpManager.createPopUp(_root, Window, true, {closeButton:true});
//win.title=" Azienda Agricola Baldi Paolo";
//win.contentPath=('showpic.swf');
//win.setSize(mcwidth,mcheight);
//var alto:Number = ((Stage.width-mcwidth)/2);
//var destra:Number = ((Stage.height-mcheight)/2);
//win._x = alto;
//win._y = destra;
//lo = new Object();
//lo.click = function(){
//win.deletePopUp();
//}
//win.addEventListener("click", lo)
//}
}
function setSelectedThumb(thumb:MovieClip):Void{
selected_thumb = thumb;
}
function getSelectedThumb():MovieClip{
return selected_thumb;
}
View Replies !
View Related
Send Data From DataSet To A DataHolder?
This is my first time using the DataSet and DataHolder components. I am impressed with what I have seen so far, but seem to be missing a key concept in data handling.
I am building a standard multiple-choice quiz with about 400 questions.
1) I converted all my data from word-->access-->xml.
2) I set up a xmlConnector to load the data and I bound it to a DataSet.
3) I bound the DataSet to a DataGrid and set all my schema.
4) The application sucesfully loads all the data in the correct format into the DataGrid!! The data grid is 400 rows and 10 columns.
What I want to do next is send a query to the DataSet and request that all the data from ONE row is sent to a DataHolder. (i.e. all the pertinent info for one question)
I have the DataHolder bound to all the UI components on the stage (i.e. question text, option a, b, c, d etc.) When I manually send data into the DataHolder via action script it successfully updates the items on the stage.
THE PROBLEM IS that I cannot figure out how to send just one row of data over to the DataHolder from the DataSet.
looking through the list of vars at runtime (ctrl-atl-v) i tracked down where the DataSet is storing my data, but I can't seem to get at an entire row AND send it to the DataSet.
Code:
Variable _level0.questions_ds.__items = [object #308, class 'Array'] [
0:[object #309, class 'Object'] {
ID:4,
TOPIC:"Nursing Process and Drug Therapy",
QUESTION_NUMBER:1,
QUESTION:"Which of the following ... a patient?",
A:"Allergies",
B:"Use of over-the-counter medications",
C:"Home remedy use",
RATIONAL:"Allergies. The key to this question is the phrase “most important.” ",
ANSWER:"a.",
D:"Alcohol intake",
__ID__:"IID68066591723"
},
1:[object #310, class 'Object'] {
ID:5,
TOPIC:"Nursing Process and Drug Therapy",
QUESTION_NUMBER:2,
QUESTION:"When administering medications to a patient, the nurse should:",
A:"Double-check the medication orders before administering",
B:"Call the patient by name ... person",
C:"Check the patient’s armband before administering the medication",
RATIONAL:"Checking the patient’s armband is the ... identity.",
ANSWER:"c.",
D:"Prepare medications for all patients first, ... appropriately",
__ID__:"IID75015590992"
}
]
this will put out the correct data, but only one item at a time, AND I am not sure how to dump it into the DataHolder.
Code:
trace(this._parent.questions_ds.__items[0].QUESTION_NUMBER);
trace(this._parent.questions_ds.__items[1].QUESTION_NUMBER);
trace(this._parent.questions_ds.__items[0].TOPIC);
//etc
Any help?
thanks!!
-mm
View Replies !
View Related
Data Binding Using DataSet And ComboBox
Hi guys, hope someone can help me with this. Seems it should be simple, but it's not, that's why I'm here. I have data loading into a DataSet component. I have a ComboBox on the stage with predefined values and lables, so it's not dynamic at all. After loads into the DataSet I have the value Bound to the the Combobox, but nothing is being selected. I know the ComboBox is a little bit trickier, unlike the Textfield or TextInput wich work right away. Again, hope someone can help.
View Replies !
View Related
Selectively Putting Data Into A List With DataSet And XMLC
Goal with this project is to have a listbox in which some data is showing, and when a row is selected, some other data is presented in some labels.
Have the following defined:
list_lb (a listbox)
label_txt (a simple lable)
XML_con (an XMLConnector)
data_ds (a dataset)
Have an XML-file which looks like:
<data>
__<data1>Some data</data1>
__<data2>More data</data2>
__<data3>You guessed it...</data3>
</data>
What I really would like to do, is in the listbox list_lb, present data1 and data2, and when clicked on, data3 is shown in label_txt.
So I've done the following:
1. Imported the XML through XML_con.
2. Bound XML_con and data_ds
3. Bound data_ds and list_lb
4. Added XML_con.trigger(); in the first frame
So, this gives me the following in list_lb:
Some data, More data, You guessed it...
There's two things I want to do:
1. Limit this to say "Some data: More data", ie a Custom Formatter
2. Trigger the label_txt to show "You guessed it..." when that row is pressed.
Any pointers to how I would go about doing this?
I've actually tried the following formatter and it looks like it should work... I get the trace as well:
Quote:
class myformatter
{
function myformatter (){
trace("This is where it starts!");
}
function format ():Array{
var __d:Array = new Array();
var _arg = arguments[0];
for(var a = 0; a < _arg.length; a++){
__d.push({label:_arg[a].data1 + ": " + _arg[a].data2, data:_arg[a].data1})
}
return __d
}
}
Any help is greatly appreciated, I'm going nuts over here!
//Magnus
View Replies !
View Related
More Help With XML - Filtering
In the following example (taken from Adobe's help on Flash) if there is only one item that matches the specified criteria than the value of the XML element is returned, however, if there are multiple returns you get the mark up and the value.
Here's the AS
ActionScript Code:
var settings_pathString:URLRequest = new URLRequest("xml/order.xml");
var settingsLoader:URLLoader = new URLLoader(settings_pathString);
settingsLoader.addEventListener("complete", loadSettings);
function loadSettings(event:Event):void{
var environment:XML = XML(settingsLoader.data);
trace(environment.item.(price==1.45).menuName);
}
And here are two examples of the XML and what they return
HTML Code:
<order>
<item id="1">
<menuName>burger</menuName>
<price>3.95</price>
</item>
<item id="2">
<menuName>fries</menuName>
<price>1.45</price>
</item>
</order>
returns:
fries
HTML Code:
<order>
<item id="1">
<menuName>burger</menuName>
<price>3.95</price>
</item>
<item id="2">
<menuName>fries</menuName>
<price>1.45</price>
</item>
<item id="3">
<menuName>ice cream</menuName>
<price>1.45</price>
</item>
</order>
returns:
<menuName>fries</menuName>
<menuName>ice cream</menuName>
I need to be able to work with the values even if there are multiple returns...
I know that the questions I ask are likely very rudimentary and I thank you guys for your help and patience.
- Doc
View Replies !
View Related
XML Not Filtering
Hello,
I've written code that loads in an XML file. Once loaded I can filter out a specific user by typing there name in and clicking a button. This works fine when the XML file only contains a few elements but when I load in a larger XML file the filter function doesn't work.
I know all the data is being loaded in, it just won't filter.
Any help would be greatly appreciated.
Thanks
Steve
View Replies !
View Related
AS3 And XML Filtering
Hello All,
This is my first post on this forum so I hope that you guys can help. I'm trying to filter some data from a XML file but flash keeps telling me that my child node is not available. I have checked the file several times with no luck. This is my first time using XML with AS3 so any help would be appreciated. This is still a work in progress but I'd like to be able to filter this data. I don't know if the XML file is too large or what. Here is the AS:
import fl.containers.ScrollPane;
import fl.controls.TextArea;
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("http://mainstreetlvnm.org/xmltest/AssetDatabase.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseProperties(xmlData);
}
function ParseProperties(propertyInput:XML):void {
trace("XML Output");
trace("------------------------");
var addressArray = new Array()
var authorList:XMLList = propertyInput.Properties.(Occupancy == "Vacant").Physical_x0020_Address;
trace(authorList)
var yLoc:Number = 0
var sp:ScrollPane = new ScrollPane();
sp.setSize(335, 360);
sp.move(195,13)
var textSource:MovieClip = new MovieClip();
for (var i:int = 0; i < authorList.length(); i++) {
var authorElement:XML = authorList[i];
var myTextArea:TextArea = new TextArea()
myTextArea.setSize(300, 50);
myTextArea.move(0, yLoc);
textSource.addChild(myTextArea);
myTextArea.editable =false
myTextArea.text = authorElement
yLoc = yLoc + 50
addressArray.push(authorElement);
//trace(authorElement);
}
sp.source = textSource
addChild(sp);
}
View Replies !
View Related
Filtering XML In AS3
Im trying to get a subset of an XMLList by using the AS3 supported xml filtering syntax. My XML basically consist of several item-elements, where each item can have zero och more type-elements.
A simplified version of my XML looks like this:
Code:
<itemlist>
<item name="item1">
<itemtypes>
<type>1</type>
<type>2</type>
</itemtypes>
</item>
<item name="item2">
<itemtypes>
<type>1</type>
</itemtypes>
</item>
<item name="item3">
<itemtypes>
<type>2</type>
</itemtypes>
</item>
</itemlist>
- The type element doesn't have to, but I chose to wrap it in an itemtypes-element.
- I use the name attribute to check which item has actually been selected by my filtering.
The problem is how do I select all item-elements that contains the element "type" with value: 1?
Im trying to do it with this code:
Code:
var _items:XMLList = itemList.*.itemtypes.(type == "1");
... which only selects the item elements which has only one type element. Im guessing that above expression can't test against more than one type element in the same target element.
(I solved it by traversing through the xml with loops, which looks horrible if you can solve it with one line of code)
View Replies !
View Related
Filtering XML
I'm trying to figure out how to sort/filter through XML entries. Basically what I'm trying to do is output(trace) all of the movies that have a movie_type.type of 1. This would output all the info in Movie One and Movie Three. How would I go about searching through all of the types. Would I have to use a loop of some sort? My logic (which is wrong) thought it would be something like this:
Code:
movie_list.movie.(movie_type.type == 1)
// or
movie_list.movie.(movie_type.* == 1)
Code:
<movie_list>
<movie>
<movie_name>Movie One</movie_name>
<movie_id>1</movie_id>
<movie_type>
<type>1</type>
<type>3</type>
<type>4</type>
</movie_type>
</movie>
<movie>
<movie_name>Movie Two</movie_name>
<movie_id>2</movie_id>
<movie_type>
<type>2</type>
</movie_type>
</movie>
<movie>
<movie_name>Movie Three</movie_name>
<movie_id>3</movie_id>
<movie_type>
<type>4</type>
<type>1</type>
</movie_type>
</movie>
</movie_list>
So is there any way to do this or do I have to use a for loop of some sort?
Any help would be greatly appreciated.
View Replies !
View Related
[AS3] Filtering XML
I'm having a little trouble with some XML filtering. I have some xml that is formatted like so:
Code:
<item id="2">
<name><![CDATA[Test]]></name>
<desc><![CDATA[asdfasdfasf]]></desc>
<link><![CDATA[asfasf]]></link>
<bplink><![CDATA[asdfasdf]]></bplink>
<date><![CDATA[2008-12-03 12:31:01]]></date>
<featured><![CDATA[no]]></featured>
<cat>
<catname><![CDATA[Jazz Technology]]></catname>
<catname><![CDATA[Requirements Management]]></catname>
</cat>
<cat2><![CDATA[Demonstrated Business Value]]></cat2>
<cat3><![CDATA[Customer Case Studies & References]]></cat3>
<industry><![CDATA[Industry Solution]]></industry>
</item>
What I want to do is query the whole XML document and get every <item> node where at least one of the 'catname' nodes (highlighted in red) equals a certain value. In this particular 'item' node, there are two 'catname' children in the 'cat' node. I want to return the node if at least one of those matches a value (say Jazz Technology). Can't seem to get it to happen though. Any love?
View Replies !
View Related
[AS3] - E4x Filtering
I am soooo confused!!! I regret to say I have been stuck on this one wayyyy toooo long!
So I am trying to do some E4x filtering on some XML. From the code below test traces out with a XMLList that has all three Display Object Nodes which totally makes sense to me. But why does test2 trace out as nothing?!?!? I have searched high and low and cannot figure this out!
Code:
var testXML:XML = new XML("<levelXML>
<DisplayObject><attr name="Name" value="collectionBox" /></DisplayObject>
<DisplayObject><attr name="Name" value="background" /></DisplayObject>
<DisplayObject><attr name="Name" value="titleScreen" /></DisplayObject>
</levelXML>");
var test:XMLList = testXML.DisplayObject.attr.(@name == "Name");
var test2:XMLList = testXML.DisplayObject.attr.(@value == "collectionBox");
Thanks for even viewing! Happy New Year!
View Replies !
View Related
Xml Datagrid Filtering?
hi guys!
im a little stuck with datagrids, i have loaded an xml file into my datagrid but im at the stage now where i need to create a 'search' input box so users can filter the file down.
does anyone know of a good way to do this?
thanks all!
View Replies !
View Related
Filtering/displaying
Hello! I'm trying to create a list made up of movie clips that can be dynamically filtered. I am trying to use the checkbox component to filter fake search results. I have a for loop that populates an initial list (each result is a movie clip that is attached to a container on the stage). Is there any way to attach what would be more or less tags to movie clips so that they could be taken off the list/added to it based on the tags?
View Replies !
View Related
XML Filtering Not Getting Any Results?
I'm sure this is right, but it doesn't seem to work. I just want to filter an XMLList.
Here is my code:
ActionScript Code:
trace("XML filter: " + responseXML.recruiters.recruiter.(@name == e.target.r_name.text));
for each (var prop_:XML in responseXML.recruiters.recruiter)
{
if(prop_.@name == e.target.r_name.text) trace("we have a match: " + prop_.@name);
}
It traces:
XML filter:
we have a match: Ted Teacher
So why doesn't it filter??? If I loop the XML the strings match... What the bleep.
ActionScript Code:
The XML List:
<sauder>
<recruiters>
<recruiter name="Ted Teacher" title="Teacher" email="name@eamil.com" phone="123.123.1234" image="images/teacher.jpg"/>
<recruiter name="Don Waun" title="Teacher/Prof" email="name@eamil.com" phone="123.123.1234" image="images/teacher.jpg"/>
<recruiter name="Jimmy James" title="Teacher new" email="name@eamil.com" phone="123.123.1234" image="images/teacher.jpg"/>
<recruiter name="John Doe" title="Teacher test" email="name@eamil.com" phone="123.123.1234" image="images/teacher.jpg"/>
<recruiter name="Whatever Name" title="Teacher one" email="name@eamil.com" phone="123.123.1234" image="images/teacher.jpg"/>
</recruiters>
</sauder>
View Replies !
View Related
XML List Filtering
In the attached code, "_items" is an XMLList and "attrib" is an attribute.
The trace statement executes properly. The second line of code generates a "term is undefined" error.
Is there a reason for this?
Attach Code
trace( _items.(@attrib == "true").length() );
var numItems:int = _items.(@attrib == "true").length();
Edited: 07/18/2008 at 08:30:13 AM by _PlayerOne_
View Replies !
View Related
Filtering XML On An Attribute
My brain has melted at this point, so I'll ask you all - how do I filter for the following attribute:
story.attributes.year == "2005"
in the code below, so that only the nodes marked "2005" are displayed? Files are attached.
Code:
//Create textfield
this.createTextField("content_txt", 10, 0, 0, 390, 0);
//Create and load styles
var pressStyle:TextField.StyleSheet = new TextField.StyleSheet();
pressStyle.load("news.css");
content_txt.styleSheet = pressStyle;
//Textfield attributes
content_txt.multiline= true;
content_txt.wordWrap = true;
content_txt.html = true;
content_txt.autoSize = true;
content_txt.variable = "press";
// The first step is to activate the XML object
newsXML = new XML();
newsXML.onLoad = pressLoad;
newsXML.load("newsPress.xml");
function pressLoad(OK) {
if (OK == true) {
Publish(this.firstChild);
//content_txt.htmlText = newsXML;
}
}
function Publish(HeadlineXMLNode) {
if (HeadlineXMLNode.nodeName.toUpperCase() == "BROADCAST") {
press = ""; // Removes "undefined" instance
story = HeadlineXMLNode.firstChild;
while (story != null) {
if (story.attributes.year == "2005") { trace("2005"); }
if (story.nodeName.toUpperCase() == "STORY") {
lead = "";
body = "";
URL = "";
element = story.firstChild;
while (element != null) {
if (element.nodeName.toUpperCase() == "LEAD") {
lead = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "BODY") {
body = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "URL") {
URL = element.firstChild.nodeValue;
}
element = element.nextSibling;
}
press += "<font family='Verdana' size='11' color='#B2B2B2'>"+lead+"</font><br>";
}
story = story.nextSibling;
}
}
}
View Replies !
View Related
Filtering Elements Within XML
Just been looking at senocular's XML tutorial.
It tells me I can filter through my xml using something like this, to
output the nodes with the attribute value of 1.
trace(grades.student.quiz.(@num == "1"));
However this is not quite what I'm after. Not all my xml nodes have the same attributes and so I need a way to
search or filter through my xml and get the nodes which have the @num attribute or which ever attribute I am looking for.
Im sure this is pretty basic stuff, but dont know the syntax I need to use.
Thanks in advance,
Julian
View Replies !
View Related
[AS3] Filtering Children
Just a little code snippet here for you guys. I needed a solution that would only allow certain object types to be added to a display list, and the first thing I did was override all of the addChild and removeChild related methods in order to catch and filter out unwanted object types... then I remembered the Event.ADDED event... D'oh!
Anyway, I was using an interface to mark certain object types but this little example works in exactly the same way, it will only allow Shape objects into the display list:
ActionScript Code:
// Just draws a rectangle
function drawRect(graphics:Graphics, colour:uint=0):void
{
graphics.beginFill(colour);
graphics.drawRect(0, 0, 100, 100);
graphics.endFill();
}
// The event handler
function addedHandler(event:Event):void
{
if (!(event.target is Shape))
{
removeChild(DisplayObject(event.target));
}
}
// Register the event listener
addEventListener(Event.ADDED, addedHandler);
// Create the objects
var sprite:Sprite = new Sprite();
var shape:Shape = new Shape();
shape.x = 100;
// Draw rectangles into the objects so they can be seen
drawRect(sprite.graphics);
drawRect(shape.graphics, 0xF02060);
// Try to add the objects to the display list
addChild(sprite); // gets kicked out
addChild(shape); // is allowed in
View Replies !
View Related
XML And AS: Filtering By Attribute
Can I use actionscript (in mx 2004) to filter xml by attribute?
For example, I have an xml-file, that looks like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<trailer>
<film url="number1.flv" title="film 1" company="alpha" />
<film url="number2.flv" title="film 2" company="alpha" />
<film url="number3.flv" title="film 3" company="beta" />
</trailer>
and in Flash I have two buttons, "company alpha" and "company beta" and a dynamic textfield that's supposed to display the titles.
So if I click "company alpha" I want all the film-titles that have the attribute company="alpha", displayed in the textbox.
How do I do this? Is it possible to filter by attribute?
View Replies !
View Related
Filtering Text Input
I have trawled around the forums and not found any reference to this - maybe it is so easy I have missed something ;-)
What I want to do is filter input to a text box.
For example, a user should only enter numbers, so the text box doesn't accept any non numerican key strokes.
Or A user must enter a code with no spaces or dashes, so only allow alphanumeric keystrokes.
Has anyone got anything quick and easy I can swipe (failing that anything at all!) I am guessing I might have to use a clip event and process the key strokes in Actionscript filtering out illegal keys and appending kosher key strokes to a dynamic variable. I then need to add code to handle delete key, and also swipe, copy, cut and paste.
Not something I feel like doing if some kind sole has already done it!
(is this something I could add as a prototype to a text box to add this functionality to ALL text fields??)
Thanks for your help in advance!
Olz.
View Replies !
View Related
Image Montage/filtering
Hi.
I have created a very simple "image montage/filtering" for a company's website. The way it is currently built is very simple.
It consists of a series of movieclips overlapping on the timeline.
What I would like to happen is:
When a user goes to the site and refreshes, a new set of images
show. Basically having random sets.
Thank you in advance for your time!
akinnelly
View Replies !
View Related
ActionScript Color Filtering
Ok, so I've been thinking about making a sprite-version platform fighting game where the user can upload their own sprites and make their own characters. I understand, to at least some reasonable degree how to do most of the actionscript that I'll need. However, I have no idea where to really start when it comes to working with sprites' background color.
Basically, I'm going to have a tool(part of the main game or separate) that will upload/import all the sprites that someone will be using in a convenient fashion. But obviously they're going to have the problem of making the background transparent(and there are very few people who would have know how to do that if it can be done). Anyway, I want to set up my tool so that it will take in a specific color, given by the user, and filter that color out of each of the sprites.
In case I'm being confusing, the only thing I want help on, for the time being, is how to filter color(s) out of a raw image. I want to work with multiple image types such as: bmp, jpg, png and gif.
So if anyone can at the very least point me in the right direction, I would be very grateful!
(PS: If I do follow through with this project and finish it, I could have your name in the credits if you want, or at least I could send you the device when I'm done! )
View Replies !
View Related
Nested For Loop And Filtering
So i'm fairly new to loops, and actionscripting for that matter. I've been doing fine until now.
I have a nested FOR loop (f) which i want to check all items added in the (i) array for duplicate entries. It will work without the nested loop, by just comparing to the previous entry, so I know everything else works.
This is what I have so far:
Code:
var list = info_xml.firstChild.childNodes[6].childNodes;
for (var i = 0; i<list.length; i++) {
for (var f = 0; f<=i; f++) {
var current = list[i].attributes.topic;
var filter = list[f].attributes.topic;
if (current == filter) {
//do not display duplicate
} else {
//display the new attribute
}
}
}
I also need to sort these results alphabetically when displayed.
Thanks!
View Replies !
View Related
Filtering Duplicates In An Array
I have a simple array below with various items in my array. When I retrieve all of the values in my array, I only want the unique values and not the values that already exist. Is there a quick way to do this.
myArray = [
"honda",
"acura",
"toyota",
"lexus",
"mercedes",
"acura",
"toyota",
"porsche",
"lexus",
"bmw"
];
for(i = 0; i < myArray.length; i++) {
trace(myArray[i]);
}
--------------------------------------------------
Basically, when I trace the array items i would like to see (even though some of the items are included twice in the array):
honda
acura
toyota
lexus
mercedes
porsche
bmw
Any help would be greatly appreciated.
View Replies !
View Related
Filtering Array By Keywords
Hi
I've been fighting for a while and cant seem to get it working
if anyone could give me a hand with the looping structure i would appreciate it.
blueprint
projectsArray:Array; - all the projects from the xml
pKeywords:Array; - every project has 1 or more keywords
activeKeywords:Array; - the keywords that ar currently selected
filteredProjects:Array; - the projects that match 1 or many activeKeywords
good luck to myslef!
View Replies !
View Related
Xml Menu Filtering Hell
I am such a dork, I just can't get my head around this problem.
I'm creating a menu from an xml doc and need to filter it based upon categories within each node. Unfortunatly when I filter down to specific categories it creates the menu with blank spaces for the filtered out nodes.
I've enclosed a stripped down example.
Help please !!!!
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<menus>
<button cat="Frequent" buttonname="button_01"></button>
<button cat="Overview" buttonname="button_02"></button>
<button cat="Frequent" buttonname="button_03"></button>
<button cat="Frequent" buttonname="button_04"></button>
<button cat="Overview" buttonname="button_05"></button>
<button cat="Overview" buttonname="button_06"></button>
<button cat="Overview" buttonname="button_07"></button>
<button cat="Frequent" buttonname="button_08"></button>
</menus>
Code:
menuXml=new XML();
menuXml.ignoreWhite=true;
menuXml.onLoad=function(success){
myMenu = this.firstChild.childNodes;
for (var i=0; i<myMenu.length; i++){
if (myMenu[i].attributes.cat=="Frequent"){
item = attachMovie("videoMenuButton","videoMenuButton" +i, i);
item._x = 10;
item._y = 10 + 25*i;
item.buttonText.text = myMenu[i].attributes.buttonname;
}}}
menuXml.load("example.xml");
View Replies !
View Related
AS2.0: Filtering Nodes In Menu.
I'm currently modifying an xml menu found in the kirupa tutorials and Ive gotten stuck. I want the menu to filter into different columns depending on a xml node called type="". So far I have this but I cant seem to get my head around how to filter the menu.
ActionScript Code:
GenerateMenu = function (container, name, x, y, depth, node_xml) { var currNode; var currItem; var currMenu = container.createEmptyMovieClip(name, depth); for (var i = 0; i<node_xml.childNodes.length; i++) { currItem = currMenu.attachMovie("menuitem", "_mc", i); if (currItem.type == web) { currItem._x = x; currItem._y = y+i*currItem._height; } currItem.trackAsMenu = true; currNode = node_xml.childNodes[i]; currItem.type = currNode.attributes.type; currItem.description = currNode.attributes.description; currItem.name.text = currNode.attributes.name; currItem.onRelease = function() { xmlDoc = this.name.text; projectType = this.type; proDescription.text = this.description; xmlProject.load(xmlDoc+"/project.xml"); resetSlideshow(); trace("this is == "+projectType); }; }};
at the moment all I've tried to do is filter the menu with an if statement to only display the type node with "web" in them. As soon as I undestand how this is done I sohuld be albe to do the rest myself.
Any help would be greatly appretiated.
Dave
View Replies !
View Related
Flex Xml + Webservices = No Filtering?
Greetings!
I have the following situation:
I use a webservice to get my information. This returns an xml in the following state:
Code:
<getBronnenResult xmlns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Bronnen>
<id>81</id>
<sCount>260</sCount>
<title>Plant grown from cell culture tissue in test tube</title>
<number>100121</number>
<width>180</width>
<height>134</height>
<croptype/>
<growthstage/>
<source>BASF</source>
<photographer/>
<photocredit>Print free of charge. Please use following photo credit "Copyright © BASF".</photocredit>
<region>Europe</region>
<country>Germany</country>
<city/>
<disease/>
<captionnotes/>
<numberofpeople>0</numberofpeople>
<nameofmodel/>
<resolution>72</resolution>
<bitdepth>24</bitdepth>
<colourspace>RGB</colourspace>
<filetype>JPEG</filetype>
<filesize>47725</filesize>
<subject>Health,Integrated pest management (IPM),Research and development</subject>
<category>Biotechnology,Crop protection,Science</category>
</Bronnen>
I already added the tempuri namespace to my project.
when I do the following code
Code:
trace("=> " + tempResult.id);
I get this result
<id xmlns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xmlnssd="http://www.w3.org/2001/XMLSchema">83</id>
But I can't seem to filter it...
so this doesn't seem to work
Code:
trace("=> " + tempResult.(child(id)=='83'));
or any variation on this code...
does someone have a solution for this problem???
View Replies !
View Related
|