<p>I have an actionscript file that defines a class that I would like to use inside a Flex application. </p>

<p>I have defined some custom controls in a actionscript file and then import them via the application tag:</p>

<pre>
<code>
&lt;mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:scorecard="com.apterasoftware.scorecard.controls.*"
...
&lt;/mx:Application&gt;
</code>
</pre>

<p>but this code is not a flex component, rather it is a library for performing math routines, how do I import this class?</p>

[{'answer_id': 39864, 'author': 'Herms', 'author_id': 1409, 'author_profile': 'https://Stackoverflow.com/users/1409', 'pm_score': 4, 'selected': True, 'text': '<p>You\'d need to import the class inside a script tag.</p>\n\n<pre><code>&lt;mx:Application\n  xmlns:mx="http://www.adobe.com/2006/mxml"&gt;\n  &lt;mx:Script&gt;\n    import com.apterasoftware.scorecard.controls.*;\n    // Other imports go here\n\n    // Functions and other code go here\n  &lt;/mx:Script&gt;\n\n  &lt;!-- Components and other MXML stuff go here --&gt;\n  &lt;mx:VBox&gt;\n    &lt;!-- Just a sample --&gt;\n  &lt;/mx:VBox&gt;\n&lt;/mx:Application&gt;\n</code></pre>\n\n<p>Then you\'ll be able to reference that class anywhere else in your script tag.  Depending on how the class is written you may not be able to use binding within the MXML, but you could define your own code to handle that.</p>\n\n<p>Namespace declarations are only used to import other MXML components.  AS classes are imported using the import statement either within a Script block or another AS file.</p>\n'}, {'answer_id': 400550, 'author': 'Niko Nyman', 'author_id': 36817, 'author_profile': 'https://Stackoverflow.com/users/36817', 'pm_score': 0, 'selected': False, 'text': '<p>@Herms: To clarify a little, namespace declarations can be used to "import" AS classes as well, when you\'re going to instantiate them using MXML.</p>\n\n<p>For example, consider having a custom visual component you\'ve written entirely in AS, let\'s say <code>com.apterasoftware.scorecard.controls.MathVisualizer</code>. To use it within MXML:</p>\n\n<pre><code>&lt;mx:Application\n    xmlns:mx="http://www.adobe.com/2006/mxml"\n    xmlns:aptera="com.apterasoftware.scorecard.controls.*"&gt;\n\n    &lt;aptera:MathVisualizer width="400" height="300" /&gt;\n&lt;/mx:Application&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/39856', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1638/']