Announcement

Collapse
No announcement yet.

[SOLVED]Previous frame still showing after using GotoAndStop()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED]Previous frame still showing after using GotoAndStop()

    Hey,

    I'm having an issue with scaleform at the moment when trying to switch between different frames.

    I currently have a main menu that has several options such as single player, credits, exit etc, what's happening is when I select the credits option and load that frame with GotoandStop() the previous frame (being the main menu) is still sitting in the background.

    It stays there for about 20 seconds before disappearing and from that point works fine if i go back to the main menu and then back to credits, but if I have to reload the menu it does it again.

    The main menu and the credits screen are in the same flash file and I just jump between frames when I select the credits option.

    This works fine if it's using the scaleform launcher from flash, but NOT in the UDK when running the game.

    If anyone has any ideas, would be greatly appreciated

    Actionscript
    Code:
    stop();
    
    import gfx.ui.InputDetails;
    import gfx.ui.NavigationCode;
    import flash.external.ExternalInterface;
    
    var selectedButtonNum:Number = 1;
    var lastButton:MovieClip = null;
    
    function SelectButton(selectedButton:Number):Boolean
    {
    	selectedButtonNum = selectedButton;
    	trace("Button Select" + selectedButtonNum);
    	if(lastButton != null) 
    	{
    		DeactivateButton();
    	}
    	
    	switch(selectedButtonNum)
    	{
    		case 1:
    			lastButton = btn_single;
    			btn_single.gotoAndStop("buttonOn");
    			break;
    		case 2:
    			lastButton = btn_multi;
    			btn_multi.gotoAndStop("buttonOn");
    			break;
    		case 3:
    			lastButton = btn_options;
    			btn_options.gotoAndStop("buttonOn");
    			break;
    		case 4:
    			lastButton = btn_credits;
    			btn_credits.gotoAndStop("buttonOn");
    			break;
    		case 5:
    			lastButton = btn_exit;
    			btn_exit.gotoAndStop("buttonOn");
    			break;
    	}
    	
    	return true;
    }
    
    function DeactivateButton():Void
    {
    	lastButton.gotoAndStop("buttonOff");
    }
    
    function ButtonPressed(selectedButton:Number):Boolean
    {
    	selectedButtonNum = selectedButton;
    	switch(selectedButtonNum)
    	{
    		case 1:
    			ExternalInterface.call("OnSinglePress");
    			break;
    		case 2:
    			ExternalInterface.call("OnMultiPress");
    			break;
    		case 3:
    			ExternalInterface.call("OnOptionsPress");
    			break;
    		case 4:
    			ExternalInterface.call("OnCreditsPress");
    			break;
    		case 5:
    			ExternalInterface.call("OnExitPress");
    			break;
    	}
    	
    	return true;
    }
    
    
    // Set up key DOWN events 
    this.ProcessKeyDown = function(details:InputDetails, pathToFocus:Array)
    {	
    	var bHandled = false;
    	if (details.navEquivalent == NavigationCode.GAMEPAD_A)
    	{
    		ButtonPressed();
    	}
    	else if(details.navEquivalent == NavigationCode.UP)
    	{
    		if(selectedButtonNum > 1)
    		{
    			selectedButtonNum--;
    			SelectButton();
    		}
    	}
    	else if(details.navEquivalent == NavigationCode.DOWN)
    	{
    		if(selectedButtonNum < 5)
    		{
    			selectedButtonNum++;
    			SelectButton();
    		}
    	}
    	return bHandled;
    }
    
    
    // Set up Key UP events
    this.ProcessKeyUp = function(details:InputDetails, pathToFocus:Array)
    {	
    	var bHandled = false;
    	detailsLabel_mc.textField.text = "";
    	if (details.navEquivalent == NavigationCode.GAMEPAD_A)
    	{
    
    	}
    	return bHandled;
    }
    
    
    
    function handleInput(details:InputDetails, pathToFocus:Array):Boolean 
    {
    	//This version does not recurse.  See versions of "InputHelper.as" for examples of how to recurse properly
    	//event has NOT been successfully dealt with.  Try to send the appropriate event to the top level movie
    	if ((details.value == "keyDown") && (ProcessKeyDown))
    	{
    		return ProcessKeyDown(details, pathToFocus);
    	}
    	else if ((details.value == "keyUp") && (ProcessKeyUp))
    	{
    		return ProcessKeyUp(details, pathToFocus);
    	}
    	else if ((details.value == "keyHold") && (ProcessKeyHold))
    	{
    		return ProcessKeyHold(details, pathToFocus);
    	}
    	//Since this is the top level, the return value isn't relevant.  Just say we didn't handle it.
    	return FALSE;
    }
    
    btn_empty.focused = true;
    btn_single.gotoAndStop("ButtonOn");
    btn_multi.gotoAndStop("ButtonOff");
    btn_options.gotoAndStop("ButtonOff");
    btn_credits.gotoAndStop("ButtonOff");
    btn_exit.gotoAndStop("ButtonOff");
    lastButton = btn_single;
    ButtonSelect();

    Code:
    function OnCreditsPress()
    {
    	menuWrapper.GotoAndStop("credits");
    }

    ***EDIT***
    Fixed this, found out it seemed to be creating two instances of the flash movie with only one of them taking input, I put in a check to see if that flash movie existed or not before reassigning it and works fine now

    Code:
    //inside the HUD class for the player
    if(MainHudMovie == none)  //<--wasn't doing this, which was causing the problem
    {
         MainHudMovie = new class'IEP_MainMenu';
         MainHudMovie.bGammaCorrection = false;
         MainHudMovie.PlayerOwner = PlayerOwner;
         MainHudMovie.Init();
         MainHudMovie.SetTimingMode(TM_Real);
    }
Working...
X