Actionscript 3 :: Flex - Change Xml Attribute Name?
Oct 20, 2010For example
i want to change
<item id="1"/>
to
<item code="1"/>
For example
i want to change
<item id="1"/>
to
<item code="1"/>
I'd like to change icon of the node according to the attribute automatically/dynamically in Flex.[code]
View 1 RepliesHow can we change the attribute name ows_Attachments to Attachments in runtime ??
ActionScript Code:
<rootNode>
<data>
<row ows_Attachments="0" ows_LinkTitle="1" ows_productNo="1" ows_purchaseDate="2010-06-09 00:00:00" xmlns="#RowsetSchema"/>
[code]....
I have an mp3 on my site that is loaded via an xml. I have an action on the xml that allows any song to be played first by assigning an attribute. However, I want another song to play when a selected button is pressed on the flash file. But I do not want to load a new xml, instead, I want to change it using an attribute. Any who, here is the code that is used to create a sound and play selected song.
//this function selects the music assigned with "musicnum" variable
selectmusic = function() {
//create a new sound variable
sound = new Sound();
//load the music
sound.loadSound(songs[musicnum].attributes.src, true);
//set volume
[Code] .....
[Code]....
I am currently updating page level "visited=true" programatically/runtime. I wanted to roll up to topic level(all parent levels) once I have shown visited state "true" to all pages in topic.
I am having trouble parsing some xml that has a few attribute names with : characters in them. The compiler is not throwing any errors and when I trace my complete xml object out it is all there, however when I try to trace out any element or node it keeps comming up undefined. I removed the attribute names with : characters in them and everything works fine. I cant seem to target the attributes either to delete them.
View 3 Repliesi have XMl like
<record id="1" name="CustomerInfo">
<field name="id" index="1" type="String"/>
</record>
[code].....
I have this variable in Model class:[code]I've used BindingUtils to get notified when the XML changes:[code]Function onChange gets triggered when I assign an XML to the variable, but not when I change some attribute of the XML: Model.getInstance().someXml.@attr = "newValue";
View 1 RepliesI wish to extract an attribute from an XMLList and assign it to a string. Here is the snippet of the XML
<node>
<sport GAME="Squash" TIME1="2" TIME2="3" TIME3="8"/>
<sport GAME="Table Tennis" TIME1="4" TIME2="6" TIME3="7"/>
</node>
I have two variables. One variable will contain the game type, either Squash or Table Tennis. The other will contain one of the following strings "TIME1", "TIME2" or "TIME3". The variables are called game and time. I have tried many variations on the code below to get the needed attribute but with no joy.
var result:String = node.sport.(@GAME == game).(attribute(time));
i have an xml which contains 'interface' sub tag, iam converting xml to object using SampleXmlDecoder. compiler did not allow me to access the value of the 'inteface' attrible of the resultobject.
[Code]....
its treating interface as keyword. the solution for this.
In the following XML[code]...
How do I use e4x to extract the urls and push them in an array with the least possible code?
Flex has an issue with hyphens in xml. I need to generate an xml object with hyphens in the attribute for a Google Checkout implementation.
I can get away with:
var xml:XML = <item-description/>;
and
var xml:XML = <item-description the-name="foo"/>;
but what I need to do is set the value of an attribute like this:
var timestamp:String = methodToGetMyTimestampString();
var xml:XML = <item-desc/>;
xml@start-date = timestamp;
but I can't do that. Since flex doesn't like the hyphens, I don't know how to get or set attributes with hyphens in the name.
I'm using a CSS file to style my flex application. can I use components IDs to change their style from the CSS file? Or I should add the styleName attribute for each element?
View 2 RepliesI'm trying to create a button skin, where i can set fillColors like in a Flex 3 button, using CSS. It was easy to set the color of the gradients, by reading them from the CSS: adding a few lines in updateDisplayList: fillGradient1.color = fillColors[0]; ...
How can i set the colors for the other states, from script? I tried adding fillGradient1.color.down = fillColors[2] and it's not working...
have an RSS feed, within Flex I have connected to the feed via HTTPService, the XML structure is as follows (not exact, but for the purpose of the question). I am able to walk down the xml and access the data within the title and link nodes with success but when I get the the description node and try to access the img and src attributes within it, I haven't had any success. Reading about parsing with e4x the example I get is:
var xList:XMLList = xData.channel.item.description.(attribute("src"));
or
var xList:XMLList = xData.channel.item.description.(@src);
[code]......
What is the best method to test the existence of an attribute on an XML object in ActionScript 3 ttp://martijnvanbeek.net/weblog/40/testing_the_existance_of_an_attribute_in_xml_with_as3.html is suggesting to test using
if ( node.@test != node.@nonexistingattribute )
and I saw comments suggesting to use:
if ( node.hasOwnProperty('@test')) { // attribute qtest exists }
But in both case, tests are case sensitiveFrom the XML Specs : "XML processors should match character encoding names in a case-insensitive way" so I presume attribute name should also be match using a case-insensitive comparison.
Why cannot I bind xml attribute for datafield? (flex 4)[code]
View 3 Repliesi want to set fade effect to the GridRow when i remove it using removeChld() function
View 2 RepliesI'm trying to get this code working:
<mx:DataGrid x="359" y="221" width="623" height="176">
<mx:dataProvider>
<fx:Object name="Garbage Collection" code="7777" hours="2"/>
<fx:Object name="Road Repair" code="8888" hours="6"/>
<fx:Object name="Lawn Maintenance" code="9999" hours="12"/>
[Code] .....
I even don't have the header text in my columns.
Suppose I have a list of objects of a certain custom type and I need to find an object given only the value of one of its attributes, how do I do it?
Eg.
// Where user1 ... usern are objects of some class User
users = [ user1, user2, user3 ... usern ]
// How do I find out the objects that have the "foo" attribute set to "bar"
I have a little concern. I started trying to make a MenuBar control with custom icons already made in FXG format. I have 3 FXG files in "assets.graphics.icons" inside my project folder:
src/assets/graphics/icons/MenuIcon.fxg
src/assets/graphics/icons/ItemAIcon.fxg
src/assets/graphics/icons/ItemBIcon.fxg
After reading the following two links and a bunch of web pages.
[Code]...
For some reason this seems to no longer work in flex 4, it used to work in flex 3.[code]I am setting the xmlTitle variable outside of the component:<local:Comp xmlTitle="Some Title" />I have tried with getter / setters...etc. It just does NOT update when changing, it shows the default value and never changes. Is this a known new bug in flex 4?
View 2 RepliesUsing e4x in flex:
var attr : String = "foo";
var xml : XML =
<resultSet>
<node foo="1"/>
</resultSet>;
How can I use the variable "attr" to access
xml.node.@foo
I thought I could do it with
xml.node.@[attr]
But this doesn't seem to work. How can I access this attribute by a dynamic value like this?
Both
xml.node.@[attr];
and
xml.node.attribute(attr);
work, as Constantiner suggested.
Updates:
Say I have an XMLList in this form:
var bar:XML =
<resultSet>
<node>value</node>
</resultSet>;
I want to filter the original xml above by matching "foo" attributes with the "value" from node in bar.
Essentially I want a sublist of the original xml such that
xml.node.@foo == bar.value
for each xml row in the original value
As Constantiner mentioned, I can filter the original list by the value in foo, but what if I want to filter on multiple values?
Can I do something like:
xml.node.(bar.node.contains(attribute(foo)) ? attribute(foo) : null);
Or perhaps a cleaner method instead of the null?
I am experimenting with e4x. I could programmatically add an attribute to an Xml by doing something like this :
[Code]...
now i have added a name attribute to it programmatically because even though the xml had no attribute called name, after the statement above, it automatically has one now. My difficulty now is how do i , as well, remove the name attribute i have inserted programmatically again?
I have a code like the one below
<mx:Button id="TestingID" width="100%" height="20">
<mx:Script>
<![CDATA[
[code]....
From some xml I want to find items that have a specific attribute and value.Here is example xml:
<node>
<node>
<node>
<special NAME="thisone"></special>
[code]....
How do you use variables to access Object attributes? Suppose I have an Object declared as follows,
var obj:Object = new Object;
obj.Name = "MyName";
obj.Age = "10";
[code].....
if you feed the textarea text attribute with an tag that has a valid src url, then for some reason flex will try to render everything as html.Eg, try this:<mx:TextArea id="textArea" width="100%" height="90%" text="<img src='http://url-to-a-valid-img"/> and instead of it rendering it as raw text it will render it as an html.
View 2 RepliesThere are styles for over and clicked but no up state.
View 1 RepliesI have a Flex XML object as follows:
private var _xmlCountries:XML =
<Countries>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AO">Angola</option>
[Code]...
This object is ok, and shows up correctly in debug mode. The problem is I have a country name i.e. private var _country:String = "Angola";, and I want to get the corresponding value 'AO' from the XML object. Do you know how to do this?
I have tried loads of Livedocs examples, but cant get it to work. P.S. I am working on a HtpService & WebService driven app to display global weather conditions overlayed on a Google Maps interface. Going to make it available to the Flex community when finished.