2

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.

Shruti Sharma
  • 177
  • 2
  • 11
  • Did you checked the related answer in SO? There seems many similar question already been asked prior. – Rahul Jun 07 '14 at 18:05
  • yeah i did .In every case they have passed a null parameter which is not allowed or referred a NULL object.But here i am using a static function of Alert class. so how there can be reason of NULL object.I even tried simply Alert.show("hi");,that also didnt work. – Shruti Sharma Jun 07 '14 at 19:26
  • @Shruti - is the Stage available on the line above Alert.show? `trace(this.stage);` Based on what you've shown, I'm expecting that to be NULL. – Brian Jun 13 '14 at 17:52

1 Answers1

0

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?).

BotMaster
  • 2,233
  • 1
  • 13
  • 16
  • oh!Than there is any way to show alert using action script3. – Shruti Sharma Jun 08 '14 at 05:06
  • I don't think this is correct. http://stackoverflow.com/questions/17027429/issue-using-flex-sdk-in-flash-professional-for-as3corelib talks about using Flex components in a Flash project. – Brian Jun 13 '14 at 17:50
  • This is correct to some extend. Some class from the Flex framework can be used without too much trouble. Some like mostly the components are very hard (or impossible) to instantiate within a pure AS3 project. Most workarounds are based on loading a swf comtaining Flex components (as opposed to using a swc) at runtime but this is at your own risks. – BotMaster Jun 13 '14 at 18:28