views:

82

answers:

1

I am putting together a presentation on flex for adobe user group that specialize in coldfusion. In my example I would like to display the text of the cfc being called from the webservice tag in my flex application. Is there a simple way to load the actual text for the cfc instead of the html that coldfusion is passing back to my URLloader variable?

Code that I have attempted to read the file:

 private function loadCodeTextAreas():void
 {
  codeURLLoader.load(new URLRequest("/FlexZenGardenCFC/GreetingService.cfc"));
  codeURLLoader.addEventListener(Event.COMPLETE,flexLoadCompleteHandler);
  codeURLLoader.addEventListener(IOErrorEvent.IO_ERROR,flexErrorHandler);
 }
 private function flexLoadCompleteHandler(e:Event):void
 {
  taCFCCode.text = codeURLLoader.data;
 }
+3  A: 

You would have to call a CFC that would return the file read of another CFC. There is no way to ask ColdFusion to return its own code (for security reasons, etc). Something like this would work:

<cfcomponent>
<cffunction name="getFileContents" access="remote">
  <cfargument name="fileToReturn">
  <cfreturn fileRead( arguments.fileToReturn )>
</cffunction>
</cfcomponent>

Thats pretty rough code but should get you going.

Sam Farmer
Or call a CFC that would return the file read of own source. One cfc less :)
Sergii