Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a file name out of a textInput text property 1

Status
Not open for further replies.

Veach

Programmer
Jun 14, 2006
14
US
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
 
Yeah, sorry. That was actually a typo. I already had it set to

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
 
So this just got kind of strange. Thank you for the help, first of all. I tried that and it worked on a different project I was testing it on. The problem is, in that project I had two textInputs, and it worked on one and not the other. The first textInput had the text property set to the variable, but the second kept getting the error "Property not found." I managed to fix this by repeatedly deleting the textInput object and making new ones until one worked. I had the settings identical to the working textinput, so I have no idea what was causing that.

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
 
Awesome, that did it. Thank you. I was having some trouble before, because even though the sprite is #6 in the cast list, it's somehow sprite(1). Does that number just come from the amount of sprites available in the entire cast instead of every cast member?

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
 
Yeah, I tried simply changing the name for the fileio xtra, and it worked fine. Director must of just been having its own issue for some reason.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top