PDA

View Full Version : Flex 2 + AS3 Beginner question


xedarius
01-31-2007, 02:40 PM
Hi,

I'm very new to the world of Flex and Action script and I was wondering if someone could point me the right direction.

In my flex project I notice I have a mxml file which seems to contain the layout of the page. However I've created some as files with some test code. My question is;

How do I access functions written in a seperate .AS file? So I can do things like;

creationComplete="CallMyFunction();"

I realise I can embed the script into the mxml file, but that looks very messy and I plan on creating a fair bit of code.

I would be grateful for any help.

Thanks
darius

xedarius
01-31-2007, 02:44 PM
sorry to waste your time

I found this

<mx:Script source="myFunctions.as" />


sorry :)

dr_zeus
01-31-2007, 06:12 PM
You might be interested in a method for linking MXML and AS (http://www.actionscript.org/forums/showthread.php3?t=126902) that I explained in another thread.

xedarius
01-31-2007, 09:46 PM
So you get your code included by subclassing that main app? Is that correct?

I am very new to this, I come from a c++/DirectX background.

dr_zeus
01-31-2007, 11:22 PM
Normally you use of <mx:Application> in your main file, and that corresponds to the ActionScript class mx.core.Application. By subclassing Application, you can add your own code to the project and use your own tag as the root.

Additionally, since you seem to pretty new at Flex, I'll point out that <mx:Script> tags can be used for more than simple includes:

<mx:Script>
<![CDATA[

public function myFunction():void
{
//do something
}

]]>
</mx:Script>

xedarius
02-01-2007, 10:22 AM
Excellent. Thanks very much. A very warm welcome to a community I hope I can contribute towards.

Cheers
darius