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

  • Home
  • SEARCH
  • 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 141647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:48:37+00:00 2026-05-11T07:48:37+00:00

Data binding in ActionScript is really cool. But what if I want to refactor

  • 0

Data binding in ActionScript is really cool. But what if I want to refactor a big switch or if statement inside the curly braces into a function, for example:

 {person.gender == 'male' ? 'Mr.' : 'Ms.'} 

into:

 {salutation(person)} 

The compiler doesn’t let me do that. I know about properties and I could write getters and setters on the person object. But since I am using inlined JSON objects now that’s not convenient(I think). What are other good ways to refactor this code?

To answer Matt’s comment. The data type of person is just plain Object. It was decoded from JSON format coming from a service call.

  • 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. 2026-05-11T07:48:37+00:00Added an answer on May 11, 2026 at 7:48 am

    You’ll need to make the Person class (assuming you have one) bindable in order for this to work.

    However, since you are saying you’re using JSON objects, I’m assuming you just have anonymous objects that were parsed from a JSON string. In that case, I’m pretty sure that won’t work. You’ll need to create a strongly typed object that has bindable properties.

    Just FYI: to avoid having to write custom JSON parsers for every object you want to create, you can create strong typed objects from vanilla objects using a bytearray trick:

    public static function toInstance( object:Object, clazz:Class ):* {   var bytes:ByteArray = new ByteArray();   bytes.objectEncoding = ObjectEncoding.AMF0;    // Find the objects and byetArray.writeObject them, adding in the   // class configuration variable name -- essentially, we're constructing   // and AMF packet here that contains the class information so that   // we can simplly byteArray.readObject the sucker for the translation    // Write out the bytes of the original object   var objBytes:ByteArray = new ByteArray();   objBytes.objectEncoding = ObjectEncoding.AMF0;   objBytes.writeObject( object );    // Register all of the classes so they can be decoded via AMF   var typeInfo:XML = describeType( clazz );   var fullyQualifiedName:String = typeInfo.@name.toString().replace( /::/, '.' );   registerClassAlias( fullyQualifiedName, clazz );    // Write the new object information starting with the class information   var len:int = fullyQualifiedName.length;   bytes.writeByte( 0x10 );  // 0x10 is AMF0 for 'typed object (class instance)'   bytes.writeUTF( fullyQualifiedName );   // After the class name is set up, write the rest of the object   bytes.writeBytes( objBytes, 1 );    // Read in the object with the class property added and return that   bytes.position = 0;    // This generates some ReferenceErrors of the object being passed in   // has properties that aren't in the class instance, and generates TypeErrors   // when property values cannot be converted to correct values (such as false   // being the value, when it needs to be a Date instead).  However, these   // errors are not thrown at runtime (and only appear in trace ouput when   // debugging), so a try/catch block isn't necessary.  I'm not sure if this   // classifies as a bug or not... but I wanted to explain why if you debug   // you might seem some TypeError or ReferenceError items appear.   var result:* = bytes.readObject();   return result; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 92k
  • Answers 93k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My best thought was pretty good. Here is a solution,… May 11, 2026 at 6:33 pm
  • Editorial Team
    Editorial Team added an answer This should work: function loadResults(){ $('div.to.update').load('yourpage.php') setTimeOut(arguments.callee, 10000) } loadResults()… May 11, 2026 at 6:33 pm
  • Editorial Team
    Editorial Team added an answer Classic ADO can manipulate very large (>8000) varbinary and image… May 11, 2026 at 6:33 pm

Related Questions

I am having a problem with binding values in my ActionScript components. I basically
I've only done a bit of Flex development thus far, but I've preferred the
In my Flex interface, I've got a few List components that are data bound
I have been developing in ActionScript 3 / Flex Builder 3 for a while

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.