Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3-错误1119-没有检测到我的静态类_Actionscript 3_Flash_Static Members - Fatal编程技术网

Actionscript 3 AS3-错误1119-没有检测到我的静态类

Actionscript 3 AS3-错误1119-没有检测到我的静态类,actionscript-3,flash,static-members,Actionscript 3,Flash,Static Members,背景:我一周前开始学习AS3。我的所有文件都在同一个文件夹中,路径设置为(默认情况下),因此所有类都应该在逻辑上相互检测。但事实证明,我有一个类包含大量的公共静态var,每次我在另一个类中调用它们时,都会得到错误1119 Access of possibly undefined property isKeyJump through a reference with static type Function. 带有静态变量的类称为Cont,用于“控制”;它基本上是用来检查哪些键被快速按下、刚刚按

背景:我一周前开始学习AS3。我的所有文件都在同一个文件夹中,路径设置为
(默认情况下),因此所有类都应该在逻辑上相互检测。但事实证明,我有一个类包含大量的
公共静态var
,每次我在另一个类中调用它们时,都会得到错误1119

Access of possibly undefined property isKeyJump through a reference with static type Function.
带有静态变量的类称为
Cont
,用于“控制”;它基本上是用来检查哪些键被快速按下、刚刚按下或按下两次。基本上,我让这个类来组织代码

我声明所有变量如下:

public static var isKeyRight:Boolean = false;
if (standing && Cont.isKeyJump) vacc = _jumpAcc;
如果这还不够明确,我甚至在构造函数中写了这个(我很累):

但这根本没有解决问题。问题似乎独立于类本身;只是我的另一个类没有检测到
Cont

我尝试了
导入Cont但这也没有改变任何事情。我的44行错误1119如下所示:

public static var isKeyRight:Boolean = false;
if (standing && Cont.isKeyJump) vacc = _jumpAcc;
我甚至确保在我的另一个类的实例之前实例化
Cont
,以确保定义至少在那里。但是,如果问题出在编译之后,而不是编译期间,那么这可能会导致错误

大部分:

其他类:(有44个错误的类)

及续:

package {

import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.display.MovieClip;
import flash.utils.*;

public class Cont extends MovieClip
{
    // Key codes
    public static var isKeyRight:Boolean;
    public static var isKeyJump:Boolean;
    ...

    //CONSTRUCTOR
    public function Cont()
    {
        Cont.isKeyRight = false;
        Cont.isKeyJump = false;
        ...

        if (stage) { init(); } 
        else { this.addEventListener(Event.ADDED_TO_STAGE, init); }
    }

    //POST-CONSTRUCTOR
    private function init(e:Event=null)
    {
        this.removeEventListener(Event.ADDED_TO_STAGE, init);
        ...
    }
编辑:嗯,将
Cont
中的所有代码放入
PersonnagePrincipal
中确实解决了synthax错误(因为我去掉了
Cont.
)。。。但现在我的代码不再那么性感和灵活了


编辑2:我将类
PersonnagePrincipal
设为空,它成功了。更奇怪的是,当我将行
public-var-control:Cont=new-control
放在
Main
中时,它工作了,同时在
PersonnagePrincipal
中生成了一个编译时错误。什么?

您是否在PersonnagePrincipal中声明了名为Cont的函数?不,唯一名为Cont的是类。我可以看到,“通过对静态类型函数的引用”使我认为您可能也意外地将其声明为函数