1

为什么它不能检测到这些声明的图像对象 - m22,m33 ....?
TypeError:2007 错误#:参数 child 必须为非空。

代码运行良好,直到选择文本函数然后出错。

模式轨迹显示。显示其他轨迹。

Yaddah Yaaddah boxtrans 是一个透明的精灵来屏蔽鼠标输入。

package {
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
import flash.ui.Keyboard;
import mx.core.BitmapAsset;
//import board;
import flash.accessibility.AccessibilityImplementation;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.text.AntiAliasType; 
import flash.utils.describeType;
import flash.net.*;
import Set;
import StatusBox;
import Statusx;
import flash.display.InteractiveObject;
import flash.text.TextFieldType;
import flash.events.FocusEvent;
import fl.managers.FocusManager;
import flash.display.*;
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.utils.*;
import boxtrans;

public class boxsprite extends Sprite {     
    [Embed(source = "C:/Windows/Fonts/Verdana.ttf", fontName = "Verdana", fontWeight = "bold", advancedAntiAliasing = "true", mimeType = "application/x-font")] 
    public static const VERD:Class;
    [Embed(source="../lib/box.gif")]
    private var boxspriteClass:Class
    [Embed(source = "../lib/m2.gif")]
    private var m2:Class

    [Embed(source = "../lib/m3.gif")]
    private var m3:Class
    [Embed(source="../lib/m4.gif")]
    private var m4:Class
    [Embed(source = "../lib/m5.gif")]
    private var m5:Class
    [Embed(source = "../lib/m6.gif")]
    private var m6:Class

    [Embed(source = "../lib/m7.gif")]
    private var m7: Class
    [Embed(source="../lib/m8.gif")]
    private var m8: Class
    [Embed(source = "../lib/m9.gif")]
    private var m9: Class

    internal var m22:Bitmap;
    internal var m33:Bitmap;
    internal var m44:Bitmap;
    internal var m55:Bitmap;
    internal var m66:Bitmap;
    internal var m77:Bitmap;
    internal var m88:Bitmap;
    internal var m99:Bitmap;
    internal var boxsprite2:Bitmap;
    internal var boxtrans1:Sprite;

    internal var mode:uint=2;
    internal var displaytext:String;
    internal var setBox:Boolean = false;
    internal var onBoard:Array = [0];
    internal var playerRound:uint = 1;
    internal var round:uint = 1;
    internal var playernumber:uint; 
    internal var myTextBox:TextField = new TextField();

    public function boxsprite():void {
        init();     
    } 

    internal function init():void   {
        boxsprite2=new boxspriteClass as Bitmap;
        this.addChild(boxsprite2); 
        m77= new m7 as Bitmap;
        this.addChild(m77);
        m66= new m6 as Bitmap;
        this.addChild(m66);
        m55= new m5 as Bitmap;
        this.addChild(m55);
        m44= new m4 as Bitmap;
        this.addChild(m44);
        m33= new m3 as Bitmap;
        this.addChild(m33);
        m22 = new m2 as Bitmap;
        this.addChild(m22); 
        boxtrans1 = new boxtrans() as Sprite; 
        boxtrans1.x = 0;
        boxtrans1.y = 240; 
        this.addChild(boxtrans1);
        this.addEventListener(MouseEvent.CLICK, clickDoubleClick);
    }

    internal var m_nDoubleClickSpeed:Number = 300;
    internal var m_toMouse:Number;
    internal function clickDoubleClick(e:MouseEvent):void {
        if (isNaN(m_toMouse)==false) {
            clearTimeout(m_toMouse);
            HandleDoubleClick();
        } else {
            m_toMouse = setTimeout(HandleSingleClick, m_nDoubleClickSpeed);
        }
    }

    internal function HandleSingleClick():void {
        trace("HandleSingleClick");
        m_toMouse = NaN;
    }

    internal function HandleDoubleClick():void {
        modeswitch();
        trace("HandleDoubleClick");

        m_toMouse = NaN;
    }

    internal function modeswitch():void{  
        trace(mode);
        switch(mode) {
            case 8: 
                {mode = 9;
                choosetext(); }

            case 9: 
                {mode = 2;
                    choosetext();
                }
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                {mode +=1; 
                choosetext(); }
        }
    }

    internal function choosetext():void { 
        switch (mode) {
            case 2: {this.setChildIndex(m22,this.numChildren - 1);}
            case 3: {this.setChildIndex(m33,this.numChildren - 1);}
            case 4: {this.setChildIndex(m44,this.numChildren - 1);}
            case 5: {this.setChildIndex(m55,this.numChildren - 1);}
            case 6: {this.setChildIndex(m66,this.numChildren - 1);}
            case 7: {this.setChildIndex(m77,this.numChildren - 1);}
            case 8: {this.setChildIndex(m88,this.numChildren - 1);}
            case 9: {this.setChildIndex(m99,this.numChildren - 1); }    
        }
    }


}

}

4

1 回答 1

0

看起来您没有实例化m88m99任何地方。

由于您的语句中没有任何break命令,switch因此即使mode只有 2 个,它也会通过并执行每个案例。

我假设你打算做这样的事情:

switch (mode) {
    case 2: 
        this.setChildIndex(m22,this.numChildren - 1);
        break;
    case 3: 
        this.setChildIndex(m33,this.numChildren - 1);
        break;
    // etc...

}
于 2013-09-14T18:03:43.263 回答