×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Creating a file name out of a textInput text property

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

RE: Creating a file name out of a textInput text property

outputFileName = the moviePath & partIdStr & ".txt"

Kenneth Kawamoto
www.materiaprima.co.uk

RE: Creating a file name out of a textInput text property

(OP)
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

RE: Creating a file name out of a textInput text property

prtIdStr = sprite(1).text

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

(OP)
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

RE: Creating a file name out of a textInput text property

> Any ideas what's causing this?

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

(OP)
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

RE: Creating a file name out of a textInput text property

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close