开发者

Separate script files in ActionScript?

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 sep开发者_运维技巧arate files. Is that possible? if so how?

Thank you


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜