Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex: Call function from included component
    primarykey
    data
    text
    <p>This is similar to my previous posting. But this time I want to call a function that exists on the main mxml page.</p> <p>This is my main mxml page:</p> <p>main.mxml</p> <pre><code>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*"&gt; &lt;mx:Script&gt; &lt;![CDATA[ public function changeText(currentText:String):void{ switch (currentText){ case "changeText": lblOne.text = "More Text"; } } ]]&gt; &lt;/mx:Script&gt; &lt;mx:HBox x="137.5" y="10" width="100%" height="100%"&gt; &lt;ns1:menu id="buttons"&gt; &lt;/ns1:menu&gt; &lt;/mx:HBox&gt; &lt;mx:Canvas x="137" y="88" width="408.5" height="200"&gt; &lt;mx:HBox x="0" y="10" width="388.5" height="190"&gt; &lt;mx:Panel width="388" height="179" layout="absolute"&gt; &lt;mx:Label x="10" y="10" text="Some Text" visible="{buttons.showLabel}" id="lblOne"/&gt; &lt;/mx:Panel&gt; &lt;/mx:HBox&gt; &lt;/mx:Canvas&gt; &lt;/mx:Application&gt; </code></pre> <p>Here is my included page:</p> <p>menu.mxml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300"&gt; &lt;mx:Script&gt; &lt;![CDATA[ [Bindable] public var showLabel:Boolean = true; ]]&gt; &lt;/mx:Script&gt; &lt;mx:MenuBar width="380" height="58"&gt;&lt;/mx:MenuBar&gt; &lt;mx:Button x="10" y="10" width="80" label="Show" id="btnOne" click="this.showLabel=true;" /&gt; &lt;mx:Button x="94" y="10" width="80" label="Hide" id="btnTwo" click="this.showLabel=false;"/&gt; &lt;mx:Button x="181" y="10" width="80" label="Run Function" id="btnThree" click="{changeText('changeText')}"/&gt; &lt;/mx:Canvas&gt; </code></pre> <p>How do I call the changeText function from the button on menu.mxml?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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