dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Help with my XML....Pease.

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    21

    Help with my XML....Pease.

    I created a simple xml in notepad that will display a news headline and URL (when available). What is happening is after the first time it runs through perfectly, then on the second run through is where things got a bit strange. If I do not have a URL attached to the headline that is being displayed, it used the last URL it had, until a new one is read. Is there a way to clear out the URL? I am still learning a lot. I am using Flash 8 Pro. Actionscrip 2. Below is my actionscript, please let me know if I need to move this thread elsewhere. Thanks you in advance.

    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;
    caption = [];
    url = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    caption[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    url[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    }
    first_item();
    } else {
    content = "file not loaded!";
    }
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("http://static.cbslocal.com/station/wcco/ticker/news.xml?blarg="+new Date().getTime());
    //
    function first_item() {
    delay = 6500;
    p = 0;
    display(p);
    p++;
    }
    function timer() {
    myInterval = setInterval(ticker, delay);
    function ticker() {
    clearInterval(myInterval);
    if (p == total) {
    p = 0;
    }
    fadeout();
    }
    }
    function display(pos) {
    over = new TextFormat();
    over.underline = true;
    //
    out = new TextFormat();
    out.underline = false;
    //
    newsMC.newsText._alpha = 100;
    newsMC.newsText.text = caption[pos];
    if (url[pos] != null) {
    newsMC.onRelease = function() {
    getURL(url[pos], "_blank");
    };
    }

    if (url[pos] != null) {
    newsMC.onRollOver = function() {
    this.newsText.setTextFormat(over);
    };
    }
    if (url[pos] != null) {
    newsMC.onRollOut = function() {
    this.newsText.setTextFormat(out);
    };
    }
    timer();
    }
    function fadeout() {
    this.onEnterFrame = function() {
    if (newsMC.newsText._alpha>=0) {
    newsMC.newsText._alpha -= 5;
    } else {
    display(p);
    p++;
    delete this.onEnterFrame;
    }
    };
    }

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    its hard to read your code since you didnt format it..

    but have you done a check to see if your URL var is 'undefined'?

    and if so set your URL var = ""

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center