Welcome, Guest
  • Author Topic: CS3 AS2 Datagrid not populateing on server  (Read 13475 times)

    POUND!

    • Server what's that
    • *
    • Posts: 4
      • View Profile
      • Email
    CS3 AS2 Datagrid not populateing on server
    « on: 09/17/09, 17:35 »
    Hi everyone,

    Wasn't sure where to post this one as I'm not sure where the error is occuring.

    I have datagrid components being populated from a mySQL DB using php. The grids exist on external swfs being loaded into a parent clip.

    The datagrids populate locally no problem when tested individually and when loaded into the parent clip. They have also been working from the server in previous days, but I was doing final tests checks on some recent final changes and now things aren't working.

    obviously I went back and ran through what I changed but nothing really applied to the grids.

    I'm right on deadline and any advice would help.

    Codes are below

    Cheers

    AS
    Code:

    Code: [Select]
    //DISPLAY ON TAP BEERS
    var myOnGridArray:Array = [];
    myOnGridArray.push({status:"loading data..."});
    myOnGrid.dataProvider = myOnGridArray;
    var myDataHolder:Array = [];
    var sender:LoadVars = new LoadVars();
    var receiver:LoadVars = new LoadVars();
    receiver.onLoad = function(ok) {
    if (ok) {
    myOnGrid.removeAllColumns();
    myOnGrid.removeAll();
    for (var i = 1; i<=receiver.total; i++) {
    receiver["dataPacket"+i] = receiver["user_data"+(i)].split("|");
    var _ID:String = receiver["dataPacket"+i][0];
    var _beerName:String = receiver["dataPacket"+i][1];
    var _type:String = receiver["dataPacket"+i][2];
    var _ABV:String = receiver["dataPacket"+i][3];
    var _description:String = receiver["dataPacket"+i][4];
    var _link:String = receiver["dataPacket"+i][5];
    var _brewery:String = receiver["dataPacket"+i][6];
    var _breweryLocation:String = receiver["dataPacket"+i][7];
    var _status:String = receiver["dataPacket"+i][8];
    var _location:String = receiver["dataPacket"+i][9];
    myOnGridArray.push({bottleID:_ID, Name:_beerName, Type:_type, ABV:_ABV, Description:_description, Link:_link, brewery:_brewery, breweryLocation:_breweryLocation, Status:_status, bottleLocation:_location});
    var dataObj:Object = {};
    dataObj.ID = _ID;
    dataObj.beerName = _beerName;
    dataObj.type = _type;
    dataObj.ABV = _ABV;
    dataObj.description = _description;
    dataObj.link = _link;
    dataObj.brewery = _brewery;
    dataObj.breweryLocation = _breweryLocation;
    dataObj.status = _status;
    dataObj.location = _location;
    myDataHolder.push(dataObj);
    delete (receiver["user_data"+i]);
    }
    myOnGrid.dataProvider = myOnGridArray;
    setupGrid();
    } else {
    myOnGrid.removeAllColumns();
    myOnGrid.removeAll();
    myOnGridArray.push({Status:"No data was found!"});
    myOnGrid.dataProvider = myOnGridArray;
    }
    myOnGrid.removeColumnAt(8);
    myOnGrid.removeColumnAt(7);
    myOnGrid.removeColumnAt(6);
    myOnGrid.removeColumnAt(5);
    myOnGrid.removeColumnAt(4);
    myOnGrid.removeColumnAt(3);
    myOnGrid.removeColumnAt(0);

    };
    sender.sendAndLoad("http://myclientsdomain/SHARED/scripts/onTap.php",receiver,"post");

    setupGrid = function(){;
    var myOnGridSensorObj:Object = {};
    myOnGridSensorObj.cellPress = function(){;
    if(myOnGrid.selectedIndex == undefined){;
    trace("error");
    }else{;
    var userData:Array = myDataHolder[myOnGrid.selectedIndex];
    showDetails(userData.ID,userData.beerName,userData.type,userData.ABV,userData.description,userData.link,userData.brewery,userData.breweryLocation,userData.status,userData.location);
    };
    };
    myOnGrid.addEventListener("cellPress",myOnGridSensorObj);
    };
    showDetails = function($ID:Number,$beerName:String, $type:String, $ABV:String, $description:String, $link:String,$brewery:String, $breweryLocation:String, $status:String, $location:String){;
    beerID.text = ""+$ID+"";
    beerName.htmlText = ""+$beerName+"";
    beerType.htmlText = ""+$type+"";
    ABV.htmlText = ""+$ABV+"";
    beerDescription.htmlText = ""+$description+"";
    link.htmlText = ""+$link+"";
    brewery.htmlText = ""+$brewery+"";
    breweryLocation.htmlText = ""+$breweryLocation+"";
    statusOn.selected = true;
    //trace($bottleLocation);
    if ($location=="Mel") {;
    locationMel.selected = true;
    }else if ($location=="Syd") {;
    locationSyd.selected = true;
    }else if ($location=="Both") {;
    locationBoth.selected = true;
    };
    };

    PHP
    PHP Code:
    Code: [Select]
    <?php
    $server 
    "xxxxxxxx";
    $user "xxxxxxxxxx";  
    $pass "xxxxxxx";
    $database "xxxxx";
    $conn = @mysql_connect($server,$user,$pass);
    $database = @mysql_select_db($database,$conn);

    $query = @mysql_query('SELECT * FROM `taps` WHERE location NOT LIKE "Mel" AND status = "onTap" ORDER BY beerID desc');
    $total_rows = @mysql_num_rows($query);
    $counter 0;

    while(
    $ourData = @mysql_fetch_array($query)){
        
    $beerID $ourData["beerID"];
        
    $beerName $ourData["beerName"];
        
    $beerType $ourData["beerType"];
        
    $ABV $ourData["ABV"];
        
    $brewery $ourData["brewery"];
        
    $breweryLocation $ourData["breweryLocation"];
        
    $counter++;

        print(
    "&user_data$counter=$beerID|$counter|$beerName|$beerType|$ABV|$brewery|$breweryLocation");
    }
    print(
    "&total=$total_rows");
    ?>

    POUND!

    • Server what's that
    • *
    • Posts: 4
      • View Profile
      • Email
    Re: CS3 AS2 Datagrid not populateing on server
    « Reply #1 on: 09/17/09, 17:56 »
    OK,

    I've discovered by accident that some of the grids and other dynamic fields work if "www" is typed before the address and others work if there is no "www".

    From memory I have dealt with this situation before but is there something I am doing wrong that leads to this situation and more to the point, can I fix this with a .htaccess or crossdomain policy file etc?

    Cheers

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: CS3 AS2 Datagrid not populateing on server
    « Reply #2 on: 09/18/09, 11:12 »
    Flash sees the www und not www as beeing different domains - so you need a crossdomain xml file placed in your root stating that cross referencing is allowed, or just dont refference this way ;)
    happy flashing
    8)
    Ronald

    POUND!

    • Server what's that
    • *
    • Posts: 4
      • View Profile
      • Email
    Re: CS3 AS2 Datagrid not populateing on server
    « Reply #3 on: 09/28/09, 18:50 »
    Thanks Ronald!

    I ended up using a crossdomain file which fixed it all up.

    As general practice, how would you recommending referencing.

    When I have control over the structure of the server, I'd use ../file.php but when the client won't give me direct access it can make this tricky for live testing as I then have to go through and change every reference.

    I've got to the point now where I really have to streamline all my practices (that I used to be able to get away with) so any suggestions would be really helpful!

    Cheers

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: CS3 AS2 Datagrid not populateing on server
    « Reply #4 on: 09/29/09, 03:54 »
    especialy in these cases, where you have to expect www and normal addresses, you might need to write this crossdomain file.

    If you make sure, that the first movieclip, which loads all the others, is loaded from http://... without www, you can just refference relative, because you set the first one.

    So the important part is inside of the html-container. If you use absolute address there, you are propably fine.

    If you are writing a application to be installed on many different systems, you might need something like a config file keeping track of the installation parameters.
    happy flashing
    8)
    Ronald