• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How to programmatically set the endpoint in a flashbuilder created app

New Here ,
Apr 02, 2013 Apr 02, 2013

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.

Views

887

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines