A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Next button trouble in AS2

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

    Next button trouble in AS2

    This is most likely a simple fix. I am having trouble with my next button. I can get it to work but not the way I want it to. Right now, when I click the next button, it will go to the next on the list in my xml, but once I get to the end, it goes to undefined rather then starting over. Does that make sense, did I explain it ok. Below is my code. In red in the next button code (simple, but obviously wrong). Thanks for the help in advanced.

    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("myXMLfileGOshere" + 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) {
    newsMC.newsText._alpha = 100;
    newsMC.newsText.text = caption[pos];
    newsMC.newsText.setTextFormat(out);
    newsMC.newsURL = url[pos]
    newsMC.enabled = false;
    if (newsMC.newsURL != undefined) {
    newsMC.enabled = true;
    }
    timer();
    }
    over = new TextFormat();
    over.underline = true;
    //
    nextbutton.onRelease = function() {
    display(p);
    p++;
    delete this.onEnterFrame;

    };
    out = new TextFormat();
    out.underline = false;
    newsMC.onRelease = function() {
    getURL(this.newsURL, "_blank");
    };
    newsMC.onRollOver = function() {
    this.newsText.setTextFormat(over);
    };
    newsMC.onRollOut = function() {
    this.newsText.setTextFormat(out);
    };
    function fadeout() {
    this.onEnterFrame = function() {
    if (newsMC.newsText._alpha >= 0) {
    newsMC.newsText._alpha -= 5;
    } else {
    display(p);
    p++;
    delete this.onEnterFrame;
    }
    };

    }

  2. #2
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    760
    PHP Code:
    nextbutton.onRelease = function() {
         
    display(p);
         
    p++;
         if(
    p==total){
               
    p=0;
         }
         
    delete this.onEnterFrame;

    [SIGPIC][/SIGPIC]

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Posts
    21
    rynoe, thanks for the help... after testing it out, I also needed the clearInterval function in there. I am going to do some more testing before it goes live. Again thanks for your help.

Tags for this Thread

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