Avatar of Jay Roy
Jay RoyFlag for United States of America

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="{modelviewdata.workflowviewstate}">              
<workflowNavigation:WorkflowView label="{(modelviewdata.doesWorkflowExist == false ? 'Create New Profile' : (modelviewdata.showWorkFlow == true ? modelviewdata.selectedWorkflowid : ''))}" 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="org.efflex.mx.viewStackEffects.*"  
 borderStyle="none" height="2000" xmlns:buttons="com.ms.ewq.view.component.buttons.*"
creationComplete="init()">
..
<mx:Script>
             
<![CDATA[
private function init():void {
here i want to pass the lable value to  WorkflowSearchEvent
mx.controls.Alert.show("label",label);
var workflowevent:WorkflowSearchEvent = new WorkflowSearchEvent(label);
workflowevent.dispatch();
}

any idea?
thanks
Apache Flex

Avatar of undefined
Last Comment
Jay Roy
Avatar of dgofman
dgofman
Flag of United States of America image

Implementation is not the best and wrong

You should dispatch from child an event

http://livedocs.adobe.com/flex/3/html/help.html?content=mxmlcomponents_advanced_4.html

this.dispatchEvent(workflowevent);

By before add a metadata in your MXML for handle this event from outside

Lets believe you have class com.mycompany.events.WorkflowSearchEvent
And event type is “searchEvent
In this case client MXML declaration will be
<mx:Metadata>
    [Event(name=" searchEvent ", type="com.mycompany.events.WorkflowSearchEvent ")]
</mx:Metadata>

Now you can handle this event from a parent class

<workflowNavigation:WorkflowView searchEvent=”onSearchEvent(event) "  ..

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.WorkflowSearchEvent
<mx:Metadata>
    [Event(name="eventName", type="eventType")]
</mx:Metadata>
Avatar of dgofman
dgofman
Flag of United States of America image

Another option you can call the parent class function and pass label

parentDocument.setLabel(label);

You just need to implement "public function setLabel(value:String):void" in your parent class
Avatar of Jay Roy
Jay Roy
Flag of United States of America image

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:WorkflowSearchEvent = new WorkflowSearchEvent(this.label);
workflowevent.dispatch();
}
<workflowNavigation:WorkflowView label="{(modelviewdata.doesWorkflowExist == false ? 'Create New Profile' : (modelviewdata.showWorkFlow == true ? modelviewdata.selectedWorkflowid : ''))}"
height="3000" width="3000" searchEvent="onSearchEvent(event)" />

In WorkflowView.mxml i added
<mx:Metadata>
[Event(name="searchEvent", type="com.ms.ewq.Events.Workflow.WorkflowSearchEvent")]
</mx:Metadata>


am i correct?
thanks
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Jay Roy
Jay Roy
Flag of United States of America image

ASKER

hi...
what is meant by this>>>workflowevent.label = "My Label";

what should My Label be?

thanks
Apache Flex
Apache Flex

Apache Flex is a highly productive, open source application framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops and devices (including smartphones, tablets and television). It provides a modern, standards-based language and programming model that supports common design patterns suitable for developers from many backgrounds. Flex applications can be deployed to the Adobe Player in the browser, Adobe AIR on desktop and mobile devices or to native Android, iOS, Windows or Mac applications.

4K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo