Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to port a flex method #438

Closed
pashminakazi opened this issue Jul 29, 2019 · 3 comments
Closed

Unable to port a flex method #438

pashminakazi opened this issue Jul 29, 2019 · 3 comments

Comments

@pashminakazi
Copy link
Contributor

We have a method:
https://paste.apache.org/jy56s
We are calling it as : shmUtil.setForm(arrFormItems, voCompany as Object,
org.apache.royale.reflection.describeType(shmCompanySetupVO) as XML);

We have tried it using TypeDefinition Instead of XML.

When we have changed XML to TypeDefinition in method setForm(...aValueObjInfo:TypeDefinition){.....
for each (var val:TypeDefinition in aValueObjInfo..variable)
...}

I got a compile time Error as ..variable property not exist in TypeDefinition:

Access of possibly undefined property variable through a reference with static type TypeDefinition.
[java]
[java] for each (var val:TypeDefinition in aValueObjInfo..variable)

Kindly Help us to Port this method. As we are using this method in our whole Application in every file.

Thanks in Advance

@aharui
Copy link
Contributor

aharui commented Jul 30, 2019

I think the loop should be something like:

for each (var val:VariableDefinition in aValueObjInfo.variables)

@greg-dove
Copy link
Contributor

Alex is correct (this will let you loop through the public instance variable definitions).
But you will also need to make more changes inside the loop.
(assuming 'val' is a VariableDefinition in all below):
wherever you have name comparisons it should be without the '@'
instead of:
if((aFormItems[k].id == val.@name)
it should be:
if((aFormItems[k].id == val.name)

And you need to change any reflection based getting and setting...

instead of:
aFormItems[k].text = aValuObject[val.@name];

you need:
aFormItems[k].text = val.getValue(aValuObject);

Generally for getting or setting values it should be like:
var instanceVal:* = val.getValue(instance);
val.setValue(instance, valueToBeSet)

You should use the above approach instead of using instance[val.name]. (where val.name is the name of the variable in the original actionscript, and is the same value as for name in XML attribute)

The getValue/setValue approaches are important if you want to use reflection for manipulating public vars correctly in js-release build (because they are likely to be renamed by google closure compiler)

@alinakazi
Copy link
Member

Thanks issue has been fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants