简体   繁体   English

错误1046和1119

[英]Error 1046 and 1119

Hi there I'm having 2 errors which I can't seem to solve. 嗨,我遇到了2个似乎无法解决的错误。 Though it seems like it shouldn't be too much of a problem. 尽管似乎应该不是一个太大的问题。

package  {

import flash.display.MovieClip; //line 3
import flash.events.MouseEvent;


public class video01 extends MovieClip {


    public function video01() {
        // constructor code
        import flash.events.MouseEvent;

        trace("movieclip 1 geladen");

        btn_terug.addEventListener(MouseEvent.CLICK.terug); //line 16


    }


    public function terug(evt:MouseEvent):void {
    trace("knop ingedrukt");

    }


}

} }

The errors are: Line 3 1046: Type was not found or was not a compile-time constant: btn_terug. 错误是:第3行1046:找不到类型或不是编译时常量:btn_terug。 Line 16 1119: Access of possibly undefined property terug through a reference with static type String. 第16行1119:通过静态类型为String的引用访问可能未定义的属性terug。

Any thoughts? 有什么想法吗?


EDIT 编辑

This is my main code, it resides on the timeline of the .fla: 这是我的主要代码,它位于.fla的时间轴上:

import fl.video.*;
import flash.events.MouseEvent;
import flash.display.MovieClip;

stop();

btn_1.addEventListener(MouseEvent.CLICK,speel1);
btn_2.addEventListener(MouseEvent.CLICK,speel2);
btn_3.addEventListener(MouseEvent.CLICK,speel3);
btn_4.addEventListener(MouseEvent.CLICK,speel4);
btn_5.addEventListener(MouseEvent.CLICK,speel5);
btn_6.addEventListener(MouseEvent.CLICK,speel6);
btn_7.addEventListener(MouseEvent.CLICK,speel7);
btn_8.addEventListener(MouseEvent.CLICK,speel8);
btn_9.addEventListener(MouseEvent.CLICK,speel9);


var mc_video01:MovieClip = new video01();
var mc_video02:MovieClip = new video02();
var mc_video03:MovieClip = new video03();
var mc_video04:MovieClip = new video04();
var mc_video05:MovieClip = new video05();
var mc_video06:MovieClip = new video06();
var mc_video07:MovieClip = new video07();
var mc_video08:MovieClip = new video08();
var mc_video09:MovieClip = new video09();

var filmAan = false;

function speel1(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video01);
    mc_video01.x=340; 
    mc_video01.y=227;
    mc_video01.width=1360;
    mc_video01.height=1060;

    filmAan = true;
}
}
function speel2(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video02);
    mc_video02.x=340; 
    mc_video02.y=227;
    mc_video02.width=1360;
    mc_video02.height=1060;

    filmAan = true;
}
}
function speel3(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video03);
    mc_video03.x=340; 
    mc_video03.y=227;
    mc_video03.width=1360;
    mc_video03.height=1060;

    filmAan = true;
}
}
function speel4(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video04);
    mc_video04.x=340; 
    mc_video04.y=227;
    mc_video04.width=1360;
    mc_video04.height=1060;

    filmAan = true;
}
}
function speel5(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video05);
    mc_video05.x=340; 
    mc_video05.y=227;
    mc_video05.width=1360;
    mc_video05.height=1060;

    filmAan = true;
}
}
function speel6(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video06);
    mc_video06.x=340; 
    mc_video06.y=227;
    mc_video06.width=1360;
    mc_video06.height=1060;

    filmAan = true;
}
}
function speel7(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video07);
    mc_video07.x=340; 
    mc_video07.y=227;
    mc_video07.width=1360;
    mc_video07.height=1060;

    filmAan = true;
}
}
function speel8(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video08);
    mc_video08.x=340; 
    mc_video08.y=227;
    mc_video08.width=1360;
    mc_video08.height=1060;

    filmAan = true;
}
}
function speel9(evtObj:MouseEvent):void {
trace("knop 1: video 1");
    if (filmAan == false) {

    addChild(mc_video09);
    mc_video09.x=340; 
    mc_video09.y=227;
    mc_video09.width=1360;
    mc_video09.height=1060;

    filmAan = true;
}
}

The main page has 9 buttons that open a movieclip with a video, and button to go back to the main page. 主页上有9个按钮打开带有视频的动画片段,还有9个按钮返回到主页。 Each movieclip has a class named video01, video02 etc. (As seen above) The main .fla it's class is titled 'main'. 每个动画片段都有一个名为video01,video02等的类(如上所示)。它的主.fla类的标题为“ main”。

The buttons on the main page work, and all open a different movieclip(with the button inside). 主页上的按钮起作用,并且所有按钮都打开一个不同的动画片段(带有内部按钮)。 What I want to do is so that the btn_terug removes the child. 我要做的是让btn_terug删除孩子。 But I'm getting error 1046 on line 3. 但是我在第3行收到错误1046。

Hope this clarifies my question :) 希望这可以澄清我的问题:)

Phew, you're all over the place on this one, lol..so all import statements live after package ..besides you have import flash.event.MouseEvent twice. ew,到处都是,大声笑..so所有import语句位于package ..之后,但您两次import flash.event.MouseEvent It should not live in the constructor code. 它不应存在于构造函数代码中。 Second, your event listener should be like this: 其次,您的事件监听器应如下所示:

btn_terug.addEventListener(MouseEvent.CLICK, terug);

not btn_terug.addEventListener(MouseEvent.CLICK.terug); 不是btn_terug.addEventListener(MouseEvent.CLICK.terug);

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;

    public class video01 extends MovieClip
    {
        public function video01()
        {
            trace("movieclip 1 geladen");
            btn_terug.addEventListener(MouseEvent.CLICK, terug);
        }

        public function terug(evt:MouseEvent):void
        {
            trace("knop ingedrukt");
        }
    }
}

See how pretty that code is now? 看看现在的代码有多漂亮? =) =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM