本文介绍了如何使用JavaScript访问的ActionScript在Adobe AIR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用HTML编写的AIR应用程序/ JavaScript的,我想使用ActionScript打印功能,但我在的ActionScript AIR没有经验。

I have an AIR application written in html/javascript and I want to use the Actionscript print functions but I have no experience in Actionscript for AIR.

我在哪里可以把动作脚本code?是否进入MXML文件还是需要编译成一个Flash应用程序。我在哪里可以把它和我怎么它列入到HTML文件?最后,我该如何从JavaScript调用的AS功能?

Where do I put the Actionscript code ? Does it go into an mxml file or does it need to be compiled into a Flash application. Where do I put it and how do I include it into the html document ? Finally, how do I call the AS function from Javascript ?

=====更新=====

我知道我必须编译要么是的.mxml或文件。截至到.swf文件使用mxmlc的,我有我的。至于文件中的以下内容:

I know I have to compile either an .mxml or .as file into .swf using mxmlc and I have the following in my .as file:

package {
    import mx.controls.Alert;
    public class HelloWorld {
        public function HelloWorld():void {
            trace("Hello, world!");
        }
    }
}

或者交替,这一个的.mxml文件:

Or alternately, this in a .mxml file:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
       import mx.controls.Alert;

           public function HelloWorld():void {
               Alert.show("hello world!");
               trace("Hello, world!");
           }
        ]]>
    </mx:Script>
</mx:Application>

这编译正常,但是当我在一个HTML文件,它包含:

This compiles OK, but when I include it in a html file with:

<script src="actionscript.swf" type="application/x-shockwave-flash"></script>

我收到以下错误:

I get the following error:

类型错误:错误#1009:无法访问空对象引用的属性或方法。    在mx.managers ::的FocusManager /激活()    在mx.managers ::的SystemManager / activateForm()    在mx.managers ::的SystemManager /激活()    在mx.core ::应用/ initManagers()    在mx.core ::应用/初始化()    在动作/初始化()    在mx.managers ::的SystemManager / http://www.adobe.com/ 2006 /柔性/ MX /内部:: childAdded ()    在mx.managers ::的SystemManager / initializeTopLevelWindow()    在mx.managers ::的SystemManager / http://www.adobe.com/ 2006 /柔性/ MX /内部:: docFrameHandler ()    在mx.managers ::的SystemManager / docFrameListener()

TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.managers::FocusManager/activate() at mx.managers::SystemManager/activateForm() at mx.managers::SystemManager/activate() at mx.core::Application/initManagers() at mx.core::Application/initialize() at actionscript/initialize() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::childAdded() at mx.managers::SystemManager/initializeTopLevelWindow() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler() at mx.managers::SystemManager/docFrameListener()

任何想法,这是什么意思?

Any ideas what that means ?

推荐答案

有这个文件在这里找到:http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7ed9.html

There's documentation on this found at: http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7ed9.html

请确保您编译与acompc:

Make sure you compile with acompc:

注:编译的ActionScript SWF  库使用作为HTML的一部分  在AIR页,使用acompc编译器

和也......因为你使用了​​Alert类...这取决于Flex框架。确保当您编译SWF。编译整个框架。 (即确保 -static链接,运行时共享库​​=真

And also... since you're using the Alert class... it depends on the Flex Framework. Make sure when you compile the swf. You compile in the whole framework. (i.e. make sure -static-link-runtime-shared-libraries=true)

这篇关于如何使用JavaScript访问的ActionScript在Adobe AIR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 12:54