简体   繁体   English

我可以使用AS3在Flash文件中使用其他语言吗?

[英]Can I use other languages in a Flash file using AS3?

I want to create my own systems for flash (like a scoreboard and made a feedback system) but I honestly have no clue where to even begin when it comes to implementing such things using AS3. 我想为Flash创建自己的系统(例如记分板和反馈系统),但老实说,我不知道从AS3实现这类事情的起点。

I know how to create say a scoreboard using PHP but then I have no clue at ALL how I would get that into my game using AS3. 我知道如何使用PHP创建记分板,但是我完全不知道如何使用AS3将其纳入我的游戏。

Any help/tutorials would be great, Thanks! 任何帮助/教程都很好,谢谢!

You can use the HTTPService component with an Adobe Flex program (the language is based on ActionScript3 and is a mix of MXML for the User Interface and ActionScript3), and receive a response from your PHP script in a specific format (ie: XML, plain String, etc), which you can process with AS3 and use to update your Flash application. 您可以将HTTPService组件与Adobe Flex程序一起使用(该语言基于ActionScript3,并且是用户界面和ActionScript3的MXML的混合体),并以特定格式(例如XML,纯XML)接收来自PHP脚本的响应字符串等),您可以使用AS3处理该字符串,并用于更新Flash应用程序。 I mentioned XML because AS3 supports the e4x format for HTTPService, and it becomes really easy to manipulate XML data with AS3. 我之所以提到XML是因为AS3支持HTTPService的e4x格式,并且使用AS3操作XML数据变得非常容易。

The Adobe Flex Developer QuickStart has everything you need to get started with Adobe Flex (I went through that route), and there are countless other tutorials online (a Google search for a specific tutorial subject would turn up some results). Adobe Flex Developer快速入门提供了开始使用Adobe Flex所需的一切(我遵循了这条路线),并且在线上还有其他教程(通过Google搜索特定的教程主题会得出一些结果)。 Another resource worth checking out is the Flex section on Switchonthecode . 另一个值得检查的资源是SwitchonthecodeFlex部分

An article geared towards what you want can be found on the Loading External data with HTTPService page of the QuickStart guide mentioned above. 可以在上面提到的快速入门指南的“ 使用HTTPService加载外部数据”页面上找到适合您所需内容的文章。

Additionally, the Flex Getting Started tutorial articles on Adobe's wiki platform may be of use, as they offer a lot of examples of the language's useful features. 此外,在Adobe Wiki平台上的Flex入门教程文章可能会有用,因为它们提供了该语言有用功能的许多示例。 An article from the wiki on External Interfaces actually explains how to make your Flex Application talk to a JavaScript on the HTML page, which might be useful for you also. Wiki上有关外部接口的文章实际上解释了如何使Flex应用程序与HTML页面上的JavaScript对话,这可能对您也很有用。

Hope this helps, 希望这可以帮助,

If you want to get really technical, it doesn't really matter as long as you compile your code into ABC bytecode which is basicly as low level as it gets before Flash compiles/interprets the code. 如果您想真正地掌握技术,那么只要将代码编译为ABC字节码就没什么大不了了,而ABC字节码基本上与Flash编译/解释代码之前的代码一样低。 In theory, this would mean that you could write a compiler for most any language. 从理论上讲,这意味着您可以为大多数任何语言编写编译器。

However, I'm guessing you're asking for something that's more readily available. 但是,我猜您正在要求更容易获得的东西。 In that case, ActionScript is your friend. 在这种情况下,ActionScript是您的朋友。 There is no reason to go with AS2 as it is for all intents and purposes a dead end. 没有理由使用AS2,因为出于所有目的和目的,AS2都是死胡同。 The player falls back to AVM1 for AS2 code which is much slower than AVM2 which runs AS3 code. 播放器退回到AS2代码的AVM1,这比运行AS3代码的AVM2慢得多。 AS2 also is a much looser language than AS3. AS2也比AS3宽松得多。 Sometimes that's a good thing, but generally it's like running barefoot across a field of glass. 有时候这是一件好事,但总的来说,就像赤脚越过一块玻璃。

You could have a look at Flex, which combines MXML and AS3. 您可以看看Flex,它结合了MXML和AS3。 MXML is a markup language for declaratively defining components (visual and non-visual). MXML是用于以声明方式定义组件(可视和非可视)的标记语言。 While MXML is a markup language, it is not similar to HTML at all. 尽管MXML是一种标记语言,但它根本不类似于HTML。 However, it does help knowing HTML (or any other markup language, such as XML) when faring into the world of MXML. 但是,当深入到MXML领域时,它确实有助于了解HTML(或其他任何标记语言,例如XML)。 The Flex compiler interprets the MXML code and generates AS3-classes which are subsequently compiled into bytecode. Flex编译器解释MXML代码并生成AS3-类,随后将其编译为字节码。

Just as raptors tell above, you can also perform regular http calls. 就像猛禽在上面说的那样,您还可以执行常规的http调用。 While this is most certainly useful, it's not something I suggest for logic that really do belong client side. 尽管这当然是最有用的,但对于真正属于客户端的逻辑,我不建议这样做。

Maybe Flex would be a good option for you. 也许Flex将是您的一个不错的选择。 You could try using AS2 which has a lot more in common with JavaScript than anything else. 您可以尝试使用AS2,它与JavaScript有很多共同点。 AS2 is a much more forgiving environment too from a syntax/coding style perspective and might be more inviting to a PHP programmer. 从语法/编码样式的角度来看,AS2也是一个更宽容的环境,并且可能更吸引PHP程序员。

您应该研究AMFPHP ,它是Flex Data Services的替代产品,它使ActionScript-PHP集成更加容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM