• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

flex 4 viewstack

Please. how can I access a function in a mxml component loaded into a ViewStack? thanks
0
cpub
Asked:
cpub
  • 4
  • 3
1 Solution
 
dgofmanCommented:
trace(Object(viewStack.selectedChild).functionName())

The better to replace Object by Class Type (cast to your class) but the problem each children in most case belongs to diffrent MXML files in this case you may wath to create an interface file and implement your share function for each viewstack children

Recomending use this

trace(IMyMathInterfaceClass(viewstack.sekectedChild).round());
0
 
cpubAuthor Commented:
please the HERE comment into code:

CPUBDESKTOP.txt (the call)

COMPONENTMXML.txt (the component mxml)

Thanks


CPUBDESKTOP.txt
COMPONENTMXML.txt
0
 
dgofmanCommented:
Your btum function should look like this

protected function btum(event:MouseEvent):void
{
    var obj:Object = vs.selectedChild;
    obj.reload();
}

and ViewStack children are:

<mx:ViewStack id="vs" x="10" y="179" width="100%" height="100%"
                                x.show="0" y.show="74" width.show="100%" height.show="100%">
                  <component:MyView1 width="100%" height="100%" backgroundColor="0xFF0000"/>
                  <component:MyView2 width="100%" height="100%" backgroundColor="0xFF0000"/>
            </mx:ViewStack>

And MyView1 and MyView2 must extends from NavigatorContent

<?xml version="1.0" encoding="utf-8"?>
<s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009"
              xmlns:s="library://ns.adobe.com/flex/spark"
              xmlns:mx="library://ns.adobe.com/flex/mx">
      <s:Label text="MyView1_Label"/>
</s:NavigatorContent>
0
How to change the world, one degree at a time.

By embracing technology, we can solve even the biggest problems—including the gender gap.  By earning a degree from WGU, you have an opportunity to gain the knowledge, credentials, and experience it takes to thrive in today’s high-growth IT industry.

 
dgofmanCommented:
and implements a public function "reload"
0
 
cpubAuthor Commented:
ok but
how do I access the function of leitorRSSX.mxml? from main.mxml.
The example below:

MAIN.MXML
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                 xmlns:s="library://ns.adobe.com/flex/spark"
                                 xmlns:mx="library://ns.adobe.com/flex/mx"
                                 xmlns:examples="flecInc.alumina.hud.examples.*"  
                                 width="1270"
                                 height="630"
                                 >
<fx:Script>
*******************************    HERE THE CALLFUNCION ****************************************
protected function btum(event:MouseEvent):void
{
var w3a:leitorRSSX;
w3a.videox();
}
*******************************    HERE THE CALLFUNCION ****************************************
</fx:Script>

<mx:ViewStack id="vs" x="10" y="179" width="100%" height="100%"
x.show="0" y.show="74" width.show="100%" height.show="100%">

<s:NavigatorContent id="um" width="100%" height="100%" backgroundColor="0xFF0000">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<examples:leitorRSSX>
</examples:leitorRSSX>
</s:NavigatorContent>
                                                
<s:NavigatorContent id="dois" width="100%" height="100%" backgroundColor="0x0000FF">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
</s:NavigatorContent>
</mx:ViewStack>
</s:WindowedApplication>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IN leitorRSSX.MXML

<s:NavigatorContent  xmlns:fx="http://ns.adobe.com/mxml/2009" ...

<fx:Script>
<![CDATA[
*******************************    HERE THE PUBLIC FUNCION ****************************************
public function videox():void
{
Player_Containerx.videoID =vsplit(dg.selectedItem.link);
Player_Containerx.play();// TODO Auto-generated method stub
}
*******************************    HERE THE PUBLIC FUNCION ****************************************
]]>
</fx:Script>

</s:NavigatorContent >

thanks
0
 
dgofmanCommented:
Move to external view file

<examples:leitorRSSX>
</examples:leitorRSSX>
0
 
cpubAuthor Commented:
<examples:leitorRSSX id="varID">
</examples:leitorRSSX>

Solution correct - instantiate de object with:  id property

Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now