Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-08-2006, 01:34 PM   #1
Registered User
Join Date: Oct 2006
Posts: 112
Default viewStack + load component function


I have a main mxml file "main.mxml" containing a view stack linking to an additional 2 mxml components:

<mx:ViewStack id="viewStack_vs">
<miage1 id="page_1" label="this is page 1"/>
<miage2 id="page_2" label="this is page 2"/>
<miage3 id="page_3" label="this is page 3"/>
<miage4 id="page_4" label="this is page 4"/>

when an item within the viewStack is selected / clicked… I want to call a function within the component that is selected….

For example within page2.mxml there is a function called testFunc():

Public function testFunc(){
Alert.show(“hello world”)

and then the link “page 2” is selected / clicked from the viewStack, I want to run this fuction within the page2.mxml component….

Is this possible??? Is t here some sort of onClick event within the viewStack I can use???

ljonny18 is offline   Reply With Quote
Old 11-08-2006, 02:50 PM   #2
Senior Member
Join Date: Aug 2005
Location: Minnesota, USA
Posts: 216

Yes, there's a click event for ViewStacks (and most everything else).

			import mx.controls.Alert;

			private function myFunction(event:Event):void
				Alert.show("here!","My Title");
	<mx:ViewStack click="myFunction( event )">
One of my favorite events
meddlingwithfir is offline   Reply With Quote
Old 10-14-2007, 05:27 PM   #3
Registered User
Join Date: Oct 2007
Posts: 2

Hello, but is there a way to call a function within the viewStack???
jsmb is offline   Reply With Quote
Old 10-15-2007, 05:16 PM   #4
dr_zeus's Avatar
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999

The "show" or "change" events might be better choices. If the function you want to call is public, you can do it in the MXML file that the ViewStack is in, yes. This should help get you started:

<mx:ViewStack id="stack" change="if(stack.selectedIndex == 1) page_2.myFunction()">
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
stop all child MCs function doing funny things to media component drewsteele ActionScript 2.0 7 04-01-2013 10:53 AM
2 primitive numbers not showing up as equal when returned from OOP functions arianhojat ActionScript 2.0 12 03-14-2006 07:37 PM
tweenining with AS lelales ActionScript 2.0 5 04-26-2005 10:05 PM
Database simulated with arrays on a cd-rom lecasn5 Components 61 09-07-2004 11:40 AM
[MX] Cannot acces to variable i'v load in my own component flapflap Components 2 10-27-2003 09:47 AM

All times are GMT. The time now is 08:30 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.