flash - AS3 : ERROR 1046: Type was not found or was not a compile-time constant: Stage and TextField

原文 标签 flash actionscript-3 oop error-handling

因此,我正在做一个游戏,当我将类测试到文件中时,我得到四个相同类型的错误:“1046:找不到类型或不是编译时常量:Stage和TextField”。我已经导入了所有内容,请看一下:

游戏

package  {

import flash.display.Stage.*;
import flash.filter.GlowFilter.*;
import flash.text.TextField.*;
import flash.net.URLLoader.*;
import flash.net.URLRequest.*;
import flash.net.URLRequestMethod.*;
import flash.net.URLLoaderDataFormat.*;
import flash.net.URLVariables.*;


public class Game {

    public static const STATUS_MENU:int = 1;
    public static const STATUS_SURVIVAL:int = 2;
    public static const STATUS_MULTIPLAYER:int = 3;

    public static const GAME_RUN:int = 1;
    public static const GAME_PAUSE:int = 2;

    public static var palco:Stage;
    public static var profileName:Array; //Name, status, pass

    public function Game():void {
        trace("Class Game is online.");
    }

    public function transStage(sender:Stage):Stage {
        palco = sender;
        palco.align = StageAlign.BOTTOM_LEFT;
        palco.scaleMode = StageScaleMode.EXACT_FIT;
        palco.displayState = StageDisplayState.FULL_SCREEN;
        return(palco);
    }

    public function makeGlow(txt:TextField):void {
        var glow:GlowFilter = new GlowFilter(); 
        glow.color = 0xFFFFFF; 
        glow.alpha = 1; 
        glow.blurX = 4.5; 
        glow.blurY = 4.5; 
        glow.quality = BitmapFilterQuality.HIGH;
        txt.filters = [glow];

    }

    public function removeGlow(txt:TextField):void {
        txt.filters = [];
    }

    public function setStatus(current:int):void {
        var request1:URLRequest = new URLRequest("http://www.url.com/");
        var loader:URLLoader = new URLLoader();
        var vari:URLVariables = new URLVariables();
        vari.Profile = profileArray[1];
        switch (current) {
            case 1:
            vari.Status = 1;
            profileArray[2] = 1;
            break;
            case 2:
            vari.Status = 2;
            profileArray[2] = 2;
            break;
            case 3:
            vari.Status = 3;
            profileArray[2] = 3;
            break;
        }
        loader.dataFormat = URLLoaderDataFormat.VARIABLES;
        request1.data = vari;
        request1.method = URLRequestMethod.POST;
        loader.load(request1);
    }

    }
   }

这是fla测试文件:
import Game;

var manager:Game = new Game();

另外,如果对我的组织方式或编写此代码的方式有任何建议,请在此处发布,因为我是初学者。

最佳答案

您所有的进口商品都是错误的。

//Change
import flash.display.Stage.*;
import flash.filter.GlowFilter.*;
import flash.text.TextField.*;
import flash.net.URLLoader.*;
import flash.net.URLRequest.*;
import flash.net.URLRequestMethod.*;
import flash.net.URLLoaderDataFormat.*;
import flash.net.URLVariables.*;


/ to
import flash.display.Stage;
import flash.filter.GlowFilter;
import flash.text.TextField;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLLoaderDataFormat;
import flash.net.URLVariables;

关于flash - AS3 : ERROR 1046: Type was not found or was not a compile-time constant: Stage and TextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7960561/

相关文章:

ios - 如何在具有单独位置URL和资源URL的服务器中实时直播来自服务器的音频?

sqlite - SQLite请求中的嵌套引号

jquery - 网络摄像头/麦克风检测

actionscript-3 - 每个 MOUSE_DOWN 都保证一个 MOUSE_UP 吗?

oop - 什么时候防止类继承?

c++ - cout 不产生输出

flash - 将 Adob​​e Air 3.3 SDK 与 Flash Builder 结合使用

javascript - 如何使用 Microphone.getMicrophone() Actionscript 3 切换音频源

c++ - C++如何从函数返回对象数组

flash - AIR renderMode GPU与renderMode Direct