到目前为止,我已经完全被这个难住了,我已经做了几天了,我关注的大多数链接和我所做的搜索都让我一无所获。
我想做一个简单的游戏,带有鼠标界面,但我也想添加一个预加载器。我最初使用的是 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:此外,可能值得一提的是,它目前的方式仍然设法在加载后抛出警报。