Announcement

Collapse
No announcement yet.

My statBtn can't let me open a level

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

    My statBtn can't let me open a level

    Hi,
    I start learning scalform UI these days follow the video from youtube.
    and i follow the steps of the tutorial , but i can't open a level through the start button,
    here is my code, what the problem is? Thank you!

    Code:
    class MyMenu extends GFXMoviePlayer;
    
    var GFxClikWidget StartButton;
    var GFxObject MainMenuTitle;
    function bool start(optional bool StartPaused = false)
    {
    	super.start();
    	Advance(0);
    
    	MainMenuTitle = GetVariableObject("_root.textField");
    	MainMenuTitle.SetText("Hello World!");
    	return true;
    }
    event bool WidgetIntialized(name WidgetName, name WidgetPath, GFXObject Widget)
    {
    	switch(widgetName)
    	{
    		case ('startBtn'):
    			StartButton = GFxClikWidget(Widget);
    			StartButton.AddEventListener('CLIK_press', OnStartButtonPress);
    			break;
    		default:
    			break;
    	}
    	return true;
    }
    
    
    function OnStartButtonPress(GFxClikWidget.EventData ev)
    {
    	ConsoleCommand("open dm-deck");
    
    }
    
    /* I am use July 2012 udk, so i skip this function accrrding to the video said:
    final function ConsoleCommand(string Cmd, optional bool bWriteToLog)
    {
    	if (PlayerOwner != none)
    		PlayerOwner.ConsoleCommand(Cmd, bWriteToLog);
    }
    */
    defaultproperties
    {
    	WidgetBindings.Add((WidgetName="startBtn",WidgetClass=class'GFxClikWidget'))
    
    
    }

    #2
    I think this "StartButton.AddEventListener('CLIK_press', OnStartButtonPress);" should be "StartButton.AddEventListener('CLIK_buttonPres s', OnStartButtonPress);"

    Comment


      #3
      Originally posted by Solid Snake View Post
      I think this "StartButton.AddEventListener('CLIK_press', OnStartButtonPress);" should be "StartButton.AddEventListener('CLIK_buttonPres s', OnStartButtonPress);"
      Thank you for your reply, but it still not works,
      Both the before code and the code after change 'CLIK_press' to 'CLIK_buttonPress' can compile with no error.
      I will try to check if i miss some other steps.

      Comment


        #4
        in widget initialized change the 'break' after the button to return true; and for default to this function return false instead of true, are you sure the button has enableInitCallback checked in flash?

        Comment


          #5
          I have the same question!

          How to solve it? Thanks for help!

          Comment


            #6
            maybe try changing 'CLIK_press' to 'CLIK_click' and also as i said above
            return true only when the widget is initialized (in switch case) and false otherwise (below the switch)

            Comment

            Working...
            X