ActionScript Error 1047: Parameter initializer unknown or is not a compile-time constant.

ActionScript Error 1047: Parameter initializer unknown or is not a compile-time constant.ActionScript Error 1047

Description:
Let’s break down ActionScript Error 1047 into it’s various parts.

  1. Parameter = The variable inside the parenthesis of a function
  2. Initializer = An initial value set on the parameter inside the parenthesis
  3. Compile-time Constant = Something Flash knows the value of without evaluating

So long story short – you are trying to assign a value to a parameter that has to be evaluated.  Still don’t know what I mean?  Check the code examples.

This is actually a really great feature of AS3.  Say for example you have an event listener that calls a function.  You also want to call this same function without the event. Unless you pass a value in you will get AS3 Error 1136.  AS3 allows you to set the Event parameter to null and therefore accept a call to that function without passing in a parameter.  function myUtilFunc( e:Event = null);

You can initialize and function with any Compile time constant for example a string like “Happy”, a constant like null or an int like 5 but you can not throw in anything that needs to be evaluated like a variable, math operation, an in-line array like [a,b,c] or date.

Flex / Flash Error #1047 Fix:
Remove any variable data and use only constants in the initializer such as Strings, Numbers, Null, etc…

Bad Code:

var init:String = “Happy”
function bob(someValue:String = init){
trace(someValue);
}

Good Code:

function bob(someValue:String = “Happy”){
trace(someValue);
}

or

function multiFunction(e:Event = null){
//doSomething;
}

Related Errors:

AS3 Error 1184

This should help you resolve Flex / Flash Error #1047

Thanks and as always Happy Flashing

Curtis J. Morley

Flex / Flash Compiler Error #1023: Incompatible override.

AS3 Compiler Error #1023: Incompatible override.

AS3 Error 1023 Description:

This ActionScript error is the most terse error that AS3 has provided us.  It is nothing like the beautiful description of AS3 Warning 1090

It popped up, rearing it’s ugly head like a teenager on Halloween. In most cases this error has more to do with AS3 Error 1021 than it does with an “Incompatible override”.   The first example below demonstrates this behavior. Example 1 will also give AS3 Error 1021 every time.

The second example is when an “Incompatible override” really is the reason.  Method signatures have to match or you will get this error.  Basically it means that you have not matched everything up properly from the method/Class that you are overriding.  So if you are overriding something that accepts events and you forget to put in events you will get this error.  If you give it a different Type you will get this error. Etc…

Adobe gives a good explanation of my second example.  They say:

“A function marked override must exactly match the parameter and return type declaration of the function it is overriding. It must have the same number of parameters, each of the same type, and declare the same return type. If any of the parameters are optional, that must match as well. Both functions must use the same access specifier (public, private, and so on) or namespace attribute as well.”

Flex / Flash Error #1023 Fix:

Make sure that you do not have duplicate names with an object and a function

or

Match the Method Signature of the soon to be overridden class.

Bad Code 1:

var myArray:Array = [1,2,3];

function myArray () {
}

Good Code 1:

var myArray:Array = [1,2,3];

function myArrayFunction () {
}

Bad Code 2:

override protected function draw(event:Event = null):void

Good Code 2:

override protected function draw(event:Event):void

Related Errors:

AS3 Error 3596
AS3 Error 1021
AS3 Error 1023 (Different error same number)

This should help you resolve Flex / Flash Warning #1023

Thanks and as always Happy Flashing

Curtis J. Morley

AS3 Compiler Error# 1021: Duplicate function definition.

AS3 Compiler Error# 1021: Duplicate function definition..

AS3 Error 1023 Description:

This ActionScript error is the most terse error that AS3 has provided us.  It is nothing like AS3 Warning 1090 It popped up, rearing it’s ugly head like a teenager on Halloween. In most cases this error has more to do with AS3 Error 1021 than it does with an incompatible override.  Sometimes it realy does mean that you have an override that is incompatible but many times it just means that you have a function that is named the same as

Flex / Flash Error #1021 Fix:

Do exactly what the message says use an event listener instead of the onRelease event that was common in AS2.

Bad Code 1:

function bob () {
}

function bob () {
}

Good Code 1:

function bob () {
}

function jim () {
}

Bad Code 2:

var myArray:Array = [1,2,3];

function myArray () {
}

Good Code 2:

var myArray:Array = [1,2,3];

function myArrayFunction () {
}

Related Errors:

AS3 Error 3596
AS3
Compiler Error 1023
AS3 Error 1023 (Different error same number.  This one has nothing to do with error 1021)

This should help you resolve Flex / Flash Warning #1021

Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript Warning 1090: Migration issue: The onRelease event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( ‘click’, callback_handler).

AS3 Warning: 1090: Migration issue: The onRelease event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0.  You must first register this handler for the event using addEventListener ( ‘click’, callback_handler).

AS3 Warning 1090 Description:

So the other day I opened some AS2 files that I use for teaching Flash Arrays at UVU.  I changed a few things in the file and tested my movie.  That is when Warning 1090 popped up and I realized that I had missed a few things.  AS3 Warning1090 is the most comprehensive and complete error message that I have ever encountered in Flash or Flex.  Not only does it give a really clear description but it tells you how to solve the issue.  Kudos Flash programmers/writers.  Jen DeHaan  if this is you – Nice Job!

P.S.  This will also happen with onEnterFrame, onPress, onMouseMove, etc…  I have only included one example here but it applies to all cases.

Flex / Flash Error #1090 Fix:

Do exactly what the message says use an event listener instead of the onRelease event that was common in AS2.

Bad Code:

joinArray_btn.onRelease = function () {
//Do Something
}

Good Code:

joinArray_btn.addEventListener(MouseEvent.CLICK, joinArray);

function joinArray() {
//Do Something
}

Related Errors:

AS3 Warning 1058

This should help you resolve Flex / Flash Warning #1090

Thanks and as always Happy Flashing

Curtis J. Morley

ReferenceError: Error #1069: Property addEvent not found on flash.utils.Timer and there is no default value

ReferenceError: Error #1069: Property addEvent not found on flash.utils.Timer and there is no default value.

ActionScript 3 Error #1069 Description:
AS3 error 1069 appears when you have misspelled a property or function and have not assigned a value to it. If you have properly typed the Object to begin with you will get AS3 Error 1061. See the examples below. AS3 error 1069 is actually pretty nice to work with because it tells you exactly which method/property didn’t work and it tells you which object it didn’t work on.

Flash / Flex Error 1069 Fix:
Find the object listed in the error and then check the spelling after the dot.

Bad Code 1:

var t = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick);

Good Code 1:

var t = new Timer(1000, 60);
t.addEventListener(TimerEvent.TIMER, Tick);

This should help you resolve Flex / Flash Error #1069

Thanks and as always Happy Flashing

Curtis J. Morley

Related ActionScript Error(s):
Flash / Flex Error 1061
– You will get AS3 Error 1069 instead of 1061 if you don’t properly type your object before referencing a property on it. For example var t:Timer = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick); will give error 1061 but var t = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick); will give Error 1069.
Flash / Flex Error 1119
Flash / Flex Error 1056
– This is the error you will get if you try and call a method with a misspelled name in the same way as calling a property with a misspelled name.

Flash 10 Drawing API tutorials

Flash 10 Drawing Tutorials

In the spirit of keeping everyone on the bleeding edge, Trevor McCauley at Senocular has provided an amazingly detailed description of using the drawing API’s with for Flash 10.  This is a must read.

http://www.senocular.com/flash/tutorials/flash10drawingapi/

I will keep you up to date on all of the great tutorials I find on using Flash 10.

Thanks and Happy Flashing

Curtis J. Morley

Flash 10 to have Dynamic Sound Generation

So it looks like the Make Some Noise campaign paid off.  Thanks to Andre Michelle who has always been at the forefront of Sound in Flash.  Thanks to everyone that voted for the bug and Eliot Van Buskirk for the Article on Wired.The day after Eliot wrote his article is when the Flash Player 10 announcement came out.  You can read more on Wired Magazine

It is official – Flash 10 has Dynamic Audio Support.  Dynamically generated sound can now be passed from Flash directly to the sound card.  This opens many doors for Flash Developers and for products like musicRAIN digital sheet music.

This is a Quote from the Flash Player 10 Release Notes on Adobe Labs

Other Community Requested Enhancements

  • File Reference
  • Dynamic Sound Generation
  • etc…

This is great news for the Flash Community. Flash 10 is going to revolutionize the audio industry just like FLV have changed the way we watch TV and movies(ie… youtube) This will allow products like the digital sheet music at www.musicRAIN.com to have a solid audio playback solution. I am personally excited about what we are going to see over the next year throughout the industry. Music Mixers, digital sheet music, Real Time audio for games, Networked Jam sessions like www.eJamming.com, optimization and smaller downloads to name a few.

Thanks Andre for starting the campaign, thanks Eliot for posting the article, and thanks Tinic Uro and everyone at Adobe for putting this in the next version.

Happy Flashing,

Curtis J. Morley

Flash CS6 / Flex Error #1009: Cannot access a property or method of a null object reference

TypeError: Error #1009: Cannot access a property or method of a null object reference

ActionScript 3 Error #1009 is an AS3 that you can get for many anecdotal reasons. This error basically means that you are trying to reference something that isn’t there yet. That something can be a variable, data from the server, or even a movieClip or other display instance. So if you try and make a call to something and are getting this error simply look at what you are trying to reference and ask yourself is it there yet.
Don’t bang your head against the wall any longer. Here I explain one of the most un-obvious ways to get this error.

One reason that you will get AS3 Error #1009 is because you are trying to access a movieClip that isn’t instantiated yet. For example you try and reference a movieClip named loader_mc that is inside another movieClip. you are referencing it from a class that you created. Each time you run the test the movie you get the Run-Time Error #1009. You look inside your movieClip and see that the loader_mc is right where you want it. It is on frame 10 inside your animated moveiClip. That is when it dawns on you that the call to loader_mc happens when it is instantiated. Simply, put loader_mc on frame 1 and change it’s alpha to 0 and then the movieClip will be instantiated when the call from your custom class is made.

Another reason for this error is simply incorrect targeting. If you target parent.bob and the correct reference is parent.parent.bob then you will get this error as well.

Fix 1 :

Make sure the the reference is instantiated before it is called.  This means that the script is run after the object is loaded or the frame in the animation has been reached etc…

Fix 2 :

Check your targeting

Thanks and Happy Flashing