flex - Is it possible to use outside "<mx:script>" in "<mx:canvas>"? -
i got new project. , part of it, flex exist.
<mx: application xmlns:mx=...> <mx:script> import... function a() { } </mx:script> <mx:linkbar...> <mxviewstack ...> <mx:canvas id="1st" ...> **[here]** </mx:canvas> <mx:canvas id="2nd" ...> ... </mx:canvas> <mx:canvas id="3rd" ...> ... </mx:canvas> ** when viewstack calls canvas sequentially, a() has work.
is possible use function a() in **here**]?
or please let me know possible function or tag can used.
below example may you: -
<?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minwidth="955" minheight="600"> <fx:declarations> <!-- place non-visual elements (e.g., services, value objects) here --> </fx:declarations> <fx:script> <![cdata[ private function a():void { //your code } private function viewstackhandler():void { //method 1 if(viewstackid.selectedindex == 0) { a(); } else if(viewstackid.selectedindex == 1) { a(); } else { a(); } //or method second //call a() } ]]> </fx:script> <mx:vbox width="100%" height="100%"> <mx:hbox width="100%" height="20"> <s:button label="one" click="{viewstackid.selectedindex = 0}"/> <s:button label="two" click="{viewstackid.selectedindex = 1}"/> <s:button label="three" click="{viewstackid.selectedindex = 2}"/> </mx:hbox> <mx:viewstack width="500" height="400" id="viewstackid" change="viewstackhandler()"> <mx:canvas id="canval1" bordercolor="#ff0000" width="100%" height="100%"> <s:button label="one"/> </mx:canvas> <mx:canvas id="canval2" bordercolor="#00ff00" width="100%" height="100%"> <s:button label="two"/> </mx:canvas> <mx:canvas id="canval3" bordercolor="#0000ff" width="100%" height="100%"> <s:button label="three"/> </mx:canvas> </mx:viewstack> </mx:vbox> </s:application>
Comments
Post a Comment