PDA

View Full Version : TypeError: Error #2007: Parameter text must be non-null.


scross
16-11-2009, 08:17 AM
Hi There,



I am trying to get a swf file to send variables to a php file and then have the php file return a variable and display it within a dynamic text field however everytime I run it, I get the following error:



TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at OCC_checklist_page_2_fla::MainTimeline/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()



I have no idea how to resolve this issue. Does anyone have any ideas?



php code:



<?php
require_once('../../layer/ws/onWsStart.php');
require_once('../../layer/app/fSessionKey.php');



$sessionKey = 0;



if ( isset( $_POST['operation_id']) && isset($_POST['mission_id']) && isset ($_POST['section_id']) ) {
$studentId = getStudentId();
$sessionKey = randomiseKey( $studentId, $_POST['operation_id'], $_POST['mission_id'], $_POST['section_id'] );
storeKey( $sessionKey, $studentId, $_POST['operation_id'], $_POST['mission_id'], $_POST['section_id'] );



}
print "sessionkey=".$sessionKey;
?>



Actionscript 3.0



var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("http://test.flamingcow.com.au/layer/ws/xGenSessionKey.php");
varSend.method = URLRequestMethod.POST;
varSend.data=variables;



var varLoader:URLLoader = new URLLoader();
varLoader.dataFormat=URLLoaderDataFormat.VARIABLES ;



varLoader.addEventListener(Event.COMPLETE, completeHandler);



variables.operation_id="1";
variables.mission_id="1";
variables.section_id="1";



varLoader.load(varSend); //This sends the variables to php


//Step 1. POST variables to Get sessionkey


function completeHandler(event:Event):void{

var sessionVar = event.target.data.sessionkey; //flash variable to hold variable created in php
flash_sessionVar.text=sessionVar; //prints variable taken from php into the dynamic text field in flash
}

scross
16-11-2009, 12:24 PM
Ok! A friend fixed the issue and thought I would post the solution for any other newbies such as myself out there needing a helping hand:

removed extraneous line breaks - this is both before *and* after the variable string.
There must be one carriage return at the end. no white space before and there must also be no other text beforehand - I suspect other variable assignments or comments will break it, eg.


print "sessionkey=".$sessionKey;"\r\n";