Skip to main content
January 11, 2013
Question

Display data from db to flash label

  • January 11, 2013
  • 1 reply
  • 1174 views

Hey guys,

I still can't get the data from mysql to the flash label after so many tries and research. I managed to read the data (from the db) from my php file. I don't think there's a problem with the php file..however, i think the problem came from the actionscript. I'm gonna post both below anyway just in case. Is it because i can't use label? Or i have to use textbox? I don't know, i'm a newbie in actionscript. So, please help!! Thanks!

php

<?php

include_once "dbconnect.php";

($_POST['systemCall'] == "checkWA");

   

$tbl_name = "info";

$result = "";

$sql = "SELECT wa1 FROM $tbl_name"; //column wa1 for 1 textbox

$query = mysql_query($sql) or die ("cannot access");

$wa_one = mysql_num_rows($query);

while ($data = mysql_fetch_array($query)) {

$wa_one = $data["wa1"];

$result = "$wa_one";

}

print $result;

?>

actionscript --> I believe the problem starts here

import flash.display.*;

import flash.events.*;

import flash.net.URLLoader;

import flash.net.URLRequest;

import flash.net.URLVariables;

import flash.net.URLLoaderDataFormat;

import flash.net.URLRequestMethod;

var phpVars:URLVariables = new URLVariables();

var phpFileRequest:URLRequest = new URLRequest("wa.php");

phpFileRequest.method = URLRequestMethod.POST;

phpFileRequest.data = phpVars;

 

var phpLoader:URLLoader = new URLLoader();

phpLoader.dataFormat = URLLoaderDataFormat.TEXT;

phpLoader.addEventListener(Event.COMPLETE, showWa);

function showWa(event:Event):void

{

wa_info.autoSize = TextFieldAutoSize.LEFT;

    if (event.target.data.result == "")

    {

        wa_info.text = "No Data"; 

    }

    else

    {

        wa_info.condenseWhite = true;

        wa_info.text = "" + event.target.data.result;

    }

}

phpVars.systemCall = "checkWA";

phpVars.wa_info = wa_info.text;

phpLoader.load(phpFileRequest);

This topic has been closed for replies.

1 reply

Inspiring
January 11, 2013

First: Enable debugging in your fla (Publishing options->allow debugging)

then publish with Ctrl+Shift+Enter

Go to the Output window and report back.

January 11, 2013

Hi, thanks for replying...

When i use this code,

phpLoader.dataFormat = URLLoaderDataFormat.TEXT;

It won't debug.

But when i changed it to:

phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

It did bebug but the label, where i wanted the data to show up, shows undefined...

What's the problem here?

Inspiring
January 11, 2013

What do you mean by label? Do you use a textfield that is named "label" or do you use Button Component? Are you getting the "undefined" message in the debug output or shows it up in the swf. Post a screenshot if possible.