Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 09:15
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  PHP, Perl, ASP, JSP, CFM (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Jorge Solis, nothingGrinder)
| | |-+  Any HELP please? PHP and Action Script
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Any HELP please? PHP and Action Script  (Read 2684 times)
dsn7287
Server what's that
*
Posts: 6


View Profile Email
« on: 04/13/09, 18:30 »

Ok guys I am pretty ok at php but am pretty much a novice when it comes to Flash/ Actionscript, but i really need to get this done. I have done tons and tons of research in the last 3 days and I still have not been able to get anywhere with this. Any help you could give me would be VERY much appreciated.

***All the code that is shown below i have come up with trying to follow the various sources online.***

This is the php file I have:
weather.php
Quote
<?
$weatherid="UKXX1586";
echo "weatherid=$weatherid";
exit;
?>

in my .fla I have:
Quote
var lvSend = new LoadVars();
var lvReceive = new LoadVars();
lvSend.SendAndLoad("my http path goes here yes?/weather.php",lvReceive,"POST");
lvReceive.onLoad = function(bSuccess) {
if(bSuccess == true) {
{
trace(this.weatherid); Copied this from somewhere on the net, so not sure how to use this variable other than in a trace
}
}

.......Some other stuff here


function dloc() {
   
        units = "c";
   
   weatherCode = Ok this is where I need the value of that variable (weatherid) so that it can be used to get the weather using this code ;
}

dloc();



Guys please please help if you can as this is pretty urgent.

Cheers...
« Last Edit: 04/13/09, 22:17 by dsn7287 » Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #1 on: 04/14/09, 05:30 »

this never would work, if you expect to receive the code, before you call the function.

Remember: we are working in a event driven environment.

If you fire a call before the first call received the answer, it will run into eternity.


Here is the fix:

Code:
var lvSend = new LoadVars();
var lvReceive = new LoadVars();
lvSend.SendAndLoad("my http path goes here yes?/weather.php",lvReceive,"POST");

lvReceive.onLoad = function(bSuccess) {
if(bSuccess) {
    dloc(this.weatherid);
}
}

.......Some other stuff here


function dloc(code) {
   
        units = "c";
   
   weatherCode = code;
}
Logged

happy flashing
Cool
Ronald
dsn7287
Server what's that
*
Posts: 6


View Profile Email
« Reply #2 on: 04/14/09, 12:49 »

hiya mate,
I used the code you provided me withword fro word. Using the code below I understand what you mean about event driven. However after trying out the code i still have errors in the sense that no values seem to be getting passed, or the thing is going on some kind of infinite loop maybe?

var lvSend = new LoadVars();
var lvReceive = new LoadVars();
lvSend.SendAndLoad("my http path goes here yes?/weather.php",lvReceive,"POST");

lvReceive.onLoad = function(bSuccess) { When I ran this code debug mode, it comes upto this part and then the pointer seems to just disappear into nowhere. At this point the debug output window shows the values -16320 & -16323. Can you provide any insight into this by any chance, and maybe a possible solution please? Any help is very very much appreciated.

if(bSuccess) {
    dloc(this.weatherid);
}
}

.......Some other stuff here - Even removed all of this


function dloc(code) {
   
        units = "c";
   
   weatherCode = code;
}
Logged
dsn7287
Server what's that
*
Posts: 6


View Profile Email
« Reply #3 on: 04/14/09, 18:16 »

Hiya mate,
Using some of your code and some other stuff I managed to piece together I finall have something tha works.... Thanks for all your help.... Decided to go with a txt file as opposed to a php one (from info provided in the flash-db tutorial this was much much simpler!)... Much easier! Smiley

Here's the code I ended up with jus incase someone needs it in the future:

Code:
myData = new LoadVars()
    myData.load("http://<<someurl>>/data.txt")
    myData.onLoad = function(succes){
      if(succes){
            dloc(this.name1);
} else trace ("Error loading data")
    }
function dloc(code) {
units = "c";
weatherCode = code;
}

text file
Code:
name1=UKXX0047
« Last Edit: 04/14/09, 18:18 by dsn7287 » Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #4 on: 04/15/09, 00:20 »

I hope, you are not running this in a loop.
If you have this code in a keyframe, this frame should only be run once.

Even though this might be an easy thing, Charles could help you understand the communication.

Download and install Charles (as described in the loading and saving tutorials) and see what happens on the line.

Do you have this online somewhere, so we may have a look into the life system?
Logged

happy flashing
Cool
Ronald
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!