2013-03-27 49 views
2

我试图把一个AS3“拖放”游戏放在captivate 6的幻灯片中。独立的瑞士法郎工作正常,但一旦它被导入将其全部内容重新包装到另一个swf中,从而失去导入的游戏包。AS3“导入包”不工作 - 拖放游戏迷住

在Flash主时间轴我有行动

import com.test.games.*; 

var dragArray:Array = [comment1, comment2, comment3, comment4, comment5, comment6, comment7, comment8 ]; 
var matchArray:Array = [leftMatch, leftMatch, rightMatch, rightMatch, rightMatch, leftMatch, rightMatch, leftMatch ]; 
var posArray:Array = [ {x:154, y:362}, {x:154, y:316}, {x:641, y:362}, {x:641, y:316}, {x:641, y:270}, {x:154, y:270}, {x:641, y:224}, {x:154, y:224} ]; 

var dragGame:DragGame = new DragGame(stage, dragArray, matchArray, posArray); 

dragGame.addEventListener(DragGame.MATCH_MADE, onMatch); 
dragGame.addEventListener(DragGame.NO_MATCH, onFlub); 
dragGame.addEventListener(DragGame.ALL_DONE, onDone); 

function onMatch(event:Event):void { 
    var matchSound:Sound = new MatchSound(); 
    matchSound.play(); 
} 
function onFlub(event:Event):void { 
    var flubSound:Sound = new FlubSound(); 
    flubSound.play(); 
} 
function onDone(event:Event):void { 
    var applause:Sound = new Applause(); 
    applause.play(); 
} 

但我认为是什么原因造成的问题是,重新包装时,从

import com.test.games.*; 

的4个文件丢失在迷人的瑞士法郎,如果这是有道理的?

我是否需要定位根目录或其他东西才能工作,或者是否有一种方法可以使用主时间线嵌套所有文件的包。

(游戏是免费的东西我已经找到了 - 所以我不majorly自信AS3作为一种语言请温柔)

回答

1

我希望它是因为stage值可以为空当您导入到Captivate的这。用这个覆盖:

var dragGame:DragGame; // uninitialized! 
if (stage) init() else addEventListener(Event.ADDED_TO_STAGE,init); 
function init(e:Event=null):void { 
    removeEventListener(Event.ADDED_TO_STAGE,init); 
    // here we have stage available, let's make a game 
    dragGame = new DragGame(stage, dragArray, matchArray, posArray); 
    dragGame.addEventListener(DragGame.MATCH_MADE, onMatch); 
    dragGame.addEventListener(DragGame.NO_MATCH, onFlub); 
    dragGame.addEventListener(DragGame.ALL_DONE, onDone); 
} 
+0

谢谢,我试过改变这个,但它打破了它作为一个独立的版本,不幸的是不能在Captivate工作。我认为这与“import com.test.games。*;”有关打破作为evertyhing其他作品,我甚至可以拖动元素在迷人的答案是在参考AS3包文件 – Randy4 2013-03-27 10:31:19

+0

哎呀。查看编辑的代码。我忘记了这个舞台出现在一个案例中。 – Vesper 2013-03-27 10:36:55

+0

我不认为导入可以完全中断,导入是针对编译器,而不是针对运行时。 – Vesper 2013-03-27 10:37:50