frasseff
01-03-2009, 08:39 PM
Hi all
I have a Bindable string from a Class Ihave made. I want to send it as prameter to a function in my mxml file. How can I do that ?
I am doing the following but it is not working ("initApp('{mypara}')").
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:components="components.*" applicationComplete="initApp('{mypara}')">
<mx:Binding source="dipclasses.conf.GETALLLANDPOLY" destination="mypara" />
<mx:Script>
<![CDATA[
import dipclasses.conf
[Bindable]
public var mypara:String;
public function initApp(method:String): void
{
var netConnection:NetConnection = new NetConnection();
netConnection.connect(conf.URL);
var responder:Responder = new Responder(onComplete, onFail);
netConnection.call(method, responder);
}
function onComplete(results) {
var res:Object= results;
//UserMessage.text += results;
for (var r:Object in res)
{
UserMessage.text += r + res[r];
}
}
function onFail(results) {
for each (var thisResult in results){
UserMessage.text += thisResult;
}
}
private function mapMousOver(event:MouseEvent):void
{
var cor:String;
cor = "X: " + event.localX.toString() + " Y: " + event.localY.toString() + "\n";
CommandMessage.text += cor;
}
]]>
</mx:Script>
<mx:HBox x="0" y="0" width="100%" height="100%" backgroundColor="#050505" color="#EDF5F7">
<mx:VBox>
<mx:Image id="map" source="images/standard.gif" mouseMove="mapMousOver(event)" click="mapMousOver(event)"/>
<mx:HBox>
<mx:RichTextEditor title="Message To Player" height="273" width="336"
color="#790404" fontWeight="bold"
headerColors="[#e4e4e0,#eeeeee]"
footerColors="[#eeeeee,#e4e4e0]">
</mx:RichTextEditor>
<mx:VBox>
<components:userList/>
</mx:VBox>
</mx:HBox>
</mx:VBox>
<mx:VBox>
<mx:Label text="Move Command:" fontWeight="bold" />
<components:orderBox/>
<mx:TextArea id="CommandMessage" width="496" height="201" color="#790404" />
<mx:Button label="Send order" width="496" click="initApp('{mypara}')"/>
<mx:Label text="New Units :" fontWeight="bold" />
<mx:HBox>
<mx:Image source="images/ab-40.gif"/>
<mx:Image source="images/ch_b1_bis.gif"/>
</mx:HBox>
<mx:Label text="News :" fontWeight="bold" />
<mx:TextArea width="503" height="46" color="#790404" />
<mx:Label text="User Message:" fontWeight="bold" />
<mx:TextArea id="UserMessage" width="506" height="212" color="#790404" />
</mx:VBox>
</mx:HBox>
</mx:Application>
My class look like this
package
{
public class conf
{
public static var URL:String = "MyURL";
public static var METHODPREFIX:String = "exposed.";
[Bindable]
public static var GETALLLANDPOLY:String= METHODPREFIX + "getAllLandpoly";
public function conf()
{
}
}
}
Thanx
Frasse
I have a Bindable string from a Class Ihave made. I want to send it as prameter to a function in my mxml file. How can I do that ?
I am doing the following but it is not working ("initApp('{mypara}')").
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:components="components.*" applicationComplete="initApp('{mypara}')">
<mx:Binding source="dipclasses.conf.GETALLLANDPOLY" destination="mypara" />
<mx:Script>
<![CDATA[
import dipclasses.conf
[Bindable]
public var mypara:String;
public function initApp(method:String): void
{
var netConnection:NetConnection = new NetConnection();
netConnection.connect(conf.URL);
var responder:Responder = new Responder(onComplete, onFail);
netConnection.call(method, responder);
}
function onComplete(results) {
var res:Object= results;
//UserMessage.text += results;
for (var r:Object in res)
{
UserMessage.text += r + res[r];
}
}
function onFail(results) {
for each (var thisResult in results){
UserMessage.text += thisResult;
}
}
private function mapMousOver(event:MouseEvent):void
{
var cor:String;
cor = "X: " + event.localX.toString() + " Y: " + event.localY.toString() + "\n";
CommandMessage.text += cor;
}
]]>
</mx:Script>
<mx:HBox x="0" y="0" width="100%" height="100%" backgroundColor="#050505" color="#EDF5F7">
<mx:VBox>
<mx:Image id="map" source="images/standard.gif" mouseMove="mapMousOver(event)" click="mapMousOver(event)"/>
<mx:HBox>
<mx:RichTextEditor title="Message To Player" height="273" width="336"
color="#790404" fontWeight="bold"
headerColors="[#e4e4e0,#eeeeee]"
footerColors="[#eeeeee,#e4e4e0]">
</mx:RichTextEditor>
<mx:VBox>
<components:userList/>
</mx:VBox>
</mx:HBox>
</mx:VBox>
<mx:VBox>
<mx:Label text="Move Command:" fontWeight="bold" />
<components:orderBox/>
<mx:TextArea id="CommandMessage" width="496" height="201" color="#790404" />
<mx:Button label="Send order" width="496" click="initApp('{mypara}')"/>
<mx:Label text="New Units :" fontWeight="bold" />
<mx:HBox>
<mx:Image source="images/ab-40.gif"/>
<mx:Image source="images/ch_b1_bis.gif"/>
</mx:HBox>
<mx:Label text="News :" fontWeight="bold" />
<mx:TextArea width="503" height="46" color="#790404" />
<mx:Label text="User Message:" fontWeight="bold" />
<mx:TextArea id="UserMessage" width="506" height="212" color="#790404" />
</mx:VBox>
</mx:HBox>
</mx:Application>
My class look like this
package
{
public class conf
{
public static var URL:String = "MyURL";
public static var METHODPREFIX:String = "exposed.";
[Bindable]
public static var GETALLLANDPOLY:String= METHODPREFIX + "getAllLandpoly";
public function conf()
{
}
}
}
Thanx
Frasse