A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: getting mc to refresh after typetext is done

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    9

    getting mc to refresh after typetext is done

    Hello,
    I have a fla file with text box (randomText) and mc (random3) on one frame. The text is being randomly loaded and typed from external text file. This works well.
    I simply want to mc to go back and play frame one when text is done typing.
    I am going crazy. I think the below should work - all is, except MC is not going back to frame one. (I have used relative/absolute paths but nothing works?)
    if you can tell me what is wrong I'll so appreciate it (using flashmx 2004 (7.2) on a mac.

    the code:

    stop();

    var typeSpeed:Number = 75; //ms: 1000ms = 1 sec
    var pauseDelay:Number = 1000; //ms: 1000ms = 1 sec
    var currentCount:Number = 0;
    var animationTimer:Number;
    var myFactsArray:Array;

    var una = new Array();
    var uniqueNums = myFactsArray.length
    for (i = 0; i < uniqueNums ; i++) {
    theNum = (Random(Number(uniqueNums))+1);
    if (una.length == 0) { una[i] = theNum }
    else {
    for (n = 0; n < una.length ; n++) {
    if (theNum == una[n-1]) {
    una.pop();
    i--;
    n = una.length;
    } else {
    una[i] = theNum

    }
    }
    }
    }


    var quoteData = new LoadVars();
    quoteData.onLoad = function(success) {

    if (success) {
    myFactsArray = quoteData.microArray.split("|");
    //randNum = Math.floor(Math.random() * myFactsArray.length);
    animationTimer = setInterval(animateIt, typeSpeed, myFactsArray[una]);
    this.random3.gotoAndPlay(1); //PLACING HERE DOES NOT WORK
    }
    }

    quoteData.load("neighbours.txt", _root.randomText.Texts);

    function animateIt(targetString) {
    if (currentCount < targetString.length) {
    Texts.text += targetString.charAt(currentCount);
    currentCount++;


    } else {

    clearInterval(animationTimer);
    setTimeout(refreshQuote,pauseDelay);
    trace("CLEARED INTERVAL");



    }
    }
    function refreshQuote() {
    trace("REFRESH CALLED");
    //reset vars
    currentCount = 0;
    Texts.text = "";
    animationTimer = setInterval(animateIt, typeSpeed, myFactsArray[una]);
    this.random3.gotoAndPlay(1); //PLACING HERE DOES NOT WORK EITHER


    }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Without seeing your fla file ( whic would be heaps more helpful to get all the structure of it)

    I think you might need to change all

    PHP Code:
    Texts.text 
    to
    PHP Code:
    randomText.Texts.text 
    and change all
    PHP Code:
    this.random3.gotoAndPlay(1
    to
    PHP Code:
    random3.gotoAndPlay(1
    but attaching the fla would make it so much easier to figure out.

  3. #3
    Member
    Join Date
    Sep 2010
    Posts
    73
    you are already on this.random3.gotoAndStop(1);

    on the refesh this.random3.gotoAndStop(2);

    and on this.random3.gotoAndStop(2); add a line is refeshed = true;

    function refreshQuote() {
    trace("REFRESH CALLED");
    //reset vars
    currentCount = 0;
    Texts.text = "";
    animationTimer = setInterval(animateIt, typeSpeed, myFactsArray[una]);
    if(refeshed== true)
    {
    this.random3.gotoAndStop(1); //PLACING HERE DOES NOT WORK EITHER
    refeshed = false;
    }
    else
    {
    this.random3.gotoAndStop(2);
    refeshed = true;
    }


    }


    it will be like flipping the page from page one to page two in a book back and forth
    think if it like a book. with two pages..

    its very hard to flip to page one, when you are on page one. mater of fact you cant flip to page one when your on page one, but you could flip to page two and then flip back to page one.
    Last edited by Mancent; 11-15-2012 at 01:42 PM.
    WiiStream A Social Movie Network Version 0.1.1 Demo Testers Aproved http://wiistream.net/WiiStream.exe

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