Hello,
I have a list of countries in an array collection that I want to use it in many mxml files. I want to create a header file and include it in all the mxml files. I see only actionscript include files but know how to include an array...
Thanks
Bharani
Views
Replies
Total Likes
Hi,
Take an ActionScript Class that includes array of the countries ,
take that array as static and you use that array where ever u require.
Go through the code Once.
<!--- main.mxml---->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<mx:Script>
<![CDATA[
import sample.SampleArrayHolder;
]]>
</mx:Script>
<mx:ComboBox id="cmb" dataProvider="{SampleArrayHolder.arr}" />
</mx:Application>
<!-- SampleArrayHolder.as -->
package sample
{
[Bindable]
public class SampleArrayHolder
{
public static var arr:Array=new Array("1","2","3","4","5");
public function SampleArrayHolder()
{
}
}
}
You can do this by just having an Array in an ActionScript file as well, and do not need a class.
If this post answers your question or helps, please mark it as such.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<mx:Script>
<![CDATA[
include "sample/SampleArrayHolder.as";
]]>
</mx:Script>
<mx:ComboBox id="cmb" dataProvider="{arr}" />
</mx:Application>
<!-- SampleArrayHolder.as -->
[Bindable] public static var arr:Array=new Array("1","2","3","4","5");