2012-03-19 34 views
-1

私はAS3でプログラムを書いています。正確な内容はここでは重要ではないようです。私は基本的に4つのクラス、4つのファイルに分割している。なぜなら、これらのファイルの1つを見つけることができず、なぜその理由が理解できないのかということです。私はそれを数回チェックして、先生にそれをチェックさせても、それでも何が間違っているのかは分かりません。他の誰かが似たような問題を抱えているのですか、あるいはこの問題を解決する方法を知っていますか?ファイルが見つかりませんAS3

EDIT: Line 37 1046:タイプが見つからないか、コンパイル時定数ではありませんでした:CustomTextField。 Line 37 1180:未定義のメソッドCustomTextFieldを呼び出します。 (2回)

package 
{ 
    // Import stuff 
    import flash.display.MovieClip; 
    import flash.text.TextField; 
    import flash.events.MouseEvent; 
    import flash.events.Event; 
    import flash.utils.*; 

public class CustomButton extends MovieClip 
{ 
    // Private variables: 

    private var animationsListAR_:Array = [];// Array for the animations. 
    private var textArea_:CustomTextField = new CustomTextField(); 
    private var curState_:int = 1;// The current state (1 = Normal, 2 = Pressed, 3 = Over). 
    private var active_:Boolean; 
    private var type_:String;// Multi choice, single choice, normal. 
    private var group_:int; 
    private var animated_:Boolean = false; 

    // Protected variables: 
    // Public variables: 

    // Constructor: 
    // This constructor sets up the event listeners and the button's properties. 
    public function CustomButton(animationAR:Array, buttonlabel:String = "Hello", animated:Boolean = false, active:Boolean = true, type:String = "free", group:int = 0) 
    { 
     this.gotoAndStop(curState_); 

     // Prevents the start of the animations. 

     // Deals with the text inside the button. 
     this.buttonMode = true; 
     active_ = active; 
     this.addChild(textArea_); 


     if (animated == true) 
     { 
      animated_ = true; 
      /* 
      animationsListAR_[0] = 1; 

      for (var i:int = 1; i < animationAR.length; i++) 
      { 
      animationsListAR_[i] = animationAR[i - 1]; 
      } 
      */ 
     } 

     // If active_ is true the game will add EventListeners to this object. 
     if (active_ == true) 
     { 
      this.addEventListener(MouseEvent.MOUSE_DOWN,mouseOverHandler); 
      this.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler); 
      this.addEventListener(MouseEvent.MOUSE_OUT,mouseOutHandler); 
     } 

     // Needed to monitor the active_ var. 
     this.addEventListener(Event.CHANGE, activeChangeHandler); 
    } 

    // This function swaps the active_ variable value and calls activeChangeHandler. 
    public function ActiveChange() 
    { 
     active_ = ! active_; 
     this.dispatchEvent(new Event(Event.CHANGE)); 
    } 

    public function mouseOverHandler(evt:MouseEvent) 
    { 
     if(evt.type == MouseEvent.MOUSE_DOWN) 
     { 
      curState_ = 2; 

      if (animated_ == true) 
      { 
       loopSegment((animationsListAR_[1] + 1), animationsListAR_[2]); 
      } 
      else 
      { 
       this.gotoAndStop(curState_); 
      } 

      this.addEventListener(MouseEvent.MOUSE_UP, function(evt:MouseEvent):void 
            { 
             evt.target.removeEventListener(MouseEvent.MOUSE_DOWN, arguments.callee); 
             curState_ = 3; 
             evt.target.gotoAndStop(curState_); 
            }); 
     } 

     else if(evt.buttonDown != true) 
     { 
      curState_ = 3; 

      if (animated_ == true) 
      { 
       loopSegment((animationsListAR_[2] + 1), animationsListAR_[3]); 
      } 
      else 
      { 
       this.gotoAndStop(curState_); 
      } 
     } 

     dispatchEvent(new CustomButtonEvent(CustomButtonEvent.OVER)); 
    } 

    public function mouseOutHandler(evt:MouseEvent) 
    { 
     curState_ = 1; 

     if (animated_ == true) 
     { 
      loopSegment((animationsListAR_[0]), animationsListAR_[1]); 
     } 
     else 
     { 
      this.gotoAndStop(curState_); 
     } 

     dispatchEvent(new CustomButtonEvent(CustomButtonEvent.OUT)); 
    } 

    public function activeChangeHandler(evt:Event) 
    { 
     if (active_ == true) 
     { 
      this.addEventListener(MouseEvent.CLICK,mouseOverHandler); 
      this.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler); 
      this.addEventListener(MouseEvent.MOUSE_OUT,mouseOutHandler); 
     } 
     else 
     { 
      this.removeEventListener(MouseEvent.CLICK,mouseOverHandler); 
      this.removeEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler); 
      this.removeEventListener(MouseEvent.MOUSE_OUT,mouseOutHandler); 
     } 

     // modifyMaskButton(); 
    } 

    /* 
    public function modifyMaskButton():void 
    { 
    if (active_ = true) 
    { 

    } 
    else 
    { 

    } 
    } 
    */ 
    public function playSegment(begin:int, end:int):void 
    { 
     if (begin != end) 
     { 
      gotoAndPlay(begin); 
      addEventListener(Event.ENTER_FRAME,function(evt:Event):void 
        { 
         if(currentFrame == end) 
         { 
          stop(); 
          removeEventListener(Event.ENTER_FRAME, arguments.callee); 
         } 
        }); 
     } 
     else 
     { 
      this.gotoAndStop(end); 
     } 
    } 

    // This loops continuosly an animation. Should, at least... 
    public function loopSegment(begin:int, end:int):void 
    { 
     if (begin != end) 
     { 
      gotoAndPlay(begin); 
      addEventListener(Event.ENTER_FRAME,function(evt:Event):void 
        { 
         if(currentFrame == end) 
         { 
          gotoAndPlay(begin); 
         } 
        }); 
     } 
     else 
     { 
      this.gotoAndStop(end); 
     } 
    } 
} 
} 

セカンドファイル:

override function CustomTextfield(labelText:String, font:String = "Arial" 

"CustomTextfield" //あなたのスクリプトが欠落している内、 "CustomTextField" でなければなりません:二番目のファイルに次の行が

package 
{ 
import flash.display.MovieClip; 
import flash.text.TextField; 

public class CustomTextField extends MovieClip 
{ 
    private var textArea:TextField; 
    private var boldText:TextFormat = new TextFormat(); 

    function CustomTextField() 
    { 
     textArea = new TextField; 
    } 

    override function CustomTextfield(labelText:String, font:String = "Arial", color:uint = 0xFFFFFFFF, size:uint = 10) 
    { 
     textArea = new TextField; 
     boldText.font = font; 
     boldText.color = color; 
     boldText.size = size; 
     this.text = labelText; 
    } 

    function changeFont(font:String):void 
    { 
     boldText.font = font; 
     updateText(); 
    } 

    function changeColor(color:uint):void 
    { 
     boldText.color = color; 
     updateText(); 
    } 

    function changeSize(size:uint):void 
    { 
     boldText.size = size; 
     updateText(); 
    } 

    function embedText(choice:Boolean):void 
    { 
     this.embedFonts = choice; 
    } 

    function updateText():void 
    { 
     this.setTextFormat(boldText); 
    } 
} 
} 
+1

あなたは問題があると言っているだけの質問に対して答えを得ることは期待できません。エラーメッセージ、プロジェクト構造の説明、ソースコードそのものを教えてください。あなたの問題を簡単に理解できるものに分解してください。 – devsnd

+0

@twallこれは私たちのためだけに役立つだけでなく、問題を解消すると答えが見つかることがよくあります。 –

+0

誰かが「ああ、それは4つのファイルを持っているときは既知のFl​​ashの問題です」と言うことはほとんどありません。 – Kodiak

答えて

1

チェック大文字

私はこの機能がスクリプト内で2回トリガーされるか、いくつかの関連する変更がそれを知っていると思います。

+0

もちろん、同じディレクトリにあります。はい、正しく参照されています。とにかく、ソースコードを追加しました。 – MKII

+0

新しい.asファイルと.flaファイルを作成し、すべてをコピー&ペーストしました。ファイルが見つかりました。私はまだそれが何ができるか知りません。とにかく、上記の行は、その後に現れたエラーを修正しました。 – MKII

+0

私はまだ助けられました、笑LOLはメモリからのバグだったかもしれません..IVはcs5で奇妙なことが起こった、読み込まれたコンテンツは突然エラーなしでapearingを止めるので、私はあなたのself.hopeのようにもう一度始める必要がありました。 1を投票しました:) – joshua

関連する問題