how te get input from user and store it into vars?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
payton
Posts: 10
Joined: January 30th, 2009, 4:11 pm

hi guys,
im trying hard doing some needfull stuff in the new company that im working for.
all i did right now was some flash actionscript 1.0. aescripts are not really intuitive for me at this time.

i want to force the user to fill in some forms and then generate text layers with this information applied.

what i have so far is some "stolen" stuff from other discussions here.

Code: Select all

function myArtistNameValue() {
myArtistNameString = this.text
}

function myLutValue() {
myLutString = this.text
}

function myCommentValue() {
myCommentString = this.text
}


function ShowDialog()
{   
var my_dialog = new Window("dialog","Slate Creator");
my_dialog.bounds = [200,200,450,410];
my_dialog.add("statictext", [10, 10, 250, 30], "Enter information: ");

//Field for Artist name -- then assigns variable
var artistNameInput = my_dialog.add("edittext", [10, 30, 240, 50], "-");
artistNameInput.onChange = myArtistNameValue;

//Field for LUT -- then assigns variable
var lutInput = my_dialog.add("edittext", [10, 60, 240, 80], "-");
lutInput.onChange = myLutValue;


//Field for Comment -- then assigns variable
var commentInput = my_dialog.add("edittext", [10, 90, 240, 110], "-");
commentInput.onChange = myCommentValue;


okButtton = my_dialog.add("button", [10, 130, 120, 150], "OK", {name:'ok'} );
cancelButton = my_dialog.add("button", [130,130, 240, 150], "Cancel", {name:'cancel'});

// display the dialog..
return [my_dialog,artistNameInput,lutInput,commentInput];
}

var dlg = ShowDialog();
var showDlg = dlg[0].show();

myLayer = myComp.layers.addText(dlg.artistNameInput);
how do i get the last line, that adds the text layer working as expected?

thanks in advance,
payton
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

This should do it:

Code: Select all

{
	function myArtistNameValue() {
	myArtistNameString = this.text
	}

	function myLutValue() {
	myLutString = this.text
	}

	function myCommentValue() {
	myCommentString = this.text
	}

	function ShowDialog()
	{   
	var my_dialog = new Window("dialog","Slate Creator");
	my_dialog.bounds = [200,200,450,410];
	my_dialog.add("statictext", [10, 10, 250, 30], "Enter information: ");

	//Field for Artist name -- then assigns variable
	var artistNameInput = my_dialog.add("edittext", [10, 30, 240, 50], myArtistNameString);
	artistNameInput.onChange = myArtistNameValue;
	artistNameInput.active = true;

	//Field for LUT -- then assigns variable
	var lutInput = my_dialog.add("edittext", [10, 60, 240, 80], myLutString);
	lutInput.onChange = myLutValue;

	//Field for Comment -- then assigns variable
	var commentInput = my_dialog.add("edittext", [10, 90, 240, 110], myCommentString);
	commentInput.onChange = myCommentValue;

	okButtton = my_dialog.add("button", [10, 130, 120, 150], "OK", {name:'ok'} );
	cancelButton = my_dialog.add("button", [130,130, 240, 150], "Cancel", {name:'cancel'});

	// display the dialog..
	return my_dialog.show();
	}

	var myArtistNameString = "-"
	var myLutString = "-";
	var myCommentString = "-";
	var dlg = ShowDialog();

	if (dlg == 1) {
		var activeItem = app.project.activeItem;
		if (activeItem != null && activeItem instanceof CompItem) {
			var myLayer = activeItem.layers.addText(myArtistNameString);
		}
	}
}
payton
Posts: 10
Joined: January 30th, 2009, 4:11 pm

you made my day!
thanks for the help.

payton
Post Reply