Jay Roy
asked on
passing label value on view click
hi guys
I am tring to pass a label from outer mxml to inner mxml
I have a view stack like this
<mx:ViewStack id="workflowViewStack" width="100%" borderColor="#000000" cornerRadius="4" selectedIndex="{modelviewd ata.workfl owviewstat e}">
<workflowNavigation:Workfl owView label="{(modelviewdata.doesWork flowExist == false ? 'Create New Profile' : (modelviewdata.showWorkFlo w == true ? modelviewdata.selectedWork flowid : ''))}" height="3000" width="3000" />
</mx:ViewStack>
this is my WorkflowView.mxml. When WorkflowView is clicked i want to invoke the init() function and pass the label value to it.
WorkflowView.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:viewStackEffects="or g.efflex.m x.viewStac kEffects.* "
borderStyle="none" height="2000" xmlns:buttons="com.ms.ewq. view.compo nent.butto ns.*"
creationComplete="init()">
..
<mx:Script>
<![CDATA[
private function init():void {
here i want to pass the lable value to WorkflowSearchEvent
mx.controls.Alert.show("la bel",label );
var workflowevent:WorkflowSear chEvent = new WorkflowSearchEvent(label);
workflowevent.dispatch();
}
any idea?
thanks
I am tring to pass a label from outer mxml to inner mxml
I have a view stack like this
<mx:ViewStack id="workflowViewStack" width="100%" borderColor="#000000" cornerRadius="4" selectedIndex="{modelviewd
<workflowNavigation:Workfl
</mx:ViewStack>
this is my WorkflowView.mxml. When WorkflowView is clicked i want to invoke the init() function and pass the label value to it.
WorkflowView.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:viewStackEffects="or
borderStyle="none" height="2000" xmlns:buttons="com.ms.ewq.
creationComplete="init()">
..
<mx:Script>
<![CDATA[
private function init():void {
here i want to pass the lable value to WorkflowSearchEvent
mx.controls.Alert.show("la
var workflowevent:WorkflowSear
workflowevent.dispatch();
}
any idea?
thanks
Another option you can call the parent class function and pass label
parentDocument.setLabel(la bel);
You just need to implement "public function setLabel(value:String):voi d" in your parent class
parentDocument.setLabel(la
You just need to implement "public function setLabel(value:String):voi
ASKER
hi
i am trying to understand your code, here are the changes i made
in my parent i added
parent.mxml
public function onSearchEvent(event: WorkflowSearchEvent):void{
var workflowevent:WorkflowSear chEvent = new WorkflowSearchEvent(this.l abel);
workflowevent.dispatch();
}
<workflowNavigation:Workfl owView label="{(modelviewdata.doe sWorkflowE xist == false ? 'Create New Profile' : (modelviewdata.showWorkFlo w == true ? modelviewdata.selectedWork flowid : ''))}"
height="3000" width="3000" searchEvent="onSearchEvent (event)" />
In WorkflowView.mxml i added
<mx:Metadata>
[Event(name="searchEvent", type="com.ms.ewq.Events.Wo rkflow.Wor kflowSearc hEvent")]
</mx:Metadata>
am i correct?
thanks
i am trying to understand your code, here are the changes i made
in my parent i added
parent.mxml
public function onSearchEvent(event: WorkflowSearchEvent):void{
var workflowevent:WorkflowSear
workflowevent.dispatch();
}
<workflowNavigation:Workfl
height="3000" width="3000" searchEvent="onSearchEvent
In WorkflowView.mxml i added
<mx:Metadata>
[Event(name="searchEvent",
</mx:Metadata>
am i correct?
thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
hi...
what is meant by this>>>workflowevent.label = "My Label";
what should My Label be?
thanks
what is meant by this>>>workflowevent.label
what should My Label be?
thanks
You should dispatch from child an event
http://livedocs.adobe.com/flex/3/html/help.html?content=mxmlcomponents_advanced_4.html
this.dispatchEvent(workflo
By before add a metadata in your MXML for handle this event from outside
Lets believe you have class com.mycompany.events.Workf
And event type is “searchEvent”
In this case client MXML declaration will be
<mx:Metadata>
[Event(name=" searchEvent ", type="com.mycompany.events.Workf
</mx:Metadata>
Now you can handle this event from a parent class
<workflowNavigation:Workfl
Private var onSearchEvent(event: WorkflowSearchEvent):void{
By before add a metadata in your MXML for handle this event from outside
Lets beleive you have class com.mycompany.events.Workf
<mx:Metadata>
[Event(name="eventName", type="eventType")]
</mx:Metadata>