dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: avoiding 'onLoad=[type Function]'

  1. #1

    avoiding 'onLoad=[type Function]'

    Hi,

    I have a dynamic text box that retrieves text from a PHP file that in turn retrieves text from a mySQL database. Sometimes the PHP file may necessarily display no text if the mySQL database is empty. However, when the dynamic text box in Flash tries to retrieve text from an empty PHP file the dynamic text box displays onLoad=[type Function]. Is there a way of making the dynamic text box display nothing in such circumstances?

    I have attached the actionscript the dynamic text box uses to retrieve its text and also the PHP code used to retrieve text from the mySQL database.

    Many, many thanks,

    leao

    Actionscript
    code:
    path = "http://www.stpatrickscommunity.org/admin/text/landline.php";
    lv = new LoadVars();
    lv.onLoad = function(){
    str = unescape(this);
    str = str.split("=&onLoad=[type Function]").join("");
    landline.html = true;
    landline.htmlText = str;
    };
    lv.load(path);



    PHP
    PHP Code:
    <?php
    header
    ('Content-type: text/html; charset=utf-8');
    mysql_connect("mysql.myhosting.com","stpatri_user","password") or die(mysql_error());
    mysql_select_db("stpatri_table") or die(mysql_error()); 
    $result mysql_query("SELECT * FROM text")
    or die(
    mysql_error());  
    $row mysql_fetch_array$result );
    $str_encoded=urlencode($row['landline']);
    echo 
    "$str_encoded";
    ?>

  2. #2
    Big Baby Fabriq-En-Chine's Avatar
    Join Date
    Sep 2005
    Location
    In My Pants
    Posts
    193
    check for the value of the variable you're sending back in the url string.

    if the value of the variable is undefined then you can display "" - otherwise display it's value

  3. #3
    Hi, I resolved the problem by using XML.onData instead of LoadVars:

    Code:
    path = "http://www.stpatrickscommunity.org/admin/text/landline.php";
    lv = new XML();
    lv.onData = function(str){
    str = unescape(str);
    landline.html = true;
    landline.htmlText = str;
    };
    lv.load(path);
    Thanks,

    Leao

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