tags:

views:

12

answers:

1

Hi all,

I am new to flex development. Have my share of experience in asp.net though. I am looking for the equivalent of external js script files. My current situation consists of the following:

I have a lot of script code (), and I'd like to tidy it up a bit. Perhaps by putting them in separate files. Is that possible? if so how?

Thank you

+2  A: 

you can use the include keyword. This allows you to split you code into smaller chunks across files.

Be aware this is different than creating a class and importing it.

include "my_file.as";

be aware if you are not using relative file locations, the include is operating system dependant. This includes windows/mac/linus directory separators.

-- extended

@DoubleThink - Your comment is rude. There is no 'ofcourse no' - Not constructive dude.

@vondip - try to think of it as cutting up the code within the script tags, rather than doing this with the mxml.

You would probably write something more along the lines of:

<fx:script>
    include 'interfaceHandlers.as';
    include 'animationFunctions.as';
    include 'externalCalls.as';
    //... etc
</script>

therefore you only have one script block in you mxml you've added to set your includes.

You'll probably discover, as you progress you'll lean towards using more classes and one controller. Bypassing the need to use many many functions and cutting up your code by using imported classes you've built to handle various small tasks. This is the more OOP way of life and it'll uber help when you debug one day.

Glycerine
interesting. Can I write <fx:script> blocks inside a regular action script file?
vondip
@vondip: ofcourse no
DoubleThink
sorry for stupid questions, still very novice to flex. Then how can I divide my fx:script to multiple files to make it more tidy?
vondip
@Glycerine Gr8, thank you very much
vondip