2

我正在尝试为我的 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

4

1 回答 1

4

错误信息Line 246 1046: Type was not found or was not a compile-time constant: URLRequest.表明他找不到类URLRequest

在类的顶部,您必须导入类URLRequest,如下所示:

import flash.net.URLRequest;

于 2013-08-10T13:01:51.770 回答