AS3 cast String as an Object

AS3 cast String as an Object

Content Index :

AS3 cast String as an Object
Tag : actionscript-3 , By : davidg
Date : November 21 2020, 04:03 PM

wish help you to fix your issue I'm trying to convert following string to an object considering the object in the string exists: , You can use a simple function like this:
function getRValue(target:Object, chain:String):*
    for each(var i:String in chain.split("."))
        if(target.hasOwnProperty(i)) target = target[i];
            // Couldn't find property.
            throw new Error("Property " + i + " does not exist.");

    return target;
var myObject:Object = {
    property1: {
        property2: "Hello world!"

trace( getRValue(this, "myObject.property1.property2") ); // Hello world!
trace( getRValue(myObject, "property1.property2") ); // Hello world!

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Why doesn't strings.Cast<object> cast List<string> to List<object>?

Tag : chash , By : baylisscg
Date : March 29 2020, 07:55 AM
I hope this helps . You're misusing Cast.
First, here:
IEnumerable<string> items = strings.Cast<object>();
// Cast to IEnumerabe<object> then convert to List<object>

Query List of Dictionary<string, object>, can't cast from object to original type

Tag : linq , By : Killercode
Date : March 29 2020, 07:55 AM
will be helpful for those in need You can simply write a helper method that ensures the type of the value prior to executing the predicate. Something like:
    public static bool CompareToObject<TSource>(TSource left, object right, Func<TSource, TSource, bool> predicate)
        if (right is TSource)
            return predicate(left, (TSource)right);
            return false;
entityProps.Where(p => CompareToObject(p[propName], value, (x, y) => x == y));

Can I cast a string object passed on command line argument to the actual object?

Tag : asp.net , By : David
Date : March 29 2020, 07:55 AM
To fix the issue you can do You probably can't, because it's a string. It's not a cProduct (whatever that is - consider following .NET naming conventions and naming it Product instead).
Now you could do this if you had a explicit conversion operator in cProduct to create an instance from a string.
Product product = new Product(objPro.CommandArgument);
Product product = Product.Parse(objPro.CommandArgument);

Can not fetch hibernate object attribute within ObjectList - java.lang.String cannot be cast to Object

Tag : java , By : Adam May
Date : March 29 2020, 07:55 AM
will help you I have the following Hibernate Object implemented: , My picklist component:
<p:pickList id="pickList" 
  value="#   {reportConfiguratorBean.dualListVars}"
  Ajax="false" >
  <f:facet name="sourceCaption">Available Variables</f:facet>
  <f:facet name="targetCaption">Associated Variables</f:facet>              
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    Long varId = Long.parseLong(value.trim());  
    List<CRVariable> cRVariables = mybean.getCRVariables();

    for (CRVariable cRVariable:cRVariables) {
            return cRVariable;

    return null;    

trying to cast an object to javascript []{}- C# Key Value Collection OR Dictionary<string,object> or<string, st

Tag : chash , By : antonio
Date : March 29 2020, 07:55 AM
This might help you I gave your sample a try and noticed that the startPrt parameter is actually being received as an Array of Dictionary(string, object). Hence, if you make the AJAX call like this:
var hDate = [];
hDate.push({ key: "Name", value: Name });
hDate.push({ key: "City", value: City });
hDate.push({ key: "Country", value: Country });
hDate.push({ key: "SelctedClass", value: selectedRC });

    contentType: 'application/json; charset=utf-8',
    url: 'MyPage.aspx/AddNewRecord',
    type: 'POST',
    data: JSON.stringify({ startPrt: hDate }),
    success: success, // success callback
    error: error // error callback
public static void AddNewRecord(object startPrt)
    var dict = new Dictionary<string, object>();
    foreach (Dictionary<string, object> pair in (Array)startPrt)
        dict.Add((string)pair["key"], pair["value"]);
Related Posts Related QUESTIONS :
Privacy Policy - Terms - Contact Us © scrbit.com