This content has been marked as final. Show 6 replies
An ActionScript class is in an .as file, but because it includes the "package" specifier, and because it contains a class definition, it contributes to the structure of your program, and allows you to define custom types (classes).
An ActionScript file (.as file) for this discussion is a .as file that does not have a class defined in it. So you might just define an Array collection, or some embedded images, or some utility methods. Then you use "include" so the code can be used in your code.
Sometimes I put my embedded image definitions in a .as file, so my app file is less cluttered.
Any chance you could post the full source code for both your AS class and your MXML file?
That said, is there any change that your MXML file is named LoginMaster.mxml? It's a long shot, I know, but if it is, then LoginMaster is not referring to your AS class, but to your MXML component class. In the former, the property LGMST_CMPN_NO refers to a String, but in the latter, a property with the same name refers to a TextInput, and the error you receive is exactly what you get when you accidentally try to assign a String value to a TextField.
Your guess is correct, MXML file is named as LoginMaster.mxml and my ActionScript class as LoginMaster.as
Please excuse me for asking this dumb question, Since I am very much new to flex and action script.
So we can't have the mxml and actionscript file with same name ?
I can post the full code, but I assume that having same name might be the problem.
If we can have the same name, then let me know so I will post the full code.
My AS class code is posted in my previous reply.
They can have the same name, but it's not advisable, because you tend to run into this kind of problem. The issue is scope. Your error is occurring on this line:
loginMaster= new LoginMaster;
It's really important to remember here that every MXML file is pre-compiled into an ActionScript class, and MXML components are referenced by the rest of the system in exactly the same manner as ActionScript classes--because they are, in fact, ActionScript classes.
So when you say "new LoginMaster", the compiler has to find a class named LoginMaster. At this point the compiler isn't aware of which classes started life as MXML components; they're all classes now. So the compiler will pick the definition of LoginMaster that's in scope--nearest at hand--which, because you're actually writing this line within the MXML component class LoginMaster, resolves to this component class itself, not your other class, in a different package, that also happens to share the same name.
There are ways around this, but I have to strongly advise you not to have AS classes and MXML components with the same name, or you'll find yourself continually encountering hard-to-diagnose problems like this one. If you simply renamed your AS class something like LoginMasterModel, or your MXML component LoginMasterView, these problems would go away. Your code will also be a lot easier for others to understand in the future.
Hope that helps, and sorry for the delay in responding--I just found a whole bunch of Adobe Forum notifications in my Yahoo spam folder, so I'm catching up on several threads that I thought were dormant.
Thanks for your reply, I will make sure that I use different name for MXML and actionscript class.