Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Display data from db to flash label

Guest
Jan 10, 2013 Jan 10, 2013

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);

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 11, 2013 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 11, 2013 Jan 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 11, 2013 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 11, 2013 Jan 11, 2013

Instead of using textfield, i use label. So this label will show my data from the database but currently, it shows undefined whenever i play the swf. It didn't read the data from my database. Do you still need a screenshot?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 11, 2013 Jan 11, 2013

Here is a tutorial how to use the Button Component`s label property: Maybe that can help you. Without a screenshot of your problem I can only guess what kind of "label" you are referring to.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 11, 2013 Jan 11, 2013

I just checked..it's not label. It's a textfield..Sorry for the wrong information! Well, yeah..It's still undefined though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 11, 2013 Jan 11, 2013

Mark the Textfield in your fla, then go to the properties window and make sure, you named it.

"wa_info". Make also sure its not inside any MovieClip otherwise your code won`t find it.

From the 3 options beneath (Static/dynamic/Input) choose "Dynamic" and for the sake of simplicity choose Classsic Text (not TLF-Text).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 11, 2013 Jan 11, 2013

Yep. Did it but still undefined. Is the actionscript above correct?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 11, 2013 Jan 11, 2013

If it compiles without errors, you should be fine.

after the line:

wa_info.autoSize = TextFieldAutoSize.LEFT;

insert

trace(event.target.data.result);

when you compile it,

what does the output window say?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 11, 2013 Jan 11, 2013
LATEST

I solved it! The code is fine..Is just that i was very careless. I forgot to change one simple code from it. I should be more observant next time..haha..By the way, thanks so much for your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines