2013-04-05 220 views
0

我希望有人可以幫我解決一個問題,我試圖將我創建的謎題集成到我的遊戲FLA文件中。AS3 OOP繼承和功能

在Game.fla中,我有一個名爲Engine的主類,它包含從庫中調用一些空的影片剪輯到舞臺,然後使用庫中的資源填充每個影片剪輯。每個影片剪輯都有自己的類與它關聯。

我已經創建每個拼圖在一個單獨的文件與自己的主類來測試並確保拼圖的工作,當我嘗試添加一個拼圖的代碼到一個動畫片類我得到一些錯誤

輸出錯誤

**Warning** The linkage identifier 'feedback2' was already 
    assigned to the symbol 'wrong_box', and cannot be assigned 
    to the symbol 'graphics/scrambleAssets/wrong_box', 
    since linkage identifiers must be unique. 

和編譯器錯誤

    Line 132 1136: Incorrect number of arguments. Expected 1. 

線132是這樣的:

if(ques_num==words.length){removeChild(checker); 
    f3=new feedback3; 
    addChild(f3); 
    f3.x=100; 
    f3.y=100; 
    }else{ 
    getword();} 

主類

 public function show_level1Puzzle(){ 

     level1Puzzle_screen = new level1Puzzle(this); 
     remove_levelChooseBoy(); 

     addChild(levelPuzzleBoy_screen); 
     level1Puzzle_screen.x=510; 
     level1Puzzle_screen.y=380; 
    } 

**類爲level1Puzzle **

package actions { 

import flash.display.MovieClip; 

public class level1Puzzle extends MovieClip { 
        public var main_class:Engine; 

        // variables used in puzzle 
        var words:Array = new Array; 
     Var rand1:int;var rand2:int; 
     var i:int; //variable used for loop iterations 
     // more variables 

    public function level1Puzzle(passed_class:Engine) { 
        main_class = passed_class; 

    public function getword(passed_class:Engine) { 
     main_class = passed_class; 
     words=["cat","dog"]; 
     current_word=words[ques_num]; 
     setTiles(current_word.length); 
     ques_num++; 
    } 
    public function setTiles(a) {tileArray=[ ]; 
     for(i=0;i<a;i++){ 
      var tempclip:Tile =new Tile;addChild(tempclip); 
       tempclip.x=300+(i*180);tempclip.y=200;tempclip.tag=i; 
      tempclip.original_posx=tempclip.x; 
      tempclip.original_posy=tempclip.y; 
      tileArray[i]=tempclip; 

      var tempclip2:Placeholder =new Placeholder;addChild(tempclip2); 
      tempclip2.x=300+(i*180);tempclip2.y=400; 
      targetArray[i]=tempclip2; 

     }//for i 
     scramble_word(a); 
    } 

//多爲拼圖

函數

回答

2

這個函數有一個參數:

public function getword(passed_class:Engine) { 
     main_class = passed_class; 
     words=["cat","dog"]; 
     current_word=words[ques_num]; 
     setTiles(current_word.length); 
     ques_num++; 
    } 

上線132,你是不是傳遞一個參數,這樣是錯誤消息的原因。

+0

正確的,我應該更好地說明了參數「checker」涉及到一個按鈕,我已經在引擎類中聲明它 var checker = new button_chk; leve1Puzzle_screen.addChildAt(checker,1); 但它拋出未定義的屬性錯誤...如果我在level1 Puzzle類中聲明它,我得到相同的未定義的屬性錯誤 – daveQuinn 2013-04-05 23:12:42

+0

行132 1136:不正確的參數數量。預期1 - 我回答的是固定的。這是一個問題和答案論壇,它不是由問題論壇調試您的代碼問題。如果出現新問題,請就這一特定問題開始一個新問題。 – prototypical 2013-04-06 01:04:59