Creating a file name out of a textInput text property
Creating a file name out of a textInput text property
(OP)
I'm trying to create a file tracking the rotation of a 3D model. So far the model rotates, tracks the rotation, and writes the rotation correctly. The problem is that I can only get Director to write the file name using a set value. For example, this is the current piece of the script that I'm using to create the output File name:
outputFileName = the moviePath &"test.txt"
I have a textInput box at the beginning of the movie named ParticipantID. I want the text value from that box to be the filename, but I can't get the value from the box. The current script is:
partIdStr = member("ParticipantID").text
outputFileName = the moviePath & ParticipantID & ".txt"
When I do this, though, the filename is simply ".txt". There is no value to the ParticipantID variable even though I have put in a set of numbers/letters. Any ideas?
Thanks,
Anthony
outputFileName = the moviePath &"test.txt"
I have a textInput box at the beginning of the movie named ParticipantID. I want the text value from that box to be the filename, but I can't get the value from the box. The current script is:
partIdStr = member("ParticipantID").text
outputFileName = the moviePath & ParticipantID & ".txt"
When I do this, though, the filename is simply ".txt". There is no value to the ParticipantID variable even though I have put in a set of numbers/letters. Any ideas?
Thanks,
Anthony
RE: Creating a file name out of a textInput text property
Kenneth Kawamoto
www.materiaprima.co.uk
RE: Creating a file name out of a textInput text property
outputFileName = the moviePath & partIdStr & ".txt"
Here's a post I made on another forum explaining my problem a little bit better:
------
In my project I have a textInput show up at the beginning of the movie named participantID. The point of this input is to store the ID# of the user to use when creating the file at the end of the movie.
The problem is that when I use this script:
prtIdStr = member("participantID").text
the variable "prtIdStr" is empty even when there is text or numbers in the box. When I give the textInput a default value in the "Flash Component" panel, that default value is given to the "prtIdStr" every time. Even if I delete the default value at runtime and leave the box blank, the default value is given to the variable.
Any ideas on why this is?
------
Thanks for the help.
-Anthony
RE: Creating a file name out of a textInput text property
Change sprite(1) to the sprite channel where your Flash TextInput is placed.
Kenneth Kawamoto
www.materiaprima.co.uk
RE: Creating a file name out of a textInput text property
Now I'm trying to implement it into my main project here, and I'm getting the "property not found" error again. I can't get past it this time, though. I'm just using the script:
partIDStr = sprite(13).text
Any ideas what's causing this?
Thanks again,
Anthony
RE: Creating a file name out of a textInput text property
Director cannot access Flash Sprite's property until Flash Sprite object is initialized.
Kenneth Kawamoto
www.materiaprima.co.uk
RE: Creating a file name out of a textInput text property
I ran into a different problem now, though. I had a script to open a file, and that worked perfectly. After solving the problem with the textInput, though, I went back to the this other script because I wanted to get the file name of the .w3d file separated from the entire path. Here's the script:
---------------------------------
on mouseUp
global modelFileName
global newModelFileName
tmpFileObj = new xtra("fileio")
modelFileName = tmpFileObj.displayOpen() -- select a File
if (modelFileName = "") then
-- user cancled - there is no File selected
-- TODO: Display a message to the user
nothing -- to do
else
-- ok - tempFileName is a file path
-- TODO: What if the user picks a file that is not a .w3d file????
-- TODO: -- Figure out how to tell if a file is a .w3d file
-- TODO: -- Test the file to make sure it is a .w3d file
-- TODO: -- Display a message to the user if it is not
-- Load the 3d model into cast member #1
member(1).importFileInto(modelFileName)
-- Loading the model from a file sets the cast member name
-- to the file name, so reset it. Other scripts depend on the
-- cast member name being "3d".
member(1).name = "3d"
newModelFileName = ""
currCount = length(modelFileName)
currChar = ""
repeat while currCount <> 0
currChar = chars(modelFileName, currCount, currCount)
if currChar = "." then
newModelFileName = ""
currCount = currCount-1
else if currChar = "\" then
currCount = 0
else
newModelFileName = currChar & newModelFileName
currCount = currCount-1
end if
end repeat
end if
end
------------------------
The repeat while section is the new addition. The problem is that even though this worked perfectly before, and up through most of the writing of the string manipulation, it won't work now. Just as I finished up the repeat while loop, I tried running the movie and opening a file. It's like Director inserted its own break at the " tmpFileObj = new xtra("fileio")" line. Whenever I hit this button, the debug window comes up with the arrow marking this line like I inserted a break, and then when I tell it to continue I get the error:
"Script error: Script cast member not found
tmpFileObj=new xtra("fileio")"
The other thing is that if I open a new movie, place a button in it, and copy and paste this exact script to the button, it works perfectly. Even the string manipulation works. I tried completely rebuilding the file by moving every cast member to a new file, but the same problem occured once I got it set up.
Any ideas would be amazing.
Thanks again,
Anthony
RE: Creating a file name out of a textInput text property
Kenneth Kawamoto
www.materiaprima.co.uk
RE: Creating a file name out of a textInput text property