Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call a mxml component from another mxml component in flex-edited
    text
    copied!<p>I need to call a component named "defectTracker.mxml" by clicking a link in another mxml component called "reviewComponent.mxml". How do I achieve that?</p> <p>This is my reviewComponent.mxml code:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off"&gt; &lt;mx:Script&gt; &lt;![CDATA[ private function defectTrackerLink(event:Event):void{ //call defectTracker } ]]&gt; &lt;/mx:Script&gt; &lt;mx:LinkButton label="Delete" textDecoration="underline" textRollOverColor="blue"/&gt; &lt;mx:LinkButton label="Defect Tracker" textDecoration="underline" textRollOverColor="blue" click="defectTrackerLink(event)"/&gt; &lt;/mx:VBox&gt; </code></pre> <p>Some one guide me.</p> <p>Main.mxml:</p> <pre><code>&lt;mx:Script&gt; &lt;![CDATA[ private function subBtnBar(evt:ItemClickEvent):void{ switch (evt.label){ case "IQA/UAT": this.bdyStack.selectedChild = screenIQA; break; case "EQA": Alert.show("Yet To Design"); break; case "Review Tracker": this.bdyStack.selectedChild = reviewTracker; break; case "Defect Tracker": this.bdyStack.selectedChild = defectTracker; break; default: trace ("Neither a or b was selected") } } ]]&gt; &lt;/mx:Script&gt; &lt;mx:ViewStack id="tabView" width="910" creationPolicy="all"&gt; &lt;mx:ToggleButtonBar horizontalGap="0" id="subTabBar" itemClick="subBtnBar(event);" styleName="SubButtonBar" hideEffect="{dissolveOut}" showEffect="{dissolveIn}"&gt; &lt;mx:dataProvider&gt; &lt;mx:String&gt;IQA/UAT&lt;/mx:String&gt; &lt;mx:String&gt;EQA&lt;/mx:String&gt; &lt;mx:String&gt;Review Tracker&lt;/mx:String&gt; &lt;mx:String&gt;Defect Tracker&lt;/mx:String&gt; &lt;mx:String&gt;Defect Configuration&lt;/mx:String&gt; &lt;mx:String&gt;Defect Export&lt;/mx:String&gt; &lt;mx:String&gt;Defect Import&lt;/mx:String&gt; &lt;/mx:dataProvider&gt; &lt;/mx:ToggleButtonBar&gt; &lt;/mx:ViewStack&gt; &lt;mx:ViewStack id="bdyStack" width="910" height="80%"&gt; &lt;components:ScrIQA id="screenIQA" hideEffect="{dissolveOut}" showEffect="{dissolveIn}"/&gt; &lt;components:scrWorkList id="screenWorkList" hideEffect="{dissolveOut}" showEffect="{dissolveIn}"/&gt; &lt;components:DefectEntryVerification id="defectEntryVerification" hideEffect="{dissolveOut}" showEffect="{dissolveIn}" width="100%" height="100%"/&gt; &lt;components:scrDefectResolutionAndCause id="defectResolutionnVerification" hideEffect="{dissolveOut}" showEffect="{dissolveIn}" width="100%" height="100%"/&gt; &lt;components:reviewTracker id="reviewTracker" hideEffect="{dissolveOut}" showEffect="{dissolveIn}" width="100%" height="100%"/&gt; &lt;components:defectTracker id="defectTracker" hideEffect="{dissolveOut}" showEffect="{dissolveIn}" width="100%" height="100%"/&gt; &lt;/mx:ViewStack&gt; </code></pre> <p>The defect Tracker scren is already linked with the main mxml file. How to call the function in the reviewComponent file? reviewComponent consist of 2 link buttons and it is a column entry of the reviewTracker.mxml file's datagrid. So when I click the link in the review component, I want the defectTracker screen to be called. Its already a child of the main.mxml file.</p> <p>I tried creting an instance of the main file in the component, and changes the selected child to defect tracker, It shows an error saying:</p> <pre><code>Error #1009: Cannot access a property or method of a null object reference. </code></pre> <p>My modified reviewComponent.mxml code:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off"&gt; &lt;mx:Script&gt; &lt;![CDATA[ private function defectTrackerLink(event:Event):void{ var main:Main=new Main(); main.bdyStack.selectedChild=main.defectTracker; } ]]&gt; &lt;/mx:Script&gt; &lt;mx:LinkButton label="Delete" textDecoration="underline" textRollOverColor="blue"/&gt; &lt;mx:LinkButton label="Defect Tracker" textDecoration="underline" textRollOverColor="blue" click="defectTrackerLink(event)"/&gt; &lt;/mx:VBox&gt; </code></pre> <p>Please some one guide me in this? Should I call the item click event function of the Toggle button Bar? If so how to do It?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload