开发者

A newbie question about action script

I saw someone using label as an ItemRenderer for DataGrid, the code is here. I just don't understand 1)what is the "@" mean here : "data.@price" 2)what is the type of "data" and how could I use it? in order to understand this, what keyword should I search for?

package {
    import mx.controls.Label;
    import mx.controls.listClasses.*;

    public class PriceLabel extends Label {

        private const POSITIVE_COLOR:uint = 0x000000; // Black
        private const NEGATIVE_COLOR:uint = 0xFF0000; // Red

        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            /* Set the font color based on the item price. */
            setStyle("color", (parseFloat(data.@price) <= 0) ? NEGATIVE_COLOR : P开发者_高级运维OSITIVE_COLOR);
        }
    }
}

Thanks


Per the Adobe operators reference:

Identifies attributes of an XML or XMLList object. For example, myXML.@id identifies attributes named id for the myXML XML object. You can also use the following syntax to access attributes: myXML.attribute("id"), myXML["@id"], and myXML.@["id"]. The syntax myXML.@id is recommended. To return an XMLList object of all attribute names, use @*. To return an attribute with a name that matches an ActionScript reserved word, use the attribute() method instead of the @ operator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜