我正在使用 FLASH CS5.5 为 android 和 IOS 创建应用程序
当我点击按钮时,我想打开 pdf 文件。我尝试使用此代码但不工作
package
{
import flash.html.HTMLLoader;
import flash.net.URLRequest;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowType;
import flash.display.NativeWindow;
import flash.events.Event;
import flash.display.SimpleButton;
public class bpdf extends SimpleButton
{
public function bpdf()
{
// constructor code
var htm:HTMLLoader= new HTMLLoader();
htm.load(new URLRequest("test.pdf"));
var init:NativeWindowInitOptions= new NativeWindowInitOptions();
init.systemChrome = NativeWindowSystemChrome.STANDARD;
init.type = NativeWindowType.NORMAL;
var win:NativeWindow = new NativeWindow(init);
win.stage.addChild(htm);
win.width = stage.stageWidth;
win.height = stage.stageHeight;
win.activate();
htm.width = win.width;
htm.height = win.height;
win.addEventListener(Event.CLOSE, onCloseEvent);
}
function onCloseEvent(e:Event)
{
trace("window closed");
}
}
}
使用“PLYER:AIR FOR ANDROID”发布后,我在输出中收到这些错误消息
[SWF] link2.swf - 2907 bytes after decompression
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at bpdf()[C:\Users\HP\Desktop\PDF Link\Link_2\bpdf.as:30]
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
我还将我的文件转换为 APK 并签入我的 android 设备,但是当我单击按钮时出现同样的问题,没有发生任何事情
我制作我的 APK 文件不包含 pdf 和包含 pdf
使用这种方式包含我的 pdf 文件:: 发布设置 > 播放器:AIR FOR ANDROID – 设置 > 包含的文件:test.pdf