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 1928604
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:59:56+00:00 2026-05-17T06:59:56+00:00

All, While this is similar to another post , that post (does not indicate

  • 0

All,

While this is similar to another post, that post (does not indicate how to perform this (if it can be done) without instantiating an object. Also, without success I have tried multiple variations on the theme of:

class[method](arg)
class[method].call(arg)
method.apply(class, arg)

I am new to Flex, but have used Reflection in both C# and Java. BTW, the code that I am attempting to get to work in Flex is mirrored in both those languages and works as expected.

Any help is appreciated,
Thanks,
Todd

Non-functioning Flex Code:

    private function ipMethodTester( ipMethodName:String,
             shouldPass:Array, shouldFail:Array):void
    {
        var message:String;
        var entry:String;
        for each(entry in shouldPass)
        {
            message = ipMethodName + ": " + entry + " should pass";
            try
            {
                Assert.assertTrue(message,
                    FieldValidator[ipMethodName](entry));
            }
            catch(e:Error)
            {
               Assert.fail(e.message + " " + message);
            }
        }
        for each(entry in shouldFail)
        {
            message = ipMethodName + ": " + entry + " should fail";
            try
            {
                Assert.assertFalse(message,
                    FieldValidator[ipMethodName](entry));
            }
            catch(e:Error)
            {
               Assert.fail(e.message + " " + message);
            }
        }
    }

Java Code:

private void ipMethodTester(final String ipMethodName,
         final String[] shouldPass, final String[] shouldFail)
{
   Method method;
   try
   {
      method = InetUtil.class.getDeclaredMethod(ipMethodName, String.class);
      method.setAccessible(true);

      for(String entry : shouldPass)
      {
         Object[] invokeArgs = { entry };
         boolean passed = (Boolean)method.invoke(null, invokeArgs);

         assertTrue(ipMethodName + ": " + entry + " should pass", passed);
      }

      for(String entry : shouldFail)
      {
         Object[] invokeArgs = { entry };
         boolean passed = (Boolean)method.invoke(null, invokeArgs);

         assertFalse(ipMethodName + ": " + entry + " should fail", passed);
      }
  }
  catch (final Exception e)
  {
     fail(e.getClass().toString());
  }
}

C# code:

    private void ipMethodTester(string ipMethodName, string[] shouldPass, string[] shouldFail)
    {
        Type type = typeof (ValidateUtil);
        BindingFlags bindingFlags = BindingFlags.InvokeMethod
            | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;

        MethodInfo method = type.GetMethod(ipMethodName, bindingFlags);

        foreach(string entry in shouldPass)
        {
            object[] invokeArgs = { entry };
            bool passed = (bool)method.Invoke(null, invokeArgs);

            Assert.IsTrue(passed, ipMethodName + ": " + entry + " should pass");
        }

        foreach(string entry in shouldFail)
        {
            object[] invokeArgs = { entry };
            bool passed = (bool)method.Invoke(null, invokeArgs);

            Assert.IsFalse(passed, ipMethodName + ": " + entry + " should fail");
        }
    }
  • 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-17T06:59:56+00:00Added an answer on May 17, 2026 at 6:59 am

    This works for me:

    MyClass['myMethod']('arg1','arg2');
    

    This also works:

    MyClass['myMethod'].call(MyClass, 'arg1', 'arg2');
    

    Note: the first argument of the ‘call’ method (MyClass in this case) just specifies which object is referenced when you use the ‘this’ keyword inside the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While I understand this question is fairly vague since I'm not giving you all
While this question asked something similar too, I'm interested in this from another angle.
All of a sudden I start getting this error while trying to open 2
Can source code examples be kept in a SQL database while retaining all formatting
While refactoring code and ridding myself of all those #defines that we're now taught
I've searched other questions and, while this problem seems similar to a couple of
We recently were given a client requirement to encrypt all their data while at
A long while back I transitioned to doing all my web application development in
While Ctrl X works fine in vim under windows, Ctrl A selects all (duh).
Of all the forms of CAPTCHA available, which one is the least crackable while

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.