开发者

how to add <hr/> tag and utm tags in AS3?

开发者 https://www.devze.com 2023-02-14 04:11 出处:网络
I have two requirements, and im not sure is those things possible in AS3. Anyway I\'ll explain what I want.

I have two requirements, and im not sure is those things possible in AS3. Anyway I'll explain what I want.

first, I nee开发者_如何学Cd to show an <hr/> tag after the description, its an rss widget so need to seperate with each rss post with a border or hr. Its not possible to make it manually because its came from xml. I'll give you the existing script with me.

second, I need to add utm tag after the urls to trace the clicks, this is actually I need to add after the links 'utm_source=rsswidget', you'll get an idea by seeing the script below

   var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);

var xml:XML;

function onLoaded(e:Event):void
{
var style:StyleSheet = new StyleSheet();
style.setStyle(".heading", {fontWeight:"bold", color:"#6184b7", fontSize:12});
style.setStyle("body", {fontStyle:"italic"});

xml = new XML(e.target.data);
    var il:XMLList = xml.channel.item;
    for(var i:uint=0; i<il.length(); i++)
    {

t.setStyle("styleSheet", style);
t.htmlText = "<a href='"+il.link.text()[0]+"' class='heading'>"+il.title.text()[0]+"</a>"+"\<br />"+il.description.text()[0]+"\<br/><br/>"+"<a href='"+il.link.text()[1]+"' class='heading'>"+il.title.text()[1]+"</a>"+"\<br />"+il.description.text()[1]+"\<br /><br />"+"<a href='"+il.link.text()[2]+"' class='heading'>"+il.title.text()[2]+"</a>"+"\<br />"+il.description.text()[2];
    }

}

t stands for text area.

hope your replies get soon..

Paul


The HR tag isn't supported in Actionscript. My suggestion would be to just use a loop to parse through all of your XML elements, and add the HR visuals as movieclips from your library after every entry... perhaps like so (btw, this is all pseudo-code - I haven't tested it):

var xmlData:String = "<channel><item><link>My link</link> <description>My description</description> </item> <item> <link>My link</link> <description>My description</description> </item> <item> <link>My link</link> <description>My description</description> </item>  <item> <link>My link</link> <description>My description</description> </item> </channel>"
var xml:XML = new XML(xmlData);

var buffer = 5
var ypos = 0

for(var i:uint=0; i<xml.item.length(); i++){
    // create the textfield and populate it with your data
    var t = new TextField()
    t.border = true
    t.autoSize = TextFieldAutoSize.LEFT
    t.multiline = true
    t.wordWrap = true
    t.y = ypos
    t.htmlText = "<a href='"+xml.item[i].link+"' class='heading'>"+xml.item[i].link+"</a>"+"\<br />"+xml.item[i].description
    this.addChild(t)

    // create one HR
    var hr = new HorizontalLine() // this would be a movieclip in your library with the linkage HorizontalLine
    hr.y = t.y + t.height + buffer
    this.addChild(hr)

        // positioning
    ypos = hr.y + buffer
}

Also, here's an FLA saved to CS4 if you're still stuck: http://clearmpls.com/temp/xml-list.zip

0

精彩评论

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

关注公众号