• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • 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
Choose an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

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