Type was not found or was not a compile-time constant?

I don't understand what is wrong with my code. When I debug it tells me: 1046: Type was not found or was not a compile-time constant: LocationChangeEvent. This is the code:

// imports
import flash.events.Event;
import flash.events.LocationChangeEvent;
import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.events.MouseEvent;

// setup variables
var _stageWebView:StageWebView;
var myAdvertURL:String = "http://terrypaton.com/ads/exampleAdvert.html";
function createAd(event:MouseEvent):void {
    // check that _stageWebView doersn't exist
    if (! _stageWebView) {
        _stageWebView = new StageWebView () ;
        // set the size of the html 'window'
        _stageWebView.viewPort = new Rectangle(0,0,480,80);
        // add a listener for when the content of the StageWebView changes
        // start loading the URL;
    // show the ad by setting it's stage property;
    _stageWebView.stage = stage;
function toggleAd(event:MouseEvent):void {
    trace("toggling advert",_stageWebView);
    // check that StageWebView instance exists 
    if (_stageWebView) {
        if (_stageWebView.stage == null) {
            //show the ad by setting the stage parameter
            _stageWebView.stage = stage;
        } else {
            // hide the ad by nulling the stage parameter
            _stageWebView.stage = null;
    } else {
        // ad StageWebView doesn't exist - show create it

function destroyAd(event:MouseEvent):void {
    // check that the instace of StageWebView exists
    if (_stageWebView) {
        trace("removing advert");
        // destroys the ad
        _stageWebView.stage = null;
        _stageWebView = null;

function onLocationChange(event:LocationChangeEvent):void {
    // check that it's not our ad URL loading
    if (_stageWebView.location != myAdvertURL) {
        // destroy the ad as the user has kindly clicked on my ad
        // Launch a normal browser window with the captured  URL;
        navigateToURL( new URLRequest( event.location ) );
// setup button listeners

Is there a way to change this code to make it work, or this code can't be used any longer?


According to the reference, LocationChangeEvent should indeed be in flash.events if compiled in AS3. I'm not sure why it's not found.

Try compiling a simpler example:

import flash.events.LocationChangeEvent;
var ev:LocationChangeEvent;

Need Your Help

JQGrid Showing empty while processing more than 3200 records with MVC 4

asp.net-mvc-4 c#-4.0 razor jqgrid mvcjqgrid

JQGrid is working fine for records up to 3000 and so with loadone:true , while it comes to more than 3200 it is showing empty grid. I would like to take up with server side paging and loadonce:fals...

Trying to print multiple files from directory


I'm trying to print multiple files in a list from my directory.