Add a temporary variable to an array

So I’m trying to add a temporary variable inside a function to an array.
This variable is of a custom made class.

Unfortunately I can’t seem to get it to work. The array increases size but when I “call” for the variable it always comes out emtpy unless I declare it outside the function…

Here is the current code where I add the variable:

var pickUpAction : PlayerActions;
function PickUp (selectedObject : Transform){

	//Add a pickUpAction
//	var pickUpAction : PlayerAction; //this is where I wanted to have the variable so it disappears after being added.
		pickUpAction.interaction = PickUpAction;
		pickUpAction.selectedObject = selectedObject;

And here is the example of a function that later on uses it:

function DoAction (){
	currentAction = (globalActions[0] as PlayerAction);
	currentAction.interaction ();

and this is the class of the variable:

class PlayerAction {
	var interaction : function():void;
	var selectedObject : Transform;
	var selectedDestination : Transform;
	var selectedPosition : Vector3;

I’m quite new to programming so sorry if I’m missing the obvious!
Any help very appreciated.

I think you are looking for:

       var pickUpAction = new PlayerAction();