Flex 4.6, AIR 3.5, desktop app, navigateToURL, _self - apache-flex

I have a desktop AIR app built with Flex 4.6 and Air 3.5. I use navigateToURL to launch a URL in the default browser, works fine:
var request : URLRequest = new URLRequest ( "http://localhost:8890/test.html" );
var urlVariables : URLVariables = new URLVariables ();
urlVariables['activity'] = "xyz.json";
request.data = urlVariables;
request.method = URLRequestMethod.GET;
navigateToURL(request, "_self");
The app lets the user construct some JSON content (xyz.json), then test it in a test rig (test.html).
The second and subsequent times I do this, I get a new tab (I'm using Chrome). What I want is for it to appear in the same tab as the last one. Note that I've used "_self". If I pass any string I get the same result.
Any help would be appreciated. Thanks.

I dont believe it is possible to force browser to reuse same tab - that would be browser behaviour, not AIR behaviour (ie: you would change the expected behaviour in browser settings; eg: always open content in new tab).

I believe from a desktop app when you invoke NavigateToURL() it will force a new window (container) to launch.
If you can you could create a separate 'receiver' page on the server to receive the data (invisible to the user) Then launch a 'viewer' page with NavigateToURL that would contain an ajax script to check and update the data received from the 'receiver' page.
I would check out URLLoader() Class. I use this many times for my web service scripts.

Related

Using WebBrowser in ASP.Net Web Application

I am trying to use a WebBrowser in a .cs class in a Web Application - NOT A WINDOWS FORM app using (VS 2019).
I know it's a Windows Form app control, but it seems like I should be able to use it in a Web App.
Using WebBrowser in Web App does not have the .Url property, so I just use the .Navigate directly - this is where the code breaks.
I have tried many suggestions on the Net, but nothing seems to work - it looks like most of the examples uses a Web Page - I want to use the WebBrowser directly in code (.cs class).
private static void LoginViaUserAgentFlow()
{
Thread thread = new Thread(delegate ()
{
StringBuilder sb = new StringBuilder(String.Format("{0}/services/oauth2/authorize",
RHOutlook.chosenInstance.sfdcURL));
sb.Append("?response_type=token");
sb.Append(String.Format("&client_id={0}", RHOutlook.chosenInstance.clientId));
sb.Append(String.Format("&redirect_uri={0}", System.Web.HttpUtility.UrlEncode(RHOutlook.chosenInstance.redirectUri)));
WebBrowser webBrowserSFDCLogin = new WebBrowser();
//Here I can't use the .Url becaue it is not available - so I just use
//Navigate to get to the site
webBrowserSFDCLogin.Url = new Uri(sb.ToString());
//This is were it breaks, comes back with error when I navigate to the site.
webBrowserSFDCLogin.Navigate(sb.ToString());
//This code is never reached - failed at above code.
if (webBrowserSFDCLogin.LocationURL != null && webBrowserSFDCLogin.LocationURL.StartsWith(RHOutlook.chosenInstance.redirectUri))
{
//webBrowserSFDCLogin.ScriptErrorsSuppressed = true;
webBrowserSFDCLogin.Stop();
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
I expect to be able to navigate to the external website. If I can navigate to the site if I copy the url directly in a browser (say Chrome).
I tried using ; this gives me the Url property, but still get the error.
You really should stick to suggestions and examples.
What you are trying to do is to use class that is designed for Windows Application inside a Web Application.
Those two frameworks are similar like Earth and Mars. I am afraid you are not going to be able to grow a tree on Mars.

Query parameters order in AngularJS URL accessed from Flex

I have a web application written in AngularJS (version 1.0.8).
I'm using UI-Router (0.4.) to handle the state of that app.
I try to access the URL of the app from another Flex app (4.0).
In the Angular app, I have the URL:
http://localhost:8080/myApp/somePage?param01=aaa&param02=bbb
In Angular's module.config() of that app, I do something of this sort:
$stateProvider.state("somePage", {
url: "/somePage?param01&param02"
templateUrl: "view/somePage.html"
controller: "SomePageController"
});
Now in the Flex application, I have the following code:
var variables:URLVariables = new URLVariables();
variables.param01 = "aaa";
variables.param02 = "bbb";
var url = new URLRequest();
url.data = variables;
navigateToURL(url, "_self");
The problem is that when I press the button in the Flex app that navigates to the Angular app, I get this URL:
http://localhost:8080/myApp/somePage?param02=bbb&param01=aaa
In the URL's query parameters, param02 comes before param01.
Then, in Angular's ui-router, I guess, it is changed to the regular URL:
http://localhost:8080/myApp/somePage?param01=aaa&param02=bbb
My problem with this is with the browser navigation - when the user will click 'back', the browser won't navigate back to the URL of the Flex app, because there's another URL in history, where the query parameters were switched. The user will have to click 'back' twice...
Moreover, though this is an elaboration that's not necessary for the problem, so you can skip it if you'd like, the user can access that Angular app from more than 1 place (i.e. not only from the Flex app). When the user click 'Save' or 'Cancel' in the Angular app, it should be redirected to the originating page. I planned on doing it using the history.back() feature, but it's problematic due to the aforementioned phenomenon, of the URL with the query parameters switched.
Many thanks in advance,
Daniel
I solved my own problem, currently by changing the way I work with navigateToURL in Flex.
I now have something of this sort:
var queryParams:String = "param01=aaa&param02=bbb";
url.url += "?" + queryParams;
navigateToURL(url, "_self");
This way, when I use a string built by me, instead of the URLVariables class, I can control the order of the URL query params.
Unfortunately, I still don't know why the URL query params are ordered differently every time I use the function, when I do use the URLVariables class...

Launching a webpage in browser from an Adobe Air app not working

I've got a webpage I want to hook in to my Adobe Air app. It's running JavaScript, so I can't open it in the app, but I'm trying to launch it in the default system browser.
Here's the code that's supposed to be launching the page:
public function beginModule():void {
var loader:HTMLLoader = new HTMLLoader();
var gameURL:URLRequest = new URLRequest("file:///path/to/file.html");
loader.navigateInSystemBrowser = true;
loader.load(gameURL);
}
I've also tried using
flash.net.navigateToURL(gameURL);
but that had no effect.
Every time I hit the above method, that block executes but nothing happens other than a quick cursor change-- no browser opened, no change in the app. What am I missing here?
Before you start, check if the HTML page is properly running in the browser.
To open a HTML page in flex, use the HTML tag: <mx:HTML></mx:HTML>
Something like this: https://snipt.net/anishnair/flex-show-html-page/?key=28838d54ac287180032dee000ce33a74
Thank you.
Regards,
Anish
Simply use :
navigateToURL(url,"_blank");
to navigate to the url in the web-browser.

stoping flash file from running more than one time

I am working with a flash-template to create a website. I have a master page with a flash header and flash menu. when my home pages runs the flash header runs. the flash file should just run once but it is running each time I click on the menu items. I tried to use updatepanel, but i didn't know how to set the updatemode since my menu is working with flash. any idea of what i should use???
Store some data in the client that says they've viewed the flash before. When you execute your flash file, check for the existence of this data, and react accordingly. You may want to peak at http://www.flash-db.com/Tutorials/saving/ on how to save data.
You could use local storage, as shown here :
Write it as :
import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
so.data.isUsed= "true";
so.flush(); // writes changes to disk
Read it as :
import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
var isUsed = so.data.isUsed;
If it's a website page you may also use ExternalInterface.addCallback to add a function which can be called from javascript.

How to run one application from another application in flex?

I have two flex applications Main.mxml(where I have a button called loadDataViewer) and ViewData.mxml. What I want is when the user press the loadDataViewer button, the application ViewData.mxml will open in a new window. Is there any way to do it in Flex?
SWFLoader class looks interesting but I think it will load the other appliation inside the Main application which I don't want. I also saw that there is ExternalInterfaceAPI which can be used to open a url browser but not sure if I can reference the swf file of VewData application. As suggested here( http://learn.adobe.com/wiki/display/Flex/Local+Connections ) that LocalCOnnection can be used to reference one flex application in another but that's only when both applications are open I guess.
Any suggestion to guide me to the right direction wouild be greatly appreciated.
You could embed your viewData swf to an HTML file, and either do any of the following:
Call External Interface...
var url:String = 'myViewData.html';
ExternalInterface.call('window.open("' + url + '")');
or
Call the navigateToURL method...
var url:String = 'myViewData.html';
var urlReq = new URLRequest(url);
navigateToURL(urlReq,'_blank');
Use Modules. Adobe help.

Resources