I have some common code in my MXML files that I’d like to move to the MXML equivalent of a base class, then have various MXML components subclass from that. What is the syntax for doing this in MXML?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
MXML is viewed as an ActionScript generation language; and the current version of the Flex Compiler will translate MXML into ActionScript.
So, for all intents and purposes, an MXML class is no different than an ActionScript class. For inheritance purposes, an MXML Class can extend an ActionScript class–you do this every time you create a new Application file. An MXML Class can also extend another MXML class; and the approach is no different than extending an ActionScript class.
First, create your base class in whatever way you prefer. This is a sample class structure which extends a group:
Let’s assume that you named that file BaseClass.mxml and put it in the directory com.flextras . Your new class that extends the previous class will be something like this:
In Flash Builder, this is pretty easy just by doing “new –> MXML Component” inside a Flash project.