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

AS3 and/or PHP Array Issue

Guest
Aug 17, 2008 Aug 17, 2008
Good day,

Does anyone have any ideas (better yet, an effective solution) as to why the following PHP code:

TOPICS
ActionScript
826
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

correct answers 1 Correct answer

Engaged , Aug 18, 2008 Aug 18, 2008
Hello again,

Thanks for pointing out that missing semi-colon in the PHP script. Don't know how I missed that? Anyway, I would like to point you to an example I made which uses most of your Actionscript and my PHP code I showed you above.

I would like to tell you that there is a major difference between testing within the Flash IDE and thru the browser. If I test locally, saving my FLA under my localhost directory(via Apache), and use Flash to test for trace statements - I'm only ever going to ...
Translate
Engaged ,
Aug 18, 2008 Aug 18, 2008
The Actionscript is fine. Try changing your loop to match the following.

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
Aug 18, 2008 Aug 18, 2008
Thanks Noelbaland,

Unfortunately, the following PHP:

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
Engaged ,
Aug 18, 2008 Aug 18, 2008
Hello again,

Thanks for pointing out that missing semi-colon in the PHP script. Don't know how I missed that? Anyway, I would like to point you to an example I made which uses most of your Actionscript and my PHP code I showed you above.

I would like to tell you that there is a major difference between testing within the Flash IDE and thru the browser. If I test locally, saving my FLA under my localhost directory(via Apache), and use Flash to test for trace statements - I'm only ever going to get one result because Flash doesn't cache the SWF file. It doesn't matter how many records you add to the database or how many changes you make to your PHP file, the SWF will not cache if you try and view it thru Flash. Therefore each time you hit Test Movie, you'll see the same result over an over again.

The best way to view and test your movie is thru the browser. If you have a local set-up like I do (I use Wampserver), then open your browser, turn your server on, and view the HTML file of your published Flash movie that way (mine is http://localhost/FLASH/Fetch.html). Place a dynamic textbox on stage and output the results to this textbox, rather than trace statements. Do your Flash/PHP testing this way - not thru the IDE.

Take a look at the example I've created and you'll see that the results are generated as you've requested. This data is live from a MySQL database online where I've used the same entry names in my table as yours. Apart from the missing semicolon I haven't changed a thing in the PHP script I provided. The actionscript is the same as yours in the Flash file. If you need to you can download the files and take a look.

Online example:
http://www.5degrees.co.nz/tests/Fetch.html

The ExtVarsTest.php file:
http://www.5degrees.co.nz/tests/ExtVarsTest.php

Download Files:
http://www.5degrees.co.nz/tests/Fetch.zip
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
Aug 21, 2008 Aug 21, 2008
Thanks again Noelbaland,

You just taught me something I didn't know about the Flash Output panel.

Incidentally, I really appreciate your assistance! All my best to you buddy!

Troy
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
New Here ,
Sep 04, 2008 Sep 04, 2008
LATEST
That is odd,

Using this php -

<?php
$getYear=$_POST['year'];
$getMonth=$_POST['month'];
$getDate=$_POST['date'];

//omitted host etc...

$con = mysql_connect($host,$username,$password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db($db_name, $con);

$result = mysql_query("SELECT * FROM calendar WHERE year='$getYear' AND month='$getMonth' AND date='$getDate'");

$return = "";

// Loop thru and pull out all records
while($row = mysql_fetch_assoc($result))
{
$return = $return . "year=" . $row["year"] ."&";
$return = $return . "month=" . $row["month"] ."&";
$return = $return . "date=" . $row["date"] ."&";
$return = $return . "time=" . $row["time"] ."&";
$return = $return . "title=" . $row["title"] ."&";
$return = $return . "description=" . $row["description"] ."&";
$return = $return . "type=" . $row["type"] ."&";
}

// Get rid of the last ampersand and echo the string
$return = substr($return, 0, -1);

echo $return;

mysql_close($con);

?>

---------------------
and this AS

var url:String = phpURL;
var reqURL:URLRequest = new URLRequest(url);
reqURL.method = URLRequestMethod.POST;

var variables:URLVariables = new URLVariables();
variables.year = "2008";
variables.month = "9";
variables.date = "29";

reqURL.data = variables;
var ldr:URLLoader = new URLLoader(reqURL);
ldr.dataFormat = URLLoaderDataFormat.VARIABLES;
ldr.addEventListener(Event.COMPLETE, handleComplete);

function handleComplete( event:Event ):void
{
var ldr:URLLoader = URLLoader(event.target);
var vars:URLVariables = new URLVariables(ldr.data);
trace("year="+vars.year);
trace("month="+vars.month);
trace("day="+vars.date);
trace("time="+vars.time);
trace("title="+vars.title);
trace("description="+vars.description);
trace("type="+vars.type);
}


---------------------
yields in the flash output panel

year=2008,2008
month=9,9
day=29,29
time=5:00,6:00
title=Test Event,test event 2
description=this is a test event to test the functionality of the calendar.,this is a second test event
type=1,1


---------------------
No problem with testing in the flash IDE.

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