Home Tutorials Forums Articles Blogs Movies Library Employment Press
Prev Previous Post   Next Post Next
Old 07-17-2008, 08:08 AM   #1
vangojames
Member
 
Join Date: Jul 2008
Posts: 57
Question PHP/Flash problem

Hi, I can't seem to get my flash site to communicate with one of the private folders on the web server it is hosted on. I am trying to use PHP to fetch an XML file from the folder and make it available to flash. I have scripting enabled on the server and I have verified the scripting path to use. The page loads all content but says it is still waiting to access the server when trying to load in the XML file.
The AS3 code is:


ActionScript Code:
package com.net.php {     import flash.events.*;     import flash.net.*;         public class PHPExtLoader extends EventDispatcher     {         public var phpFile:String;         public var remoteFile:String;         public var req:URLRequest;         private var vars:URLVariables = new URLVariables();         private var loader:URLLoader = new URLLoader();         public var data:String;                 public function PHPExtLoader()         {                     }                 public function load(php:String, remote:String):void         {             phpFile = php;             remoteFile = remote;             req = new URLRequest(phpFile);             vars.fileName = remoteFile;             req.data = vars;             req.method = URLRequestMethod.POST;             loader.addEventListener(Event.COMPLETE, contentLoaded);             loader.load(req);         }                 private function contentLoaded(event:Event):void         {             data = loader.data;             dispatchEvent(new Event(Event.COMPLETE));         }             } }

The PHP code is:


PHP Code:
<?php
    $file 
$_POST['fileName'];
    echo 
file_get_contents($file);

?>
I don't know if it is a problem but the calling swf has been loaded by another using the following class to make sure that the parent swf can access the child swf methods:


ActionScript Code:
/* ::DESCRIPTION:: This will load in a SWF and allow it to be accessed through the getPage method in a state where its functions can be accessed by an external caller. It can be unloaded via the unloadPage method. The _currentProgress variable wil return the current percentage of bytes loaded. */ package net {     import flash.events.*;     import flash.display.*;     import flash.net.*;         public class PageLoader extends Loader     {     //::::::::::::VARS:::::::::::         //*********************CONNECTION/LOADING VARS**********************         public var _page:DisplayObject;     public var _currentProgress:Number = 0;         private var _pageURL:String;     private var _pageLoader:Loader;     private var _loaderInfo:LoaderInfo; //::::::::::::PROGRAM:::::::::::         public function PageLoader(PAGESWF:String)         {                _pageURL = PAGESWF;             _pageLoader = new Loader();         }                 public function loadPage():void         {             _pageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, setProg);             _pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, pageLoaded);             _pageLoader.load(new URLRequest(_pageURL));         }                 private function pageLoaded(event:Event):void         {             _pageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, pageLoaded);             _loaderInfo = event.target as LoaderInfo;             this.dispatchEvent(new Event(Event.COMPLETE));         }                 private function setProg(event:ProgressEvent):void         {             _currentProgress = (event.bytesLoaded / event.bytesTotal);                         if(event.bytesLoaded == event.bytesTotal)             {                 _pageLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, setProg);             }         }         public function getPage():*         {             return _loaderInfo;         }                 public function pageUnload():void         {             _pageLoader.unload();         }     } }


Any help would be really appreciated!! Thanks,

James
vangojames is offline   Reply With Quote
 


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with component scope / calling function FarFeTTu Components 2 03-10-2011 10:19 PM
maybe a caching problem? kath421 ActionScript 2.0 4 03-21-2006 05:41 AM
Problem with loading unloading clips and dynamic text sah302 ActionScript 1.0 (and below) 1 01-06-2006 05:19 PM
HEEELP!!! cant work out the answer to a problem case ActionScript 1.0 (and below) 1 07-29-2003 11:37 PM
global TextField Problem! Guru wonted mediaholic ActionScript 1.0 (and below) 3 07-20-2003 10:07 AM


All times are GMT. The time now is 07:21 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.