Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7555141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:31:33+00:00 2026-05-30T11:31:33+00:00

I get this error when compiling an AS3/Flex project: Error 1118: Implicit coercion of

  • 0

I get this error when compiling an AS3/Flex project:

Error 1118: Implicit coercion of a value with static type Object to a possibly 
unrelated type HRPeople

I’ve clearly declared dataHR_A to be of class HRPeople, and I’ve initialized all of the arrays inside the HRPeople.as file. Not sure why I’m getting this error.

My MXML Code looks like (snippet):

<?xml version="1.0" encoding="utf-8"?>
<s:Application 
    creationComplete="initApp()"
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Script>
        <![CDATA[                   
            public var dataHR_A:HRPeople = new HRPeople;

            public function initApp():void
            {               
                //preallocate memory
                dataHR_A.elements = 5;
                dataHR_A.FirstName = new Array(dataHR_A.elements);
                dataHR_A.LastName = new Array(dataHR_A.elements);
                dataHR_A.Email = new Array(dataHR_A.elements);
                dataHR_A.Salary = new Array(dataHR_A.elements);

                dataHR_A = {  // ERROR IS ON THIS LINE OF CODE
                    FirstName:["Donald","Douglas","Jennifer","Michael","Pat"],
                    LastName:["OConnell","Grant","Whalen","Hartstein","Fay"],
                    Email:["OCONNELL","DGRANT","JWHALEN","MHARTSTE","PFAY"],
                    Salary:[2600, 2600, 4400, 13000, 6000]};
            }
and so on ...

Here’s the class file for HRPeople.as:

package {
    public class HRPeople {
        public var elements:int;
        public var FirstName:Array = [];
        public var LastName:Array = [];
        public var Email:Array = [];
        public var Salary:Array = [];
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:31:34+00:00Added an answer on May 30, 2026 at 11:31 am

    You cannot use this kind of syntax in ActionScript 3. Because { … } is an Object while dataHR_A is HRPeople. To make it work, you need to write it like that:

    dataHR_A.elements = 5;
    dataHR_A.FirstName = ["Donald","Douglas","Jennifer","Michael","Pat"];
    dataHR_A.LastName = ["OConnell","Grant","Whalen","Hartstein","Fay"];
    dataHR_A.Email = ["OCONNELL","DGRANT","JWHALEN","MHARTSTE","PFAY"];
    dataHR_A.Salary = [2600, 2600, 4400, 13000, 6000]};
    

    Also you can just set the properties directly, you don’t need to allocate the memory.

    Also, rather than settings an elements property yourself, you could simply create a getter that will dynamically get the number of elements. That way you can add new elements without having to worry about keeping elements current. Something like that would work:

    package {
        public class HRPeople {
            public function get elements():int {
                return FirstName.length;
            }
            public var FirstName:Array = [];
            public var LastName:Array = [];
            public var Email:Array = [];
            public var Salary:Array = [];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error when compiling a C# application. Looks like a trivial error,
I get this message when compiling C++ on gcc 4.3 error: ‘NULL’ was not
I get an undefined reference to 'typeof'-error compiling and linking this: #include <stdio.h> #include
I get this error when compiling the following source from here : Error 1
I get this error android.database.sqlite.SQLiteException: near %: syntax error: , while compiling: SELECT _id,
When compiling an Inno Setup installer script I get this error Line: xx Resource
Hi i made a command line tool but when compiling i get this error
How come I get this error when compiling with the -m32 argument? unrecognised emulation
I'm a huge erlang noob, and while compiling ejabberd, I get this error: make[1]:
I get this error message while compiling: Assembly 'MyFramework [...]' uses 'System.Web.Extensions, Version=3.5.0.0 [...]'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.