Copy link to clipboard
Copied
Greetings,
I am running flashbuilder 4.5 for php premium. I have created an application that read/writes to a postgresql database.
All is well.
Now for the unfun. When I created the service in flashbuilder, I gave it a UNC for the gateway.php file. Unfortuneately,
I don't know how to change the endpoint programmatically at run time.
My first thought was to use FlashVars in the html wrapper, then in my app in the Application creationComplete event handling code, I put
the following code:
var hostObj:Object = LoaderInfo(
this
.root.loaderInfo).parameters.myHost;
myService.endpoint = "http://" + hostObj.toString() + "/gateway.php";
that very much didn't work, and kinda screwed up my project. Had to undo the html wrapper edit, and the contentCreation code to get things
back in shape.
So, what is the correct way to programmatically set the endpoint?
Please note that the host file and dns will not solve my problem as many servers on a single network may be running my app.
thanks.
Copy link to clipboard
Copied
Ok. I have yet to get an answer to any of my posts on this forum.
I have figured out how to do this, so I will share what worked for me.
1. In the javascript section of the index.template.html in my html-template folder, added a
flashvar using the statement flashvars.myVar = "myhost". I placed it right after the var flashvars = {}; statement.
myHost is the hostname of my server and myVar is the flashvariable name I reference in my AS code.
2. in the Application creationComplete event handler, I added the following code:
for (var i:String in FlexGlobals.topLevelApplication.parameters) {
if (i == "myVar") {
tstring = FlexGlobals.topLevelApplication.parameters;
}
}
myService.endpoint = "http://" + tstring + "/gateway.php";
*Note: If you don't use code assist to add theFlexGlobals, remember to add an import statement for FlexGlobals;
3. Do a Project Clean to get rid of old bin-debug.
4. Should work now.
This allows me to edit the html wrapper file on the release-build to refelect a different hostname. This is necessary for me as I might
have multiple servers on the same network running my code.
Hope someone other than me finds this useful.