0

我从来没有遇到过 Htmlloader 的页面历史记录的问题,它是主 Native Window 阶段的子级。我只需要使用:HtmlLoaderVariable.historyForward();

但是当我将 HTMLLoader 作为孩子添加到新的本机窗口时,它似乎不起作用。

这是代码:

function createNewHtmlWindow(pageUrl:String):void{
    //Everytime I click a button, this function creates a seperate Native Window each containing HtmlLoader Class to load a webpage

    var myhtml= new HTMLLoader();
    myhtml.width = 1000;
    myhtml.height = 780;    
    myhtml.addEventListener(Event.COMPLETE, myHtmlLoaded);


    var myHtmloptions = new NativeWindowInitOptions();
    myHtmloptions.transparent = false;
    myHtmloptions.systemChrome = NativeWindowSystemChrome.STANDARD;
    myHtmloptions.type = NativeWindowType.NORMAL;   

    var extHtmlWindow = new NativeWindow(myHtmloptions);    
    extHtmlWindow.title="new title";
    extHtmlWindow.width = 1015;
    extHtmlWindow.height = 800; 

    extHtmlWindow.activate();
    extHtmlWindow.stage.align = "TL";
    extHtmlWindow.stage.scaleMode = "noScale"; 
    extHtmlWindow.stage.addChild(myhtml);

    var backNativeWin=new BackButton();
    backNativeWin.x=5;
    backNativeWin.y=500;
    backNativeWin.addEventListener(MouseEvent.CLICK, loadPrevHistory);
    extHtmlWindow.stage.addChild(backNativeWin);

    var nextNativeWin=new NextButton();
    nextNativeWin.x=30;
    nextNativeWin.y=500;    
    nextNativeWin.addEventListener(MouseEvent.CLICK, loadNextHistory);
    extHtmlWindow.stage.addChild(nextNativeWin);

    myhtml.load(new URLRequest(pageUrl));
}

function myHtmlLoaded(e:Event):void
{
    //Page loads successfully

}


function loadNextHistory(m:MouseEvent):void{
    output.text="Next>>"+m.target.parent.getChildAt(0); //Next>>[object HTMLLoader] 
    m.target.parent.getChildAt(0).historyForward(); // This line is not working


}

function loadPrevHistory(m:MouseEvent):void{
    output.text="Prev>>"+m.target.parent.getChildAt(0); //Prev>>[object HTMLLoader]
    m.target.parent.getChildAt(0).historyBack(); // This line is not working

}   
4

1 回答 1

1

我已经用我自己的网页尝试了你的代码,效果很好。这是我的代码:

import flash.html.HTMLLoader;
import org.aswing.JButton;
import flash.filesystem.File;

function createNewHtmlWindow(pageUrl:String):void{
//Everytime I click a button, this function creates a seperate Native Window each containing HtmlLoader Class to load a webpage

var myhtml= new HTMLLoader();
myhtml.width = 1000;
myhtml.height = 680;    
myhtml.addEventListener(Event.COMPLETE, myHtmlLoaded);


var myHtmloptions = new NativeWindowInitOptions();
myHtmloptions.transparent = false;
myHtmloptions.systemChrome = NativeWindowSystemChrome.STANDARD;
myHtmloptions.type = NativeWindowType.NORMAL;   

var extHtmlWindow = new NativeWindow(myHtmloptions);    
extHtmlWindow.title="new title";
extHtmlWindow.width = 1015;
extHtmlWindow.height = 700; 

extHtmlWindow.activate();
extHtmlWindow.stage.align = "TL";
extHtmlWindow.stage.scaleMode = "noScale"; 
extHtmlWindow.stage.addChild(myhtml);

var backNativeWin:JButton=new JButton("back");
backNativeWin.setSizeWH(100,22);
backNativeWin.x=5;
backNativeWin.y=500;
backNativeWin.addEventListener(MouseEvent.CLICK, loadPrevHistory);
extHtmlWindow.stage.addChild(backNativeWin);

var nextNativeWin=new JButton("next");
nextNativeWin.setSizeWH(100,22);
nextNativeWin.x=130;
nextNativeWin.y=500;    
nextNativeWin.addEventListener(MouseEvent.CLICK, loadNextHistory);
extHtmlWindow.stage.addChild(nextNativeWin);

myhtml.load(new URLRequest(pageUrl));
}

function myHtmlLoaded(e:Event):void{
//Page loads successfully
}


function loadNextHistory(m:MouseEvent):void{
trace("Next>>"+m.target.parent.getChildAt(0)); //Next>>[object HTMLLoader] 
m.target.parent.getChildAt(0).historyForward(); // This line is not working
}

function loadPrevHistory(m:MouseEvent):void{
trace("Prev>>"+m.target.parent.getChildAt(0)); //Prev>>[object HTMLLoader]
m.target.parent.getChildAt(0).historyBack(); // This line is not working

}
createNewHtmlWindow(File.desktopDirectory.resolvePath("index.html").url);

这是我桌面上的 index.html:

<html>
<head>
    <title>This is a test page</title>
</head>
<body>
    <a href="http://www.google.com">Click me to jump to Google.</a>
</body>

所以我认为你的测试网站一定有问题,换另一个重试可能会有所帮助..

于 2013-08-09T02:04:02.803 回答