a function to go to the next case on the switch...?
i have created a switch that assign different case to different toggle buttons. so when each case is activate, it loads a different swf.
so far it works fine..It's going to be like a sub menu thing, the toggle button remains activated so viewer know which page they are at right now..until they click the next toggle button..so on and so on.
but i've spent hours trying to create a "Next" button, so the activeSection will jump to the next case on the switch list, activates the next toggle button, loads next swf. Like a next page thing.
look around a lot of examples, but the more i tried, the more i confuse. so...Please HELP!!!
private function onNavigate( event:NavigationEvent ):void{
var targetId:uint = event.data.id;
switch( targetId ){
case ID_CONTENT_1:
gotoSection( ID_CONTENT_1 );
loadLabel ( ID_CONTENT_1 );
break;
case ID_CONTENT_2 :
gotoSection( ID_CONTENT_2 );
loadLabel ( ID_CONTENT_2 );
break;
case ID_CONTENT_3 :
gotoSection( ID_CONTENT_3 );
loadLabel ( ID_CONTENT_3 );
break;
case ID_CONTENT_4 :
gotoSection( ID_CONTENT_4 );
loadLabel ( ID_CONTENT_4 );
break;
}
}
private function gotoSection( contentId:uint ):void{
var urlToLoad:String;
switch( contentId ){
case ID_CONTENT_1:
_sectionToLoad = ID_CONTENT_1;
urlToLoad = SWF_CONTENT1_URL;
break;
case ID_CONTENT_2:
_sectionToLoad = ID_CONTENT_2;
urlToLoad = SWF_CONTENT2_URL;
break;
case ID_CONTENT_3:
_sectionToLoad = ID_CONTENT_3;
urlToLoad = SWF_CONTENT3_URL;
break;
case ID_CONTENT_4:
_sectionToLoad = ID_CONTENT_4;
urlToLoad = SWF_CONTENT4_URL;
break;
default:
trace("The contentId " + contentId + " is invalid" );
}
//if there is a currently active section, transition it out
if( _activeSection ){
_activeSection.transitionOut();
}
//load a section
TweenLite.delayedCall( SpriteBase.TRANSITION_TIME, loadSection, [ urlToLoad ] );
}
private function loadSection( sectionToLoad:String ):void{
//if something else is loading, cancel
if( _isLoading ){
_loader.close();
_loader.contentLoaderInfo.removeEventListener( Event.COMPLETE, onLoadComplete );
_loader.contentLoaderInfo.removeEventListener( ProgressEvent.PROGRESS, onProgress );
}
trace("Load "+ sectionToLoad )
_loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadComplete );
_loader.contentLoaderInfo.addEventListener( ProgressEvent.PROGRESS, onProgress );
_loader.load( new URLRequest( sectionToLoad ) );
_isLoading = true;
TweenLite.to( tfPercentage, .5, { alpha:1, ease:Quart.easeOut } );
}
each case is assigned to one of a group toggle buttons
public function toggleButton( p_nIndex:uint ):void{
if( _selectedButton ){
_selectedButton.activate( true );
}
switch( p_nIndex ){
case 0:
_selectedButton = button1;
break;
case 1:
_selectedButton = button2;
break;
case 2:
_selectedButton = button3;
break;
case 3:
_selectedButton = button4;
break;
}
_selectedButton.activate( false );
dispatchEvent( new NavigationEvent( NavigationEvent.NAVIGATE, { id:p_nIndex } ) );
}
How do I create a function to have it jump to the next case???
any suggestion will be appreciated!!!