change protocol of endpoint in AMFChannel, how to fix it? - actionscript-3

I am working on Flex and I find that when I give uri(https://jsonplaceholder.typicode.com/posts/1) to AMFChannel which content 'HTTPS' protocal but calculateEndpoint() method of Channel class change protocol from "HTTPS" to "HTTP".
I also made simple project to demonstrate how endpoint gets changed by AMFChannel.
<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script><![CDATA[
import mx.controls.Alert;
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.AbstractOperation;
import mx.rpc.remoting.mxml.RemoteObject;
private function button1_clickHandler(event:MouseEvent):void
{
var amfChannelWeb:AMFChannel = new AMFChannel("amfChannel", txtInput.text);
var remoteObj:RemoteObject = new RemoteObject();
remoteObj.showBusyCursor = true;
remoteObj.requestTimeout = 0;
var channelSet = new ChannelSet();
channelSet.channels = [amfChannelWeb];
remoteObj.destination = "amfphp";
remoteObj.channelSet = channelSet;
var op:AbstractOperation = remoteObj.getOperation("testAmfData");
op.send();
op.addEventListener("result", resultHandler);
op.addEventListener("fault", resultFaultHandler);
lblEndpoint.text = amfChannelWeb.endpoint;
}
private function resultHandler(e:Event):void
{
lblChannelError.text = e.toString();
}
private function resultFaultHandler(e:Event):void
{
lblChannelError.text = e.toString();
}
]]></fx:Script>
<s:VGroup width="100%">
<s:TextInput width="80%" id="txtInput" text="https://jsonplaceholder.typicode.com/posts/1"/>
<s:Button click="button1_clickHandler(event)" label="Click"/>
<s:Label id="lblEndpoint"/>
<s:Label id="lblChannelError"/>
</s:VGroup>
Is this issue or am I doing somthing wrong??

Instead of AMFChannel use SecureAMFChannel as below
var amfChannelWeb:SecureAMFChannel = new SecureAMFChannel("amfChannel", txtInput.text);

Related

itemRenderer is getting changed in the rows of a MX datagrid when scrolling

I am having a bad time with this itemRenderer.
I have an MX DataGrid that I am using to show some data I am collecting with an HTTP service. I wanted to show some data as a "preview" in the first column and I adding an itemRenderer with DataGridColum.itemRenderer property. Everything here works fine.
<mx:DataGrid id="labelsGrid" width="100%" height="100%" visible="false"
variableRowHeight="true" sortableColumns="false">
<mx:columns>
<mx:DataGridColumn headerText="Preview" dataField="recordid"
width="{ preview_column_width }" itemRenderer="us.lbs.itemRenderers.preview"/>
<mx:DataGridColumn headerText="Design id" dataField="label_id" />
<mx:DataGridColumn headerText="Font size" dataField="label_minheight"/>
<mx:DataGridColumn headerText="Width" dataField="label_width"/>
<mx:DataGridColumn headerText="Height" dataField="label_height"/>
<mx:DataGridColumn headerText="Label P/N" dataField="label_pn"/>
<mx:DataGridColumn headerText="Font type" dataField="label_fonttype"/>
<mx:DataGridColumn headerText="Qty" dataField="label_qty"/>
</mx:columns>
</mx:DataGrid>
and here is my code for the itemRenderer
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%"
horizontalAlign="center" verticalAlign="middle" creationComplete="init( )">
<fx:Style>
#namespace mx "library://ns.adobe.com/flex/mx";
#namespace s "library://ns.adobe.com/flex/spark";
</fx:Style>
<fx:Script>
<![CDATA[
import aw.utils.StringUtils;
import flashx.textLayout.edit.SelectionFormat;
import flashx.textLayout.formats.TextLayoutFormat;
import mx.binding.utils.BindingUtils;
import mx.binding.utils.ChangeWatcher;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.events.FlexEvent;
import mx.events.ModuleEvent;
import mx.geom.RoundedRectangle;
import mx.managers.PopUpManager;
import mx.messaging.messages.IMessage;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ColorUtil;
import mx.utils.ObjectUtil;
import mx.utils.StringUtil;
import spark.components.Application;
import us.lbs.viewer;
public var dad:viewer = null;
public var zoom:int = 2;
public var px_in:Number = 96;
public var pt_px:Number = 1.333333333333333;
[Bindable]public var var_width:Number = 0;
[Bindable]public var var_height:Number = 0;
[Bindable]public var var_font_size:Number = 12;
[Bindable]public var tmp_lines:String = "";
public function init( ):void {
settingDad( ); setSize( ); setFontSize( ); fixLines( );
}
protected function settingDad():void {
dad = this.parentDocument as viewer;
if ( typeof( dad.previewers[ data.label_id ] ) != 'object' ) {
dad.previewers[ data.label_id ] = {};
dad.previewers[ data.label_id ].preview = this;
/*Alert.show(
this.data.label_id + "\n" +
"Type: " + typeof( dad.previewers[ data.label_id ].preview ),
this.data.rm_pn
);*/
}
}
protected function setFontSize( ):void {
var_font_size = data.label_minheight * pt_px * zoom;
var_font_size = Math.round( var_font_size );
}
protected function setSize( ):void {
var_width = Number( data.label_width ) * px_in * zoom;
var_height = Number( data.label_height ) * px_in * zoom;
dad.labelsGrid.visible = true;
dad.preview_column_width = ( var_width > dad.preview_column_width ) ? var_width:dad.preview_column_width;
}
protected function fixLines( ):void {
tmp_lines = ""; var lines:Array = String( data.lines ).split( "//" );
for each ( var line:String in lines ) {
tmp_lines += StringUtils.trim( line ) + "\n";
} tmp_lines = StringUtils.trim( tmp_lines );
}
]]>
</fx:Script>
<s:HGroup >
<s:RichEditableText
id="previewTxt"
backgroundColor="white"
text="{ tmp_lines }"
selectionHighlighting="always" editable="false" selectable="true"
width="{ var_width }" height="{ var_height }"
kerning="on"
fontSize="{ var_font_size }" fontFamily="{ data.label_fonttype }"
paddingTop="0" paddingBottom="0" paddingLeft="0" paddingRight="0"
textAlign="center" verticalAlign="middle" focusedTextSelectionColor="0xA8C6EE"
selectionChange="dad.previewTxtSelectionChange(event)" />
</s:HGroup>
The code I shared with you above is generating this ( which is good ):
So, my issue here is that when I scroll down the datagrid, I am getting the Previews changed, like this:
The only value that has changed is the first column, everything is like it was before scrolling.
Why is happening this?
Sorry if I haven't written enough details, I think this is enough... but ask me if more details are needed.
Thanks in advance!
Renderization uses a buffer, so you must link directly your property and its change.
Try this:
Link text property to fixLines method, as follow
in <s:RichEditableText> put in the property text this:
text = "{fixLines(data)}"
Change your method as follow:
protected function fixLines(obj:Object):String {
if (obj == null) return "";
var currText = "";
var lines:Array = String( obj.lines).split( "//" );
for each ( var line:String in lines ) {
currText += StringUtils.trim( line ) + "\n";
}
currText = StringUtils.trim( tmp_lines );
return currText;
}
In your init method, where you call fixLines, change as follow:
public function init( ):void {
settingDad( ); setSize( ); setFontSize( ); fixLines(data);
}
Tell me if it's OK

Flex/AIR: Native drag'n'drop on sub-application triggers wrong event handlers

I have two Flex applications (App1, App2) that I want to use as separate apps (no problem here) but the first app should also be able to load the second app in its window (no problem either). Both apps accept native drag'n'drop (onDragIn, onDragDrop). However, when I load App2 as sub-application (multi-versioned) its drag'n'drop handlers are not being called but instead those of App1. What am I missing here?
<!-- MAIN APP (App1) -->
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="onComplete()">
<fx:Script>
<![CDATA[
import mx.controls.SWFLoader;
import mx.events.FlexEvent;
import mx.managers.DragManager;
internal var app2:App2=null;
internal var _show2nd:Boolean=false;
protected function onComplete():void
{
addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, onDragIn);
addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onDragDrop);
var context:LoaderContext = new LoaderContext();
context.securityDomain = SecurityDomain.currentDomain;
context.applicationDomain = new ApplicationDomain();
if (app2 == null) app2 = new App2();
contentLoader.loadForCompatibility = true;
contentLoader.loaderContext = context;
}
private function onDragIn(e:NativeDragEvent):void
{
if (e.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT) &&
(e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array).length > 0)
DragManager.acceptDragDrop(this);
}
private function onDragDrop(e:NativeDragEvent):void
{
var a:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
(File(a[0]).extension == 'a') ? doThis() : doThat();
}
public function get show2nd():Boolean
{
return _show2nd;
}
public function set show2nd(b:Boolean):void
{
if (!b)
{
_show2nd = false;
contentLoader.unloadAndStop();
return;
}
contentLoader.source = app2;
_show2nd = true;
}
]]>
</fx:Script>
<s:Button click="{show2nd = !show2nd}"/>
<mx:SWFLoader id="contentLoader"/>
</s:WindowedApplication>
<!-- SUB APP (App2) -->
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="onComplete()">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.managers.DragManager;
protected function onComplete():void
{
addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, onDragIn);
addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onDragDrop);
}
private function onDragIn(e:NativeDragEvent):void
{
if (e.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT) &&
(e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array).length > 0)
DragManager.acceptDragDrop(this);
}
private function onDragDrop(e:NativeDragEvent):void
{
var a:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
(File(a[0]).extension == 'a') ? doThis() : doThat();
}
]]>
</fx:Script>

How to Access buttons and labels of one mxml file from another mxml file

I m completely fresher in Flex Programming,
I have a FileUploadPanel.mxml which contains functionality of uploading, deleting and viewing one file only.. Now i need to modify the application to accommodate multiple attachments facility, So i created another panel ie MultiFileUpload.mxml, which has the functionality to get all attachment in form of List of Objects , and for each object-id I need to call the previous File Upload Panel, Every Thing is Working fine, but when i am accessing buttons and Labels of FileUpload.mxml it is throwing error:
1009- cannot access property and method of null object reference.
code FileUploadPanel.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="492" height="46" >
<mx:Label x="0" y="4" text="File Attachment:"/>
<mx:Button x="93.5" y="2" label="Browse" id="btnBrowseView" click="__onBrowse();" enabled="true" width="67"/>
<mx:Text x="264.5" y="4" width="100%" id="lbUploadFile" height="18 " />
<mx:Button x="165" y="2" label="Upload" id="btnUpload" enabled="true" click="reserveAttachment();" width="67"/>
<mx:Text x="10" y="25" width="100%" height="18" id="__status__" fontWeight="bold" color="#023AF1"/>
<mx:Script>
<![CDATA[
public function SetAttachmentID(anAttachmentID: Number): void
{
this.AttachmentID = anAttachmentID;
lbUploadFile.text = ""; //here i am getting error
__status__.text = "";
if (AttachmentID != -1)
{
m_data = new DocumentsAdt();
m_data.ConnectionIndex = ConnectionIndex;
m_data.OnLoadData = this.OnDoxLoaded;
m_data.LoadFromWebService(AttachmentID);
btnBrowseView.label = "View";
btnUpload.label = "Delete";
btnUpload.enabled = true;
btnUpload.visible = true;
}
else
{
btnBrowseView.label = "Browse";
btnUpload.visible = false;
btnUpload.label = "Upload";
btnUpload.enabled = false;
Init();
}
}
</mx:Script>
</mx:Canvas>
Code MuliFileUpload.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" xmlns:BoycePanels="BoycePanels.*" xmlns:ns1="com.flextoolbox.controls.*" xmlns:ns2="com.adobe.flex.extras.controls.*" xmlns:ns3="BoycePanels.*">
<mx:Script>
<![CDATA[
import Adt.Attachments.DocumentsAdt;
import com.boycepensions.DocumentsService.DocumentsService;
import com.boycepensions.DocumentsService.GetDocumentsRecordResultEvent;
import mx.collections.ArrayCollection;
private var m_data: DocumentsAdt = null;
import mx.rpc.events.FaultEvent;
import BoycePanels.FileUploadPanel;
import mx.controls.Alert;
public var ConnectionIndex: int = new int(0);
public var AttachmentID: Number = new Number(-1);
public var acDocList:ArrayCollection=null;
public function Init():void
{
getDocs_Test();
}
public function getDocs_Test():void
{
blah..blah..blah..
}
public function OnGetDocumentsRecord(event:GetDocumentsRecordResultEvent): void
{
var acDocList:ArrayCollection=new ArrayCollection();
var m_data:DocumentsAdt=new DocumentsAdt();
if (!CheckResult(event.result))
return;
else
{
acDocList=m_data.LoadDocumentsFromXML(event.result);
for each(var obj:DocumentsAdt in acDocList)
{
var pnl:FileUploadPanel=new FileUploadPanel();
//pnl.OnReserveAttachmentDone=OnReserveAttachment;
pnl.Init();
pnl.SetAttachmentID(obj.Document_ID); //here it is throwing error
}
}
}
Please suggest, i have already spent days and hours on it..
You try to access lbUploadFile when it hasn't been initialized. So if you want the FileUploadPanel show on Stage, try add it to stage before call SetAttachmentID function, like this.
var pnl:FileUploadPanel=new FileUploadPanel();
this.addChild(pnl);//add it to where you want
If the pnl needn't show on stage, remove the lines where access the children.

In label, value is not displaying which is used in module

I am trying to call a function (having two parameters) of module and assign values to it.
I can see the value being assigned in trace, but the same value is not displaying when it is assigned to label.
If I directly assign the value to label. It says:
Error:1009: Null object Reference
If I use [Bindable] meta tag to that label, it won't show any runtime error but the value is also not displayed. I have searched the internet and found that the [Bindable] meta tag works as try and catch blog.
How to get value display assign to label?
Main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:custom="com.custom.*" xmlns:local="*" creationComplete="onload()">
<mx:Script>
<![CDATA[
import modules.AModule;
import mx.events.ModuleEvent;
import mx.containers.VBox;
import mx.containers.TitleWindow;
import mx.controls.TextInput;
import mx.controls.Button;
import mx.containers.HBox;
import mx.controls.Label;
import mx.events.CloseEvent;
import mx.controls.Text;
import com.custom.CustomAlert;
import mx.controls.Alert;
import mx.containers.Canvas;
import mx.events.ItemClickEvent;
import mx.core.UIComponent;
import mx.modules.ModuleManager;
import mx.modules.IModuleInfo;
import mx.containers.Box;
import mx.controls.ProgressBar;
//private var can:Canvas;
public var titlewin:TitleWindow = new TitleWindow();
public var usern:TextInput = new TextInput();
public var passw:TextInput = new TextInput();
public var vb:VBox = new VBox();
public var hb1:HBox = new HBox();
public var hb2:HBox = new HBox();
public var hb3:HBox = new HBox();
public var nc:NetConnection;
public var bt1:Button = new Button();
private var pb:ProgressBar;
private var progressContainer:Box;
private var info:IModuleInfo;
private var module:UIComponent = null;
public var can:Canvas= new Canvas();
public function onload():void
{
var label1:Label= new Label();
var label2:Label= new Label();
label1.text="Username";
label2.text="Password ";
hb1.addChild(label1);
hb1.addChild(usern);
hb2.addChild(label2);
hb2.addChild(passw);
vb.addChild(hb1);
vb.addChild(hb2);
bt1.label="Sign In";
hb3.addChild(vb);
hb3.addChild(bt1);
titlewin.addChild(hb3);
//Title Window creation starts here
titlewin.title="Login";
titlewin.setStyle("paddingLeft",20);
titlewin.setStyle("paddingRight",20);
titlewin.setStyle("paddingTop",20);
titlewin.setStyle("paddingBottom",20);
titlewin.setStyle("borderThicknessBottom",0);
titlewin.setStyle("borderThicknessLeft",0);
titlewin.setStyle("borderThicknessRight",0);
titlewin.setStyle("borderThicknessTop",0);
titlewin.setStyle("cornerRadius",0);
titlewin.setStyle("borderColor","#D20101");
this.addChild(titlewin);
viewStack.enabled=false;
ctbb.enabled=false;
bt1.addEventListener(MouseEvent.CLICK, netconn);
}
private function onclick():void
{
if(usern.text!="")
{
this.removeChild(titlewin);
viewStack.enabled=true;
ctbb.enabled=true;
username.text=usern.text;
}
else
{
Alert.show("Please enter Username");
}
}
private function netconn(event:MouseEvent):void
{
nc = new NetConnection();
nc.connect("rtmp://localhost/loginhere",usern.text);
nc.addEventListener(NetStatusEvent.NET_STATUS, onstatushandler);
}
private function onstatushandler(event:NetStatusEvent):void
{
if(event.info.code=="NetConnection.Connect.Success")
{
status.text="Connected";
onclick();
}
if(event.info.code=="NetConnection.Connect.Rejected")
{
status.text="Rejected";
}
if(event.info.code=="NetConnection.Connect.Failed")
{
status.text="Failed";
}
}
private function JoinClick(event:MouseEvent):void{
if(viewStack.numChildren==3)
{
Alert.show("You Cant Add More Button","Alert");
}
if(viewStack.numChildren<3)
{
if(viewStack.numChildren<2)
{
can.label="Button2";
var button1:CustomButton= new CustomButton();
button1.label="Leave Table";
button1.x=300;
button1.y=200;
var txt:Text = new Text();
txt.text=can.label;
txt.x=50;
txt.y=50;
button1.addEventListener(MouseEvent.CLICK,remove2);
can.addChild(button1);
can.addChild(txt);
loadmodule();
}
else
{
can.label="Button3";
var button2:CustomButton= new CustomButton();
button2.label="Leave Table";
button2.x=300;
button2.y=200;
button2.addEventListener(MouseEvent.CLICK,remove3);
can.addChild(button2);
var txt1:Text = new Text();
txt1.text=can.label;
txt1.x=50;
txt1.y=50;
can.addChild(txt1);
}
can.setStyle("backgroundColor","0x5EA5BA");
viewStack.addChild(can);
if(viewStack.numChildren>2)
{
viewStack.selectedIndex=2;
}
else
{
viewStack.selectedIndex=1;
}
}
}
private function remove2(event:MouseEvent):void{
Alert.show("Do you want to Leave Table?","Confirmation",Alert.YES|Alert.NO,this,closeAlert2);
}
private function closeAlert2(event:CloseEvent):void{
if(event.detail==Alert.YES)
{
viewStack.removeChildAt(1);
}
}
private function remove3(event:MouseEvent):void{
if(viewStack.numChildren>2)
{
Alert.show("Do You want to leave Table?","Confirmation",Alert.YES|Alert.NO,this,closeAlert3);
}
else
{
Alert.show("Do you want to Leave Table?","Confirmation",Alert.YES|Alert.NO,this,closeAlert1);
}
}
private function closeAlert1(event:CloseEvent):void{
if(event.detail==Alert.YES)
{
viewStack.removeChildAt(1);
}
}
private function closeAlert3(event:CloseEvent):void{
if(event.detail==Alert.YES)
{
viewStack.removeChildAt(2);
}
}
private function loadmodule():void
{
pb = new ProgressBar();
pb.labelPlacement = "center";
pb.label = "Loading %3 %";
progressContainer = new Box();
progressContainer.percentWidth = 100;
progressContainer.percentHeight = 100;
progressContainer.setStyle("horizontalAlign", "center");
progressContainer.setStyle("verticalAlign", "middle");
progressContainer.addChild(pb);
can.addChild(progressContainer);
var moduleUrl:String="../bin-debug/modules/useModule.swf";
info=ModuleManager.getModule(moduleUrl);
if(info!=null)
{
info.addEventListener(ModuleEvent.READY, modEventHandler);
info.addEventListener(ModuleEvent.ERROR,modErrorHandler);
info.load();
}
}
private function modEventHandler(e:ModuleEvent):void
{
info.removeEventListener(ModuleEvent.READY, modEventHandler);
info.removeEventListener(ModuleEvent.ERROR, modErrorHandler);
can.removeAllChildren();
if(module==null)
{
module = info.factory.create() as UIComponent;
if(module!=null)
{
module.x=0;
module.y=0;
module.percentWidth=100;
module.percentHeight=100;
can.addChild(module);
if(module is AModule)
{
}
}
}
}
private function modErrorHandler(event:ModuleEvent):void {
//cleanup and display an error alert
info.removeEventListener(ModuleEvent.READY, modEventHandler);
info.removeEventListener(ModuleEvent.ERROR, modErrorHandler);
info = null;
Alert.show(event.toString(), "Error Loading Module");
unloadModule();
}
private function unloadModule():void
{
can.removeAllChildren();
if (module != null && info != null) {
info.addEventListener(ModuleEvent.UNLOAD, unloadEventHandler);
info.unload();
}
}
private function unloadEventHandler(e:ModuleEvent):void
{
info.removeEventListener(ModuleEvent.UNLOAD, unloadEventHandler);
module = null;
info = null;
}
]]>
</mx:Script>
<mx:Canvas width="700" height="400" x="166" y="32">
<mx:ViewStack id="viewStack" width="100%" height="100%">
<mx:Canvas label="Button1" backgroundColor="#5EA5BA" visible="true" id="can1" >
<local:CustomButton label="Join" click="JoinClick(event)" x="536" y="222"/>
<mx:Label x="304" y="120" text="Label" id="username"/>
<mx:Label x="304" y="55" text="Label" id="status"/>
</mx:Canvas>
</mx:ViewStack>
</mx:Canvas>
<custom:CustomControlBar x="166" y="423" id="ctbb">
<custom:CustomToggleButtonBar dataProvider="viewStack"/>
</custom:CustomControlBar>
</mx:Application>
useModule.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="508" height="218" implements="modules.AModule" backgroundColor="#F00F0F" creationComplete="addlabel();">
<mx:Script>
<![CDATA[
import mx.core.Application;
public var logsin:loginhere = new loginhere();
public function addlabel():void
{
lb1.text=logsin.username.text;
txt3.text=logsin.username.text;
trace(txt3.text);
trace(lb1.text);
}
]]>
</mx:Script>
<mx:TextInput id="txt3" x="30.5" y="10" width="79"/>
<mx:Label id="lb1" x="31.5" y="40" width="78" text="Will it Change?"/>
</mx:Module>
AModule.as (Its an interface)
package modules
{
import flash.events.IEventDispatcher;
public interface AModule extends IEventDispatcher
{
function addlabel():void;
}
}
I haven't looked through the entire code, but one thing I noticed is that you should pass the values on as parameters to the child components and use data binding to dynamically update parameters.
So in AModule.as:
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="508" height="218" implements="modules.AModule" backgroundColor="#F00F0F" creationComplete="addlabel();">
<mx:Script>
<![CDATA[
import mx.core.Application;
public var logsin:loginhere = new loginhere();
[Bindable]
public var username:String = "";
]]>
</mx:Script>
<mx:TextInput id="txt3" text="{username}" x="30.5" y="10" width="79"/>
<mx:Label id="lb1" text="{username}" x="31.5" y="40" width="78" text="Will it Change?"/>
</mx:Module>
In the method where you create the module you can then:
module.username = //var that holds username;
The point I missed was, I dint create a instance for interface in main.mxml
The var should be created in modEventHandler function In that function the below lines should be added
ichild=module as AModule;
ichild.addlabel(tt.text);
so the module gets called and the value is displayed in the label field.
Please let me know, if its wrong way of working. Thank You

connecting to remote webservice using SOAP and WSDL using flex or actionscript

The requirement is to get the method named getIncidentList() from web service using Soap and wsdl using Flex or Actionscript.
Can anyone help me i have a code which is not working:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:WebService id="DirectoryService"
wsdl="http://cmuicds.rutgers.edu/uicds/core/ws/services/DirectoryService.wsdl"
useProxy="false"
showBusyCursor="true"
result="onResult(event)"
fault="onFault(event)">
</mx:WebService>
<mx:ApplicationControlBar dock="true">
<mx:Button id="button"
label="get incidents from web service"
click="button_click()"/>
<mx:ComboBox id="cmb" dataProvider="{zipfls}" labelField="name" width="241" height="24"/>
</mx:ApplicationControlBar>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.utils.ObjectUtil;
import mx.collections.ArrayCollection;
[Bindable] private var zipfls:ArrayCollection;
private var flag:Boolean;
private function button_click():void
{
//Alert.show("Hi");
//DirectoryService.GetIncidentList.send();
DirectoryService.GetIncidentList();
flag = DirectoryService.canLoadWSDL();
//flag = DirectoryService.hasOwnProperty();
//Alert.show("Testing....." + flag);
//Alert.show("Description " +DirectoryService.operations);
}
private function onResult(evt:ResultEvent):void
{
zipfls = new ArrayCollection();
//textArea.text = ObjectUtil.toString(evt.result);
zipfls = evt.result as ArrayCollection;
Alert.show("Is data comming in?" + zipfls.length);
}
private function onFault(evt:FaultEvent):void
{
Alert.show(evt.type);
}
]]>
</mx:Script>
</mx:Application>
I think you are not calling method properly
and event button_click should be
private function button_click():void
{
DirectoryService.GetIncidentList();
}
i.e. send should not be used.
also see Using WebService components
Hopes that helps