0
votes

I made a new as3 file from flash builder added this code :

import flash.external.ExternalInterface;
public function alfa() : void{
 var someVarInAS : String = 'foo';
 var someOtherVarInAS : int = 10;
 var jsXML : XML = 
    <script type="text/javascript">
    var someVarInJS = '{someVarInAS}';
    var someOtherVarInJS = {someOtherVarInAS};
    <![CDATA[
        //here be code
        alert( 'this comes from flash: ' + someVarInJS + ', ' + someOtherVarInJS );
    ]]>
</script>;

ExternalInterface.call( "function js_getData(){ " + jsXML + " }" );
}

And in the mxml this code in fxscript tag :

<fx:Script>
    <![CDATA[
    include "web.as";
    alfa();
    ]]>
</fx:Script>

Now it gives me this error : Description Resource Path Location Type 1180: Call to a possibly undefined method alfa. omega.mxml /live_broadcast/src line 29 Flex Problem

They are both in the same "default_package" and if i don't put a function and let the code by itself it works wonderfull but i would like a function.

I am new to this flash thing so if anyone can make me understand why it says that? Thank you.

1

1 Answers

0
votes

Because Flash i don't know from where it had this BEAUTIFUL idea of not being able to call you'r own function at the beginning this how i should have done it.

First add initialize="init()" to the < s: Application then

    private function init():void
    {
        alfa();
    }

Where alfa() is your function, you can add as many as you like.