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

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 thoughts on “ActionScript Error #1067 – Implicit coercion of a value of type void to an unrelated type Function.

  1. 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.

  2. 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.

  3. 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

  4. 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.

  5. 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);

  6. 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.

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

  8. Pingback: curtismorley.com » Another New Example in AS3 Error 1067

  9. Pingback: curtismorley.com » AS3 Error #1051: Return value must be undefined.

  10. Pingback: Flash/ Flex Error « RIAdobe

  11. Pingback: curtismorley.com » New Info added to AS3 Error 1067

  12. Pingback: curtismorley.com » AS3 Warning: 1102: null used where a int value was expected.

  13. Pingback: curtismorley.com » AS3 Error 1188: Illegal assignment to class Boolean.

  14. 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

  15. 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.

Comments are closed.