6/15/2010 3:42:55 AM
Title:
(flex) Passing String To Module
Hi All,
I try to passing string to flex module with these code, but not succesfully working
Could someone give me such suggesstion. Thanks
--------
.
.
public function initApp():void {
info = ModuleManager.getModule("Module1.swf");
info.addEventListener(ModuleEvent.READY,
modEventHandler);
info.load();
}
private function modEventHandler(e:ModuleEvent):void
{
sm = info.factory.create() as Module1;
vb1.addChild(info.factory.create() as Module1);
}
public function st():void {
sm.Info("test");
}
]]>
</mx:Script>
<mx:VBox id="vb1" width="100%" height="100%">
<mx:Panel width="250" height="200" layout="absolute">
<mx:Button label="Button" x="10" y="10" click="st()"/>
</mx:Panel>
</mx:VBox>
.
.
=========
=========
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Script>
<![CDATA[
[Bindable]
private var s2:String;
public function Info(s:String) {
s2=s;
label01.text=s2;
}
]]>
</mx:Script>
<mx:Label id="label01" x="68" y="57" text="original"/>
</mx:Module>
==========
Davis
Points: 740
Posts:0
6/15/2010 4:22:02 AM
to access the function inside the module you need to use child property. See if this works:
sm.child.Info("test");
ping me back if does not work
6/15/2010 4:32:58 AM
you can use the following code to access the public function inside the module
//vb1 is your container in which module is added
public function st():void {
vb1.getChildAt(0).Info("test");
}
6/15/2010 5:01:44 AM
the tips doesn't work yet..
anyway thank you for resposes.
i will summarize then after find the solution.
6/15/2010 5:55:59 AM
i'm using other technique to passing the string, taken from adobe flex livedocs,
<http://livedocs.adobe.com/flex/3/html/help.html?content=modular_5.html>
or referencing module variable to parent variable.
something like :
label01.text = parentApplication.definedtext;
thank you all, case closed.