Flash Error #1009: Cannot access a property or method of a null object referencee

294 Views Asked by At

My flash professional cc is showing error just for simple Alert code. I have tried to solve this by reading previously discussed on this website but unable to solve it.

Error is :

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.controls::Alert$/show()[/Users/aharui/flex-sdk-4.12.1/frameworks/projects/mx/src/mx/controls/Alert.as:574]
at AlertTest()[D:\summer project\practice\AlertTest.as:7]

Can anyone suggest the reason, here is my code!!

package {
import flash.display.Sprite;
import mx.controls.Alert;

public class AlertTest extends Sprite {
    public function AlertTest() {
        Alert.show("Would you like to exit the application?", "Confirm", Alert.YES | Alert.NO | Alert.CANCEL);
        trace("hey");
        }


}
}

Before this I was getting error 1046 : type was not found or a compile time constant..

So I installed Flex skd 4.12.1 in a folder and included it as Library path in action settings for fla file. After doing that I landed up getting this error.

Kindly suggest.

1

There are 1 best solutions below

3
BotMaster On

The mx Alert class is from Flex framework and can't be used in a Flash CC project.

With a Flex project you can use the Alert Class like you tried to do. With a pure actionscript 3 project or Flash CC project (there are some components available on Flash CC but no Alert) you have to create your own or you can try to find a custom framework that does that (I don't know any but maybe MadComponents?).