Skip to main content
Participant
February 27, 2011
Answered

1046: Type was not found or was not a compile-time constant: URLRequest.

  • February 27, 2011
  • 1 reply
  • 1789 views

Hello everyone!

I'm having a bit of difficulty with ActionScript 3 and was wondering if anyone could help me.

I'm new to Flash CS5 and AS3 but i've attempted to create a (initially simple) track sampling app which allows the user to click an image to start/stop an mp3, I had the initial script sorted where the button would toggle that starting and stopping of the mp3. I've been trying soooooo hard for weeks but as soon as i've tried to package (to allow future script additions for effects) it it has thrown up the following error:

C:\Users\Alice\Desktop\Prototype\com\app\Application.as, Line 57

1046: Type was not found or was not a compile-time constant: URLRequest.

Here is the code for the package Application.as

package com.app{



import flash.display.SimpleButton;

import flash.media.Sound;

import flash.media.SoundChannel;

import flash.events.Event;

import flash.display.MovieClip;

import flash.events.MouseEvent;

import flash.display.Sprite;

import flash.net.URLLoader;


public class Application extends MovieClip {



public var flag:Boolean;


public function Application()

{

bozeat.addEventListener (MouseEvent.CLICK, bozeat_button_Handler);

flag = false;

}



public function bozeat_button_Handler (e:MouseEvent):void {


bozeat_snd.load(new URLRequest("drums.mp3"));

if (flag == false){

bzChannel = bozeat_snd.play(0,int.MAX_VALUE);

flag = true;

trace("true");

} else if(flag == true) {

bzChannel.stop();

flag = false;

trace("false");

}

}


This is the #1046 error keeps it keeps pointing me to:

bozeat_snd.load(new URLRequest("drums.mp3"));

And here is the code for the .fla file

import com.app.Application;

var app:Application = new Application();

I have named the document class to

com.app.Application

My mp3 is

drums.mp3 with an instance name of bozeat_sound

I hope someone understands what i am talking about lol. Sorry for the hassle thanks for any help in advance

Alice19Eighty8

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

You haven't imported flash.net.URLRequest

1 reply

Kenneth Kawamoto
Community Expert
Kenneth KawamotoCommunity ExpertCorrect answer
Community Expert
February 27, 2011

You haven't imported flash.net.URLRequest

Participant
February 27, 2011

Hi Kenneth!

Thanks for the advice, i missed such an obvious thing. I've now had another error saying:

Error: Error #2136: The SWF file file:///C|/Users/Alice/Desktop/Prototype/Working%20draft.swf contains invalid data.

at com.app::Application/frame1()[com.app.Application::frame1:2]

So I've commented out line 2 from the .fla script
var app:Application = new Application();
just to test if it is just that line of script which is to blame overall.
And now the .swf initially loads up with no errors then as the button is clicked i get the following error:
ReferenceError: Error #1069: Property play not found on flash.net.URLLoader and there is no default value.
at com.app::Application/bozeat_button_Handler()
Thanks

Participant
February 27, 2011

Btw the error is reffering to the following line in my .as file!

bzChannel = bozeat_snd.play(0,int.MAX_VALUE);