1つの.flaファイルにリンクされた2つのActionscriptファイルがあります。 Document.asファイルはキーボードコントロールとマウスコントロールをサポートしていますが、Reset.asはカードのリセットを制御すると考えられます(これはインタラクティブバースデーカードです)。これを「Reset.as」ファイルに追加しましたが、「リセット」ボタンを押すと何も起こりません。画像のどれも、離れて動かない!私はここで何か間違っていますか?すべてのファイルにインスタンス名が与えられています!Flash CS5でメディアファイルをリセットするActionscript 3?
ここに「Reset.as」コードがあります。
package src
{
import flash.events.*;
import flash.display.*;
public class Reset extends MovieClip
{
public function Reset()
{
mouse();
}
public function mouse()
{
reset.addEventListener(MouseEvent.CLICK, Reset1);
}
public function Reset1(e:MouseEvent) :void
{
aldo.x = -176.80;
aldo.y = 282;
aldoo.x = -322.80;
aldoo.y = 286;
reset.x = -401.75;
reset.y = 328.45;
firework1.x = 100.75;
firework1.y = 545.15;
firework.x = 457.55;
firework.y = 551;
instruction.x = 437.25;
instruction.y = 379;
fade2.x = 132.15;
fade2.y = 433.15
}
}
}
//and here's the 'Document.as' code;
package src
{
import flash.events.*;
import flash.display.*;
public class Document extends MovieClip
{
var speed:int = 20;
var fader:Number = 0.1
public function Document()
{
init();
}
public function init()
{
button1.addEventListener(MouseEvent.CLICK, onMouseClick);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
}
public function onMouseClick(e:MouseEvent) :void
{
//if cake is clicked, the y axis for instance "instruction", "firework1", "firework" changes
instruction.y = 500;
firework1.y = 100;
firework.y = 100;
//if cake is clicked, the y axis for instance "fade2" changes
fade2.y = 240;
}
public function onKeyDown(e:KeyboardEvent):void
{
//if the right key (arrow key) is pressed,
//the instances "aldo and "aldoo" move positively on the x axis by "5"
//the instance "fade2" (which is "Press and hold the right key") also fades out
//the longer the right arrow key is pressed
if (e.keyCode == 39 && alpha > 0 )
{
aldo.x += speed;
aldoo.x += speed;
reset.x += speed;
fade2.alpha -= fader;
}
//if the left key (arrow key) is pressed,
//the instances "aldo and "aldoo" move negatively on the x axis by "5"
if (e.keyCode == 37)
{
aldo.x -= speed;
aldoo.x -= speed;
reset.x -= speed;
}
}
}
}
.flaファイルと2つの.asファイルをリンクすることはできますか?もしそうなら、どうですか?私はあなたの設定に行きましたが、2つのドキュメントクラスを追加することはできません – Adzi
申し訳ありません。スタックオーバーフローの新機能質問に答える。あなたがそれを理解していないならば。 1つのドキュメントクラスのみを持つことができます。しかし、ドキュメントクラスファイル。 flash.events。*の読み込み方法と同じように、Resetクラスを読み込むことができます。 .flaの名前付きオブジェクトは、ドキュメントクラスからのみ参照できます(99%は確信しています)。したがって、Resetクラスの.flaオブジェクトを使用する場合は、関数の引数として渡すか、ドキュメントクラス。 – RBalm
私はフラッシュが大好きですが、いくつかの粘着物があります。私の最大のペット愛好家はAsynchonous Threadingモデルですが、私はそれについて不平を言う人は見つけられていないと奇妙に感じます。あなたはあなたが何らかのリソースを読み込んだときにあなたのプログラムフローのトラックを失います。もう一日、Flashの未来は酷いように見えるが、私の歯車を粉砕する必要はないと思う。 – RBalm