Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Passing data to a function help!

New Here ,
Aug 01, 2016 Aug 01, 2016

I'm currently in the process of modding a menu of a game and I'm trying to enable a debugging menu.

The menu is a series of checkpoints, and when you select one you are supposed to be teleported to the correct location and at the correct point of the mission for that checkpoint.

I've managed to successfully enable the visibility of the menu so I can see it and use it, but selecting any checkpoint on the list always just loads up the first one.

Now, I know that all the debug checkpoints in the game work because I have changed the script of the menu so that it doesn't get the value of the checkpoint to load from the selected menu item, but it gets it from a preset value. Changing this preset value allowed me to load different checkpoints without issue.

So I think I've narrowed the issue down to data not being passed from the "event handler" to the function (at least I would imagine that is the issue?). I've included two relevant sections of code below.

The function which creates each "Debug Checkpoint" selection on the menu:

public function addDebugCheckpoint(param1:String, param2:String, param3:int) : void

{

    var _loc4_:MenuItem = new MenuItem(param1,this.debugCheckpointHandler);

    _loc4_.description = param2;

    _loc4_.data = param3;

    this._debugCheckpointsItem.page.addItem(_loc4_);

}

The "debugCheckpointHandler" function which is supposed to call the script to load the selected checkpoint:

protected function debugCheckpointHandler(param1:MenuItemEvent) : void

{

    this.call("jump_to_debug_checkpoint",param1.item.data as int);

}

I think the issue is based around what data "param1" is receiving in the "debugCheckpointHandler" function, maybe if it's not getting any data then it's always defaulting to 0 because it's set as int, hence always loading the first checkpoint?

Here's the link to the entire ActionScript file. It would be greatly appreciated if someone could help me out!

Thanks!

EDIT: I've just done a few little tests and I think that "param1.item.data" isn't returning anything. This is most likely the issue. Does anyone know why the ActionScript isn't passing data across?

TOPICS
ActionScript
189
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 02, 2016 Aug 02, 2016
LATEST

You should learn how to use the trace() function to help follow the processing so you can check to see if data is going where you want it to go.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines