Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 8th, 2012, 08:36 AM
HuddyHuda HuddyHuda is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 2 HuddyHuda User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 10 sec
Reputation Power: 0
ActionScript 3 - ActionScript 3 Display From PHP Variable.

What do i do so that flash display all the results from php in the looped movieclips?

Can someone help me? I'm trying to extract out the data from php using array so that every rows have different data according to the rows in mysql. But right now only one data from a row of mysql seem to be displayed. However when i traced.. it displayed all the data. But how do i assign to the
looped newContainer such tht, each of the newContainer have different rows of data?


What should I do so that the each newContainer have different event names, dates, slots left coming from the 8 results respectively? And not just one newContainer displaying only one result the data. I have like 8 rows to be displayed in flash from my sql..

this is my code..

import flash.events.MouseEvent;
import flash.events.Event;
import fl.motion.MotionEvent;
import flash.net.URLVariables;
import flash.display.MovieClip;
import flashx.textLayout.elements.Configuration;



var ctr:int = 0;
var nowate = new Date();


var myurl:String = "http://localhost:8888/eventspictures/getdata.php";

var containers:Array = [];

var scriptLoader:URLLoader = new URLLoader();
var scriptRequest:URLRequest = new URLRequest();



scriptRequest.url = myurl + "?ck=" + now.getTime();

scriptLoader.addEventListener(Event.COMPLETE, handleLoadSuccess);
scriptLoader.addEventListener(IOErrorEvent.IO_ERROR, handleError);



scriptRequest.method = URLRequestMethod.POST;
scriptLoader.load(scriptRequest);


function handleLoadSuccess(evt:Event):void
{

for (var j:Number = 0; j <4; j++)
{
var newContainer:MovieClip = new con();
newContainer.name = String(ctr);

newContainer.y = j*80 +65;
newContainer.x= 16;

stage.addChild(newContainer);
containers.push(newContainer);






var variables:URLVariables = new URLVariables(evt.target.data);
trace(variables.output);


var parse:String = variables.output;
var parsed:Array = parse.split("<|>");

var tab:String = ' ';
var eventname:String = '';
var date:String='';
var slotsleft:String='';



// different variable names to assign to different column names(etc; eventname, date, slotsleft)
// loop through.. start from O

for (var i:Number = 0; i<parsed.length-1; i++)
{
trace(parsed[i]);

var item:String = parsed[i];
var itemarray:Array = item.split(",");

eventname += itemarray[2] + tab + "<br>";
date += itemarray[3] + tab;
slotsleft += itemarray[4] + tab;






trace(eventname);





}


}



newContainer.eventname_txt.htmlText = eventname;
newContainer.date_txt.htmlText= date;
newContainer.slotsleft_txt.htmlText=slotsleft;




//slotsleft_txt.x = 270;
}
function handleError(evt:IOErrorEvent):void
{
}

backbutton_mc.addEventListener(MouseEvent.CLICK, goHomePage);


function goHomePage (evt:Event):void{


gotoAndPlay("dashboard");
for (var j:int = 0; j < containers.length; j++)
{
stage.removeChild( containers[j] );

}


}



stop();



or issit a php error?

Here's the php code..

<?php

$_POST['orderby']= "date";
$_POST['sortby']= "asc";

$host = 'localhost'; // or '127.0.0.1'
$user ='root'; //FTP login name if own server
$password= 'root'; // FTP PASSWORD

$connection = mysql_connect($host,$username,$password);

$connection = mysql_connect($host, $user, $password);
if (!$connection) {
echo 'error=' . mysql_error() . '&';
die('Could not connect ' . mysql_error());
}
//echo 'Connected successfully' ."\n<br />";

// * means everything

$database = 'eventspictures';

$db = mysql_select_db($database, $connection);
if (!$db) {
echo 'error=' . mysql_error() . '&';
die ('Not connected : ' . mysql_error());
}
//echo 'Database Selected successfully'."\n<br />";

//3. Build a query


if ($_POST['orderby']){

$query= 'select * from eventsdata order by '.$_POST['orderby'].' '.$_POST['sortby'];

}else{

$query= 'select * from eventsdata';
// select everything from eventsdata

}





$results = mysql_query($query, $connection) or die('Query not run' . mysql_error());

//echo 'Query run<br>';

//4. Fetch data and 5. Loop to display data

/*while($row = mysql_fetch_array($results)){



extract ($row);
echo "$id, $admin, $name \n<br>";
}
*/



//6. format for flash



while($row = mysql_fetch_array($results)){

extract ($row);
$output .= "$id,$image,$eventname,$date,$slotsleft".'<|>';


}

echo 'output='.urlencode($output);






//7. database close
mysql_close($connection); // only if you use mysql_connect()
?>

Reply With Quote
  #2  
Old July 12th, 2012, 06:50 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 6,663 Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)  Folding Points: 14767 Folding Title: Novice Folder
Time spent in forums: 1 Month 1 Week 3 Days 20 h 10 m
Reputation Power: 3163
Facebook MySpace
Hi, did you get this sorted out? It's hard to tell what's going on, could you repost your code but wrap it in [code][/code] tags so all the indenting is in place. One thing I did notice was that you can move this bit outside the loop as it doesn't need to be done multiple times:

Code:
var variables:URLVariables = new URLVariables(evt.target.data);
trace(variables.output);

var parse:String = variables.output;
var parsed:Array = parse.split("<|>");

var tab:String = ' ';
var eventname:String = '';
var date:String='';
var slotsleft:String='';


You say it traces correctly but you don't say which trace, you have more than one. I'm curious what this one traces: trace(parsed[i]); as that would tell us if it is correctly parsing your data.
__________________
Quis custodiet ipsos custodes?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > ActionScript 3 - ActionScript 3 Display From PHP Variable.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap