【发布时间】:2013-09-02 19:33:45
【问题描述】:
到目前为止,我完全被这件事难住了,我已经做了几天了,我关注的大多数链接和我所做的搜索都让我一无所获。
我想制作一个简单的游戏,带有鼠标界面,但我也想添加一个预加载器。我最初使用的是 minibuilder,因为它是跨平台的,而且我在 Linux 上,但是我看到的所有添加预加载器的教程似乎都与它不兼容。
因此,我转而直接使用 Flex 编译器和文本编辑器,但运气不佳,甚至预加载器(这似乎是唯一有效的想法)也只是从偶然发现的教程。
理想情况下,我只想使用 MXML 文件指向预加载器 - 为预加载器提供一个 CustomPreloader.as 文件 - 并启动 Actionscript 类,可能使用 FlashPunk 以及我的代码帮助。
这是到目前为止的代码,除了 CustomPreloader.as 之外的每个文件,因为预加载器已经在工作:(注意:所有文件都在 ~/ASClasses/src )
File: ASClasses.mxml
--------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#333333"
creationComplete="init();"
width="800" height="500"
frameRate="60"
preloader="CustomPreloader"
>
<mx:Script>
<![CDATA[
//This part is mostly for testing purposes
//========================================
import mx.controls.Alert;
public function init():void {
Alert.show("The first function works.");
}
//And this is what I actually wanted to do
//========================================
import Application;
//Whenever I uncomment the following line, some error is thrown and the init function stops working at all.
//public var myApp:Application = new Application;
//addChild(myApp);
]]>
</mx:Script>
</mx:Application>
File: Application.as
--------------------
package{
import flash.display.Shape;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.display.Sprite;
public class Application extends Sprite{
public function Application(){
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.frameRate = 60;
rotationX = -45;
var s:Shape = new Shape;
s.x = 400;
s.y = 200;
s.rotation = 90;
addChild(s);
}
addEventListener('enterFrame', function(e:Event):void{
s.rotation += 2.5;
} );
}
}
但是,取消注释添加 Application.as 所需的行似乎只会引发错误,所以我认为我要么遗漏了一些代码,要么我做了一些事情错了。
请问有没有人可以教我更多这方面的知识?虽然我想说我对 Actionscript 有一些经验,但在这一点上,我已经非常强调自己无法做到这一点,如果不是的话,我宁愿这样做问的太多了,用简单的方式解释,假设我没有以前的知识。
此外,如果有任何完整的简单教程可以用这种方式制作简单/简单的游戏/演示,我也会很感激,因为到目前为止我看到的大多数教程只记录了 Flex 和 Actionscript,并且在我真正设法做任何事情之前很容易变得复杂。
提前致谢。
编辑 1:另外,可能值得一提的是,它目前的方式仍然设法在加载后抛出警报。
【问题讨论】:
标签: actionscript-3 flash apache-flex actionscript mxml