PDA

Просмотр полной версии : ошибка 1046 О чем она?


imediasun
20.11.2012, 14:06
О чем говорит ошибка 1046 Тип не найден или не является константой времени.
при том ссылается на следующие строки

import flash.display.*;
public var buttonContainer:ButtonContainer;
var container:ButtonContainer = event.target as ButtonContainer;

Wolsh
20.11.2012, 14:10
О том что класс ButtonContainer не импортирован.
В пакете flash.display нет класса ButtonContainer.

imediasun
20.11.2012, 14:29
Я же указал что он расширяет класс MovieClip. Во флэше я указываю класс ButtonContainer в свойствах но базовый класс почему то не указывается, хотя в других проектах указывается, не пойму

package {

import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.events.Event;


public class ButtonContainer extends MovieClip {
public var button1:SimpleButton;
public var button2:SimpleButton;
public var button3:SimpleButton;
public var button4:SimpleButton;
private var _index:int = 1;
public function ButtonContainer() {
// constructor code
button1.addEventListener(MouseEvent.CLICK, buttonsHandler);
button2.addEventListener(MouseEvent.CLICK, buttonsHandler);
button3.addEventListener(MouseEvent.CLICK, buttonsHandler);
button4.addEventListener(MouseEvent.CLICK, buttonsHandler);
}

private function buttonsHandler(event:MouseEvent):void{
switch(event.target.name){
case "button1":
this.setChildIndex(this["button1"], this.numChildren-1);
this.setChildIndex(this["button2"], this.numChildren-2);
this.setChildIndex(this["button3"], this.numChildren-3);
this.setChildIndex(this["button4"], this.numChildren-4);
_index = 1;
break;
case "button2":
this.setChildIndex(this["button2"], this.numChildren-1);
this.setChildIndex(this["button1"], this.numChildren-2);
this.setChildIndex(this["button3"], this.numChildren-3);
this.setChildIndex(this["button4"], this.numChildren-4);
_index = 2;
break;
case "button3":
this.setChildIndex(this["button3"], this.numChildren-1);
this.setChildIndex(this["button2"], this.numChildren-2);
this.setChildIndex(this["button1"], this.numChildren-3);
this.setChildIndex(this["button4"], this.numChildren-3);
_index = 3;
break;
case "button4":
this.setChildIndex(this["button4"], this.numChildren-1);
this.setChildIndex(this["button2"], this.numChildren-2);
this.setChildIndex(this["button1"], this.numChildren-3);
this.setChildIndex(this["button3"], this.numChildren-3);
_index = 4;
break;
}
this.dispatchEvent(new Event(Event.CHANGE));
}

public function get index():int{
return _index;
}
}

}

Wolsh
20.11.2012, 15:22
При чем здесь МувиКлип? Сам класс ButtonContainer не найден компилятором.

caseyryan
20.11.2012, 18:56
Пакет у класса корневой. Поэтому могу предположить только одно. Класс ButtonContainer находится не в той директории, что fla файл

И вообще, что это за конструкция

import flash.display.*;
public var buttonContainer:ButtonContainer;
var container:ButtonContainer = event.target as ButtonContainer;

?

Переменные в классе не должны объявляться рядом с импортами. А если это не класс, то у меременной не должна быть указана область видимости
Это так и есть? Или каждая строчка отдельно вырвана из контекста?