3

is there any solution on StageWebView.loadURL(), how I can handle URLs in HTML Pages which have target="_blank"?

It's a mobile Android App. (TabbedViewApplication)

Hope someone can help.

Thx

neknova
  • 57
  • 1
  • 5

5 Answers5

1

One option is StageWebViewBridge.

StageWebViewBridge is an extended version of flash.media.StageWebView.

  • Extends loadString method with AS3 - JS communication.
-Extends Bitmap class, you can modify his x,y,alpha,rotation,visible, etc ( Version 1 Beta )
-Communicates Actionscript with Javascript.
-Communicates Javascript with Actionscript.
-Load local files and resources in a easy way.
-Extends loadString method with AS3 - JS communication.
-Extends loadString method to load local resources.
-Lets you take an SnapShot to use as the bitmapData of the bitmap.

StageWebViewBridge source: https://code.google.com/p/stagewebviewbridge/

Nicolai
  • 11
  • 2
  • another option is to use a php proxy and change target = "_blank" to "_parent". change relative paths to absolute paths in dynamic content – Nicolai Jan 24 '14 at 03:34
0

I never worked with the StageWebView but I know it's really limited. When using an HTMLLoader, you can set a custom HTMLHost instance that specifies to use current HTMLLoader when opening to _blank. However, I don't think it's possible with StageWebView.

public class MyHTMLHost extends HTMLHost
{   
    public function MyHTMLHost(defaultBehaviors:Boolean=false)
    {
        super(defaultBehaviors);
    }

    override public function createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader
    {
        // all JS calls and HREFs to open a new window should use the existing window
        return htmlLoader;
    }
}
Exort
  • 1,075
  • 5
  • 13
0

OK, so the only solution for this problem i could found is to load the page (containing the links) as String with the URLLoader and replace its specified parts. Finally loading it via StageWebView.loadString() method.

Problems occur when the Site is dynamic and contains JavaScript. I had also replace some relative links with absolute pathes.

That's it... but I really hope that adobe makes it possible to load those "_blank" links with the StageWebView.loadURL() method.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
neknova
  • 57
  • 1
  • 5
0

If you want to capture when a user clicks on a link inside your StageWebView add an an event listener for location changing event (LocationChangeEvent).

This LocationChangeEvent will include the URL they are going to and target. Then you can prevent the URL from loading, let it continue (by doing nothing) or handle it any other way including loading another URL.

If you want to load another URL first stop the loading with stageWebView.stop(). You should also call event.preventDefault(). You can then attempt to

Note: There is another event called locationChange that may be helpful.

1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
  • LocationChangeEvent.LOCATION_CHANGING if fired before the location is set to the StageWebView so it's a lot better. You may need to set -swf-version=12 in your compiler option or else the event won't fire. – Exort Jan 25 '12 at 16:05
  • Thanks. I'm using Flex SDK 4.6 for Android App Development. I already listening to LOCATION_CHANGING Event, but it doesn't fire up on link with target='_blank'. That's the buggy point what I mean :) – neknova Jan 25 '12 at 19:09
0

As it was declared as an official bug, adobe QA Owner Sanjay C. added a comment: "Able to reproduce the issue with the attached project. Sending to IRB."

So, hope the next Build will come up with the fix wit it.

Best regards

neknova
  • 57
  • 1
  • 5