创建AS3 URL链接按钮。得到错误:1046

时间:2013-08-10 12:54:48

标签: url actionscript

我正在尝试为我的Flash游戏创建一个链接到我的网站网站的按钮。

但是,我收到了这个错误,我无法弄清楚我做错了什么。

第246行1046:未找到类型或不是编译时常量:URLRequest。

以下是我的Setup.as类

中的一些代码
package {

import flash.display.MovieClip;
import flash.events.TimerEvent; 
import flash.utils.Timer;
import flash.media.SoundChannel;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.navigateToURL;

public class Setup extends MovieClip {

    // For keeping things neat I removed my variables for this stack post. 

    public function Setup() {

        //..Preloader  
        loadingProgress = new LoadingProgress();
        loadingProgress.x = stage.stageWidth/2;
        loadingProgress.y = stage.stageHeight/2;
        addChild( loadingProgress );

        loaderInfo.addEventListener( Event.COMPLETE, 
                                     onCompletelyDownloaded );
        loaderInfo.addEventListener( ProgressEvent.PROGRESS, 
                                     onProgressMade );
        //..End Preloader
    }

   public function init():void {

        //Layer.init( stage );

        trace("");                      // Space Space Gotta Space This shiznit 
        trace("&& Game Initalized");    // Lets trace this MOFO 

        initStartup();
        //initLogo();
    }

    public function initStartup():void {
        drawGameStartup();
        btnJoyhype.addEventListener( MouseEvent.CLICK, urlRequestJoy );
    }

然后是URL功能

     public function urlRequestJoy( e:MouseEvent ) {
        var requestURL:URLRequest = new URLRequest("http://www.myurl.com");
        navigateToURL( requestURL, "_blank" );
        trace("@@ Click Click");
    }

我做错了什么?

谢谢! :d

1 个答案:

答案 0 :(得分:4)

错误消息Line 246 1046: Type was not found or was not a compile-time constant: URLRequest.表示他找不到课程URLRequest

在课程顶部,您必须导入课程URLRequest,如下所示:

import flash.net.URLRequest;