05.28.08

ActionScript Error #1067 – Implicit coercion of a value of type void to an unrelated type Function.

Posted in Error, Error, errors, Flash, Flex at 9:34 pm by Curtis J. Morley

ActionScript Error #1067: Implicit coercion of a value of type void to an unrelated type Function.

ActionScript 3 Error #1067 Description:
AS3 error 1137 is describing the fact that you have entered a parameter that is not supposed to be inside the parenthesis.

Flex / Flash Error 1067 Fix:
Remove all parameters from within the parenthesis.

Bad Code 1:

alone_btn.addEventListener(MouseEvent.MOUSE_UP, trace("The message"));

Good Code 1:

alone_btn.addEventListener(MouseEvent.MOUSE_UP, traceMe);
function traceMe (e:MouseEvent)
{
trace("The message");
}

AS3 Error # 1067: Implicit coercion of a value of type String to an unrelated type int.

ActionScript 3 Error #1067: Implicit coercion of a value of type Boolean to an unrelated type int.

Bad Code 2:

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=false);

or

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=String);

Good Code 2:

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=10);

AS3 Error 1067 Fix #2 - In the example below you will see that the function "Return Type" is listed as "int" when it needs to be listed as String.  To fix this simply change the Return Type to String or return a valid integer.

Bad Code:

function bob():int
{
return "message";
}

Good Code:

function bob():String
{
return "message";
}

Related Error(s):
Flash / Flex Error 1188
AS3 Warning 1102

This should help you resolve Flex / Flash Error #1067

Thanks and as always Happy Flashing

Curtis J. Morley

16 Comments »

  1. Viki said,

    June 29, 2008 at 2:28 am

    plusSym:Boolean = true;
    subSym:Boolean = false;
    multSym:Boolean = false;
    divSym:Boolean = false;

    I’m new to flash and I’ve been trying to make a simple calculator using the Youtube tutorial: http://au.youtube.com/watch?v=5k3h37YKZJI
    I’ve been getting errors for these lines and I don’t know whats wrong with them, the tutorial and I have the exact same codes.

  2. Curtis J. Morley said,

    June 30, 2008 at 6:45 am

    Viki,

    Thanks for the comment. This one is an easy one. I haven’t watched the tutorial but am pretty sure that it is written for AS2. AS3 Error 1067 shows up in your case because you are missing the keyword var in front of each variable assignment. This was allowed in AS2 but in AS3 all variable assignments require the keyword var like so:

    var plusSym:Boolean = true;
    var subSym:Boolean = false;
    var multSym:Boolean = false;
    var divSym:Boolean = false;
    Make sure to check out Flex / Flash Error 1188 as well.

    Happy Flashing Viki

  3. curtismorley.com » AS3 Error 1188: Illegal assignment to class Boolean. said,

    June 30, 2008 at 11:09 am

    [...] the description is is no help at all.  I have never experienced this error without also getting AS3 Error 1067 first.  This error will be thrown whenever the “var” keyword is missing on all variable [...]

  4. curtismorley.com » AS3 Warning: 1102: null used where a int value was expected. said,

    July 15, 2008 at 11:24 am

    [...] Related AS3 Error: AS3 Error 1067 [...]

  5. curtismorley.com » New Info added to AS3 Error 1067 said,

    July 15, 2008 at 11:32 am

    [...] Check out the new info I posted on AS3 Error #1067 [...]

  6. Flash/ Flex Error « RIAdobe said,

    August 10, 2008 at 8:03 pm

    [...] Related AS3 Error: AS3 Error 1067 [...]

  7. curtismorley.com » AS3 Error #1051: Return value must be undefined. said,

    August 20, 2008 at 12:41 pm

    [...] Flash Error 1067 (If you specified a return type of int, uint, Number, Array, Bitmap, etc…)Flash Warning 3590 (If you specified a return type of Boolean)Flash Error 1046 (If you specified a return type of Button) [...]

  8. curtismorley.com » Another New Example in AS3 Error 1067 said,

    August 20, 2008 at 1:32 pm

    [...] have posted a new example under the ActionScript 3 Error 1067.  This example addresses fixing an errant Return [...]

  9. Tanya said,

    December 6, 2008 at 11:28 pm

    if (leftKeyDown) {
    for(var i:int = 0; i < speed; i++) {
    if(Mouse_MC.hitTestPoint(course_MC.x – course_MC – i, course_MC.y, true)) {
    Mouse_MC.x += i;
    mazehit = true;
    break;
    }
    }
    if(!mazehit) {
    Mouse_MC.x += speed;
    }

    I am getting this error with the following code:
    if(Mouse_MC.hitTestPoint(course_MC.x – course_MC – i, course_MC.y, true))

    Any idea how to remedy this?

  10. Geoff said,

    December 29, 2008 at 8:29 pm

    Hey CM, Thanks for the blog on this. I figured I’d make a custom button handler so I could put all my URLs and all my button code in a single place at the top of the script:

    function clickHandler( page:String = ‘home’ ):void {
    var XFA:Object = {
    home:””
    , services:”page/our-services”
    , products:”page/products-we-offer”
    };
    getURL( XFA[page] );
    }

    btn01.addEventListener(MouseEvent.CLICK, clickHandler(“about”));
    btn02.addEventListener(MouseEvent.CLICK, clickHandler(“services”));
    btn03.addEventListener(MouseEvent.CLICK, clickHandler(“products”));

    …but as you point out, the above is exactly how NOT to do it.

    I had the thought that maybe what I should do is create a class that extends the MouseEvent class with a new ClickTo method that takes another parameter… (or better yet, override the CLICK event), but I wasn’t sure how to do it, and figured I must be missing something obvious. If I figure out what that might be I’ll come back and post a follow up.

  11. Geoff said,

    December 29, 2008 at 10:11 pm

    Doing some digging in the help on the Event class, I figured out that since each of my buttons has its own unique instance name, you can use the target.name property of the Event object passed, instead of trying to pass a string. Of course, once I got that far, I realized you can’t getURL in AS3 either, so a little Googling on that revealed the new URLRequest object. Here’s what I ended up with.

    function clickHandler(e:Event = null):void {
    //trace( “Button ” + e.target.name +” was clicked.” );
    var clicked:String = e.target.name;
    var XFA:Object = {
    btn00:””
    , btn01:”page/our-services”
    , btn02:”page/products-we-offer”
    };
    // trace( “Going to “+ XFA[clicked] );
    var url:String = XFA[clicked];
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, “_top”); // second argument is target
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }

    btn01.addEventListener(MouseEvent.CLICK, clickHandler);
    btn02.addEventListener(MouseEvent.CLICK, clickHandler);
    btn03.addEventListener(MouseEvent.CLICK, clickHandler);

  12. John said,

    February 25, 2009 at 4:12 pm

    Yay, your good example solved my problem :D

  13. itso said,

    March 22, 2009 at 9:23 am

    I have a simple question on how to go to a new page when the movie is over.

    I tried the getURL but the flash CS4 told me that it is no longer valid command, then I used the Actionscript 3.0 and the navigateToURL but still no luck…

    I am sure it is very easy, but simply cannot find the way.

  14. Aaron Cruz said,

    September 29, 2009 at 12:51 am

    Hi Curtis,
    Your error message descriptions have really saved me a ton of time on many occasions. So first of all, thank you.
    I have found another coding error that will commonly create the 1067 error. If I am coding in the IDE and I don’t call my variable with the “var” keyname I receive the
    “ActionScript Error #1067: Implicit coercion of a value of type Array(or whatever) to an unrelated type Class.”
    Again, thank you a ton. Aaron

  15. Arielle said,

    March 11, 2013 at 9:23 am

    I’m having problem with code
    I keep on getting this ERROR

    Line 85 1084: Syntax error: expecting rightparen before .10.

    for this line:: myText_txt.text==String((count)-myTimer.currentCount);

    BELOW IS MY CODE

    function countdown(event:TimerEvent):void {
    myText_txt.text==String((count)-myTimer.currentCount);

    if(myText_txt.text == “0″){
    gotoAndStop(28);
    }
    }

    Please help, this is for my senior project and I’ve been going crazy for days.

  16. Arielle said,

    March 11, 2013 at 9:25 am

    I’m having problem with code
    I keep on getting this ERROR

    Line 85 1067: Implicit coercion of a value of type Array to an unrelated type Number.

    for this line:: myText_txt.text==String((count)-myTimer.currentCount);

    BELOW IS MY CODE

    function countdown(event:TimerEvent):void {
    myText_txt.text==String((count)-myTimer.currentCount);

    if(myText_txt.text == “0″){
    gotoAndStop(28);
    }
    }

    Please help, this is for my senior project and I’ve been going crazy for days.
    DISREGARD LAST POST PLEASE.

Leave a Comment