Beggin' for some help. Fade out, and a bug...

  • Endlaw
  • Born
  • Born
  • Endlaw
  • Posts: 1

Post 3+ Months Ago

First of all thank you for taking the time to read this, I have a primitive understanding of AS3 code, and apologize if this may be a noob question.

Conceptually though I believe I can get the dynamic text box to fade out, the same way it fade's in. I have yet to find an example of AS3 fading out a dynamic text box that refer's to an XML file... +/

I need to fix a couple things, with this code.

The first thing i noticed is the code seems to call for the .php file before it can load, so at times it will generate a "undefined" for both the quote and author.

The second thing is, which may tie into the first, there seems to be the occasion where the code doesn't load the php file at all. The author and quote will be blank for a duration.

And the third question i have is how do i get the text to fade out again after the fade in after an interval.

I would greatly appreciate any help with this, as I am finding very little in regards to others that may have noticed these issues and possible fix's for it.

Thank you in advance.

I will provide a live page to view the bug if you wish, but here i cant post links... so ill have to PM it.

Code: [ Select ]
import caurina.transitions.Tweener;

var quote:Array = new Array();
var author:Array = new Array();
var totalQuotes:Number;

var rotateTimer:Timer = new Timer(10000, 100); //rotates the quote every 2 seconds for 100 times
quoteMC.alpha = 0;
authMC.alpha = 0;
rotateTimer.addEventListener("timer", rotateQuote);//add a listener to the timer
rotateTimer.start(); // start the timer

function init():void {
    var quotesXML:XML = new XML();
    quotesXML.ignoreWhitespace = true;
    var XMLURL:URLRequest = new URLRequest("~/images/quoterotator/quotes1.xml");
    var myLoader:URLLoader = new URLLoader(XMLURL);
    myLoader.addEventListener("complete", xmlLoaded);
    function xmlLoaded(event:Event):void {
        quotesXML = XML(myLoader.data);
        totalQuotes = quotesXML.quote.length();
        for (var i:int = 0; i < quotesXML.quote.length(); i++) {
            quote[i] = quotesXML.quote[i].text;
            author[i] = quotesXML.quote[i].author;
        var initRandom:Number = randomNumber(0, totalQuotes);
        quoteMC.quote_txt.text = String(quote[initRandom]);
        authMC.author_txt.text = String(author[initRandom]);
        }
    }
}

function rotateQuote(evt:TimerEvent) {
    quoteMC.quote_txt.text = "";
    authMC.author_txt.text = "";
    var randomness:Number = randomNumber(0, totalQuotes);
    Tweener.addTween(quoteMC, {alpha:1, time:5});
    Tweener.addTween(authMC, {alpha:1, time:5});
    quoteMC.quote_txt.text = quote[randomness]||"";
    authMC.author_txt.text = author[randomness]||"";
}

function randomNumber(low:Number, high:Number):Number {
    var low:Number = low;
    var high:Number = high;
    quoteMC.alpha = 0;
    authMC.alpha = 0;
    Tweener.addTween(quoteMC, {alpha:1, time:5});
    Tweener.addTween(authMC, {alpha:1, time:5});
    return Math.round(Math.random() * high - low) + low;
}
    
init();
  1. import caurina.transitions.Tweener;
  2. var quote:Array = new Array();
  3. var author:Array = new Array();
  4. var totalQuotes:Number;
  5. var rotateTimer:Timer = new Timer(10000, 100); //rotates the quote every 2 seconds for 100 times
  6. quoteMC.alpha = 0;
  7. authMC.alpha = 0;
  8. rotateTimer.addEventListener("timer", rotateQuote);//add a listener to the timer
  9. rotateTimer.start(); // start the timer
  10. function init():void {
  11.     var quotesXML:XML = new XML();
  12.     quotesXML.ignoreWhitespace = true;
  13.     var XMLURL:URLRequest = new URLRequest("~/images/quoterotator/quotes1.xml");
  14.     var myLoader:URLLoader = new URLLoader(XMLURL);
  15.     myLoader.addEventListener("complete", xmlLoaded);
  16.     function xmlLoaded(event:Event):void {
  17.         quotesXML = XML(myLoader.data);
  18.         totalQuotes = quotesXML.quote.length();
  19.         for (var i:int = 0; i < quotesXML.quote.length(); i++) {
  20.             quote[i] = quotesXML.quote[i].text;
  21.             author[i] = quotesXML.quote[i].author;
  22.         var initRandom:Number = randomNumber(0, totalQuotes);
  23.         quoteMC.quote_txt.text = String(quote[initRandom]);
  24.         authMC.author_txt.text = String(author[initRandom]);
  25.         }
  26.     }
  27. }
  28. function rotateQuote(evt:TimerEvent) {
  29.     quoteMC.quote_txt.text = "";
  30.     authMC.author_txt.text = "";
  31.     var randomness:Number = randomNumber(0, totalQuotes);
  32.     Tweener.addTween(quoteMC, {alpha:1, time:5});
  33.     Tweener.addTween(authMC, {alpha:1, time:5});
  34.     quoteMC.quote_txt.text = quote[randomness]||"";
  35.     authMC.author_txt.text = author[randomness]||"";
  36. }
  37. function randomNumber(low:Number, high:Number):Number {
  38.     var low:Number = low;
  39.     var high:Number = high;
  40.     quoteMC.alpha = 0;
  41.     authMC.alpha = 0;
  42.     Tweener.addTween(quoteMC, {alpha:1, time:5});
  43.     Tweener.addTween(authMC, {alpha:1, time:5});
  44.     return Math.round(Math.random() * high - low) + low;
  45. }
  46.     
  47. init();
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 19 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.