Hello
Hello

Reputation: 2265

How to attach actionscript file to mxml?

mxmlc HelloWorld.mxml

How can I import the *.as file while compiling the mxmlc?

Upvotes: 1

Views: 770

Answers (2)

I am just wondering why can't you use the import or include command inside your MXML code.

include "your_script.as";

import yourpackage.your_script.myFunc;

Docs -> http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf61c8a-7ff4.html

Upvotes: 1

Adrian Pirvulescu
Adrian Pirvulescu

Reputation: 4340

See below sample code

<?xml version="1.0" encoding="utf-8"?>
<s:Application 
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx" 
    minWidth="955" 
    minHeight="600"
    >

    <fx:Script
        source  = "FooScript.as"/>

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Button x="355" y="515" width="218" id="btn" label="परिचय"/>

</s:Application>

Please note that Foo.mxml and FooScript.as are in the same package.

Upvotes: 1

Related Questions