Jay Roy
asked on
access data from one component to other component in actionscript
hi guys
I have two components.
TextareaComponent
DatagridComponent
TextareaComponent is rendered first
DatagridComponent is rendered second.
My goal is to access lookupdataForFilter defined in the DatagridComponent from my TextareaComponent
I have defined lookupdataForFilter as bindable
I put a breakpoint on this line >>lookupdataForFilter = data as ArrayCollection; and i see the data.
but when KEY_UP event is invoked from TextareaComponent 'grid.lookupdataForFilter' is empty.
any idea where i am going wrong?
thanks
I have two components.
TextareaComponent
DatagridComponent
public class TextareaComponent extends FormItem{
public function TextareaComponent() {
super();
grid = new DatagridComponent();
this.textArea.addEventListener(flash.events.KeyboardEvent.KEY_UP,callPopulate);
}
private function callPopulate(event: flash.events.KeyboardEvent) : void {
if(grid != null && grid.lookupdataForFilter != null){
var lookupdata:ArrayCollection = grid.lookupdataForFilter; //data from DatagridComponent
}
}
public class DatagridComponent extends VBox
{
[Bindable] public var lookupdataForFilter:ArrayCollection = new ArrayCollection();
public function DatagridComponent()
{
super();
Swiz.dispatchEvent(new GlobalScreenEvent(GlobalScreenEvent.POPULATE_LOOKUP));
}
[Mediate(event="GlobalScreenEvent.LOOKUP_RECEIVED", properties="data")]
public function populateLookUp( data:Object ):void{
lookupdataForFilter = data as ArrayCollection; //contains the data
}
}
}
TextareaComponent is rendered first
DatagridComponent is rendered second.
My goal is to access lookupdataForFilter defined in the DatagridComponent from my TextareaComponent
I have defined lookupdataForFilter as bindable
I put a breakpoint on this line >>lookupdataForFilter = data as ArrayCollection; and i see the data.
but when KEY_UP event is invoked from TextareaComponent 'grid.lookupdataForFilter'
any idea where i am going wrong?
thanks
ASKER
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 2:
The data is not being set but i am not sure where its missing since i am making the lookupdataForFilter as Bindable
TRACE 2:
The data is not being set but i am not sure where its missing since i am making the lookupdataForFilter as Bindable
Did you get in this order TRACE 1 then TRACE 2?
public function DatagridComponent()
{
super();
trace("TRACE 0");
}
Check if you executing DatagridComponent more than once
{
super();
trace("TRACE 0");
}
Check if you executing DatagridComponent more than once
ASKER
Did you get in this order TRACE 1 then TRACE 2?
Yep
I got it like this
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 2:
Yep
I got it like this
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 2:
How about constructor
ASKER
when i run it without break points it doesnt display anything in the console. any idea why
you just need to execute in debug mode, plus if mm.cfg is set on your local machine you shold able to get trace from a log file
Windows 7 path
C:\Users\royjayd\AppData\R oaming\Mac romedia\Fl ash Player\Logs\flashlog.txt
Windows 7 path
C:\Users\royjayd\AppData\R
ASKER
1
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b in-debug\T radeFlex.s wf\[[DYNAM IC]]\14 - 3,054 bytes after decompression
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b in-debug\T radeFlex.s wf\[[DYNAM IC]]\15 - 3,054 bytes after decompression
[SWF] C:\myWorkspace\TradeFlex\b in-debug\T radeFlex.s wf\[[DYNAM IC]]\16 - 3,054 bytes after decompression
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 2:
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b
[SWF] C:\myWorkspace\TradeFlex\b
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 2:
Now I understood.
I can see you created two DatagridComponent and may be first one is initialized but from your TextareaComponent class may not. Add one more trace into TextareaComponent constructor
public function TextareaComponent() {
super();
trace(“BEFORE”);
grid = new DatagridComponent();
this.textArea.addEventList ener(flash .events.Ke yboardEven t.KEY_UP,c allPopulat e);
trace(“AFTER”);
}
I can see you created two DatagridComponent and may be first one is initialized but from your TextareaComponent class may not. Add one more trace into TextareaComponent constructor
public function TextareaComponent() {
super();
trace(“BEFORE”);
grid = new DatagridComponent();
this.textArea.addEventList
trace(“AFTER”);
}
ASKER
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b
BEFORE
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b
AFTER
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b
[SWF] C:\myWorkspace\TradeFlex\b
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TRACE 2:
Ok I can see constructor calls twice but why TRACE 1 4 times?
ASKER
[Mediate(event="GlobalScre enEvent.LO OKUP_RECEI VED", properties="data")]
public function populateLookUp( data:Object ):void{
lookupdataForFilter = data as ArrayCollection; //contains the data
trace("TRACE 1: " + lookupdataForFilter);
}
populateLookUp() is called on this event GlobalScreenEvent.LOOKUP_R ECEIVED... maybe swiz is calling it ?
public function populateLookUp( data:Object ):void{
lookupdataForFilter = data as ArrayCollection; //contains the data
trace("TRACE 1: " + lookupdataForFilter);
}
populateLookUp() is called on this event GlobalScreenEvent.LOOKUP_R
From your logic it must be one constructor call and single TRACE 1 output.
You should fix it that how it will resolve your issue
You should fix it that how it will resolve your issue
ASKER
i think because of
Swiz.dispatchEvent(new GlobalScreenEvent(GlobalSc reenEvent. POPULATE_L OOKUP));
is in the DatagridComponent constructor ?
so Trace 0 is invoked 3 times, Trace 1 is invoked 3 times, i checked again , trace 0 and trace 1 occurs three time..here is it
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b in-debug\T radeFlex.s wf\[[DYNAM IC]]\13 - 3,054 bytes after decompression
BEFORE
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b in-debug\T radeFlex.s wf\[[DYNAM IC]]\14 - 3,054 bytes after decompression
AFTER
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b in-debug\T radeFlex.s wf\[[DYNAM IC]]\15 - 3,054 bytes after decompression
[SWF] C:\myWorkspace\TradeFlex\b in-debug\T radeFlex.s wf\[[DYNAM IC]]\16 - 3,054 bytes after decompression
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object]...
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object]...
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object]...
...after Key is presed
TRACE 2:
Swiz.dispatchEvent(new GlobalScreenEvent(GlobalSc
is in the DatagridComponent constructor ?
so Trace 0 is invoked 3 times, Trace 1 is invoked 3 times, i checked again , trace 0 and trace 1 occurs three time..here is it
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b
BEFORE
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b
AFTER
TRACE 0
[SWF] C:\myWorkspace\TradeFlex\b
[SWF] C:\myWorkspace\TradeFlex\b
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object]...
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object]...
TRACE 1: [object Object],[object Object],[object Object],[object Object],[object Object]...
...after Key is presed
TRACE 2:
Comment Swiz call check what's happend
public function DatagridComponent()
{
super();
//Swiz.dispatchEvent(new GlobalScreenEvent(GlobalSc reenEvent. POPULATE_L OOKUP));
}
public function DatagridComponent()
{
super();
//Swiz.dispatchEvent(new GlobalScreenEvent(GlobalSc
}
ASKER
i was actually trying to do this..put the swiz call in TextareaComponent itself
public class TextareaComponent extends FormItem{
public function TextareaComponent() {
super();
public var lookupdataForFilter:ArrayC ollection = new ArrayCollection();
this.textArea.addEventList ener(flash .events.Ke yboardEven t.KEY_UP,c allPopulat e);
Swiz.dispatchEvent(new GlobalScreenEvent(GlobalSc reenEvent. POPULATE_L OOKUP));
}
private function callPopulate(event: flash.events.KeyboardEvent ) : void {
lookupdataForFilter = data as ArrayCollection;
}
[Mediate(event="GlobalScre enEvent.LO OKUP_RECEI VED", properties="data")]
public function populateLookUp( data:Object ):void{
lookupdataForFilter = data as ArrayCollection;
}
}
But the problem is populateLookUp() is never called
public class TextareaComponent extends FormItem{
public function TextareaComponent() {
super();
public var lookupdataForFilter:ArrayC
this.textArea.addEventList
Swiz.dispatchEvent(new GlobalScreenEvent(GlobalSc
}
private function callPopulate(event: flash.events.KeyboardEvent
lookupdataForFilter = data as ArrayCollection;
}
[Mediate(event="GlobalScre
public function populateLookUp( data:Object ):void{
lookupdataForFilter = data as ArrayCollection;
}
}
But the problem is populateLookUp() is never called
Paste your controller implementation
ASKER
public class LookupController extends import org.swizframework.controller.AbstractController;
{
[Mediate(event="GlobalScreenEvent.POPULATE_LOOKUP")]
public function getLookUpData():void{
var call : AsyncToken = delegate.getLookUpData();
executeServiceCall(call, lookupHandler, lookupFaulthHandler);
}
protected function lookupHandler(event:ResultEvent):void {
if (isSessionValid(event))
{
Swiz.dispatchEvent(new GlobalScreenEvent(GlobalScreenEvent.LOOKUP_RECEIVED, event.result));
}
}
public function lookupFaulthHandler ( fault : FaultEvent) : void {
//trace("Unable to Fetch User List....");
}
}
ASKER
populateLookUp() in DatagridComponent is called but populateLookUp() in TextareaComponent is never called..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do next:
public function populateLookUp( data:Object ):void{
lookupdataForFilter = data as ArrayCollection; //contains the data
trace("TRACE 1: " + lookupdataForFilter);
}
private function callPopulate(event: flash.events.KeyboardEvent
trace("TRACE 2: " + (grid ? grid.lookupdataForFilter : "NULL"));
if(grid != null){
var lookupdata:ArrayCollection