Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.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/0/amazon-s3/2.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
Flash 导入一个类并使其成为我游戏的一部分_Flash_Actionscript 3_Class - Fatal编程技术网

Flash 导入一个类并使其成为我游戏的一部分

Flash 导入一个类并使其成为我游戏的一部分,flash,actionscript-3,class,Flash,Actionscript 3,Class,大家好,我希望能得到一些帮助,将这门课导入一个小游戏AS3 allowDomains:Array是允许的域的列表 我的问题是一个如何编写这个数组的位置 以及将其放置在何处,以便使用FlashCS4进行编译 下课 package com.ikonicstudios.utils { import flash.display.DisplayObject; import flash.display.MovieClip; import flash.display.LoaderIn

大家好,我希望能得到一些帮助,将这门课导入一个小游戏AS3

allowDomains:Array是允许的域的列表

我的问题是一个如何编写这个数组的位置 以及将其放置在何处,以便使用FlashCS4进行编译

下课

package com.ikonicstudios.utils 
{
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.display.LoaderInfo;
    import flash.text.TextField;
    import flash.text.TextFormat;

    //rootLevel:MovieClip is the location of the root timeline
    //allowDomains:Array is a list of the allowed domains
    //will return true is the domain is allowed, false if the domain is not allowed
    //displayWarning dynamically adds a message across the screen

    public class SiteLock extends MovieClip
    {

        public var domain:String;
        public var rootLevel:DisplayObject;
        private var warningText:TextField = new TextField();

        public function SiteLock() 
        {
        }

        public function checkLock(rootLevel:DisplayObject, allowedDomains:Array):Boolean {
            this.rootLevel = rootLevel
            domain = rootLevel.loaderInfo.url;

            for each(var allowed in allowedDomains) {
                if (domain.indexOf(allowed)!=-1) {
                    return true;
                }
            }

            return false;
        }

        public function displayWarning() {  
            var sh = rootLevel.stage.stageHeight;
            var sw = rootLevel.stage.stageWidth;
            var format = new TextFormat("_sans", 14, 0x000000, true, false, false, null, null, "center");
            warningText.text = "This domain does not have permission to host this flash";
            warningText.y = sh / 2 ;
            warningText.width = sw;
            warningText.setTextFormat(format);
            warningText.selectable = false;
            rootLevel.stage.addChild(warningText);

        }

    }

}
使用Flash CS4时,类文件运行正常。。但是当我尝试在Flex builder中使用它时,我得到了一些警告。见下文。任何人都知道如何删除此警告,并将该类修复为在Flex builder中工作?谢谢你,约翰

1008:函数的返回值 “displayWarning”没有类型 公告第39行1008:变量 “allowed”没有类型声明。 第30行1008:变量“sh”没有 类型声明。第40行,第1008行: 变量“sw”没有类型声明。 第41行1008:变量“格式”已更改 没有类型声明。第42行

将其放置在第0帧的脚本中


谢谢你的快速回复。工作起来很有魅力。。。非常感谢。
var siteLock:SiteLock = new SiteLock()
if(!siteLock.checkLock(this, ["mydomain1.com","mydomain2.com"]))
    siteLock.displayWarning();