Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
bendev #1
How to link a .mxml file and a .as file ?
Hello,
I don't like so much the idea about mixing action Script ( processing code )
and form description ( end user presentation) even if the tags make it proper
.... it looks that FLEX is based on taht principle and I probably need to be
used to that.
In the meantime I've looked to some ways to 'link' a formular made of a .mxml
file and a class nested in an action script file (.as file in a particular
directory, for example) But I've not found any of them.
The className is a read-only property and the compiler options look to make
the things a litlle beat difficult.
Do you know if that can be done ?
Thank you in advance
bendev Guest
-
How to see the .AS file that .MXML file is translated tobefore being compiled to SWF?
I am trying to dynamically load some other Applications in one Application, use ActionScript but not SWFLoader tag, it looks like: ... -
How to get swf file of any mxml file in flex1.5
hi all, can anybody tell i have one mxml file now when i run this i file server generate swf file dynemically ....now my requirement is i... -
how to load external html file into mxml file
hi all plz tell me how i can load external html file in mcml file just like say when we receive mail in inbox and see our mail data .. i have... -
Can I embed external MXML in another MXML file?
Hi - I'm new to this so please bear with me. I'm trying to do something like you do in JSP's with a JSP include where I can import prewritten code... -
Help needed with ASP form browse for file, create link to file and insert in access database
I have a form where a user enters their name, date etc. i also want them to be able to click on a browse button and select a file which will then... -
ntsiii #2
Re: How to link a .mxml file and a .as file ?
The best way is to put your as code into its own .as class.
You then instantiate that class in mxml, giving it an id, for example, id="fn".
You reference properties(variables and getter setter functions) and
methods(functions) lke this:
var myVar:String = fn.my/var;
var myFuncResult:String = fn.myfunc(myVar); //or whatever
This architecture has the benefit of helping to avoid the 32k limit, as well.
Let me know if you need more examples.
Tracy
ntsiii Guest
-
ntsiii #3
Re: How to link a .mxml file and a .as file ?
In fact here is an example. It has three files. A test file that uses both
class files, an ordinary class file that is instantiated in an mxml tag in the
test file, and a static class whose functionality is used without an instance.
Tracy
UtilityClassTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
<mx:Script><![CDATA[
import UtilityClassStatic
public var sAppProperty:String = "BAZ";
]]></mx:Script>
<UtilityClass id="u" app="{this}"/>
<mx:Label text="{u.getFoo()}" />
<mx:Label text="{UtilityClassStatic.getBar()}" />
</mx:Application>
UtilityClass.as
// Example utility function class for dynamic instantiation
class UtilityClass
{
public var app:UtilityClassTest;
public function getFoo():String{
return "FOO" + app.sAppProperty;
}
}//UtilityClass
UtilityClassStatic.as
// Example utility function class for Static reference
class UtilityClassStatic
{
public static function getBar():String{
return "BAR";
}
}//UtilityClassStatic
ntsiii Guest
-
bendev #4
Re: How to link a .mxml file and a .as file ?
Hello,
Thank you ... That's really what I was looking for.
I just add a little comment : if you describe the namespace of the package
where you actionScript file is :
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
xmlns:myNameSpace="myDir.*">
then you will instance the class with :
<myNameSpace:myClass id="u" app="{this}"/>
Oh myDir !
Bye for now
bendev Guest



Reply With Quote

