JPEXS Free Flash Decompiler Issue Tracker

If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler

NEW : We have got a new blog where we post some interesting SWF internals info.

List of issuesList of issues

#2494 How to change a DefineText by using ActionScript?
Author:
Date created:
Type: question
Visibility: Everybody
Assigned to:
Labels: Text
State: opened Help

Hello, I'm currently working on translating an old visual novel from Japanese to English. The text translation itself is done, I just need to put the English text into the game's DefineText objects. I already have fonts for both languages. Ideally I want to offer users the ability to choose the language at the title screen, and then the game displays the text in that language for each screen (frame). I have this handled with a variable "language" that is set to "English" or "Japanese" by clicking a button on the title screen. I'm thinking that each frame can have a script with a switch statement, which checks the value of the variable "language" - if it's Japanese, then display in Japanese (default); if it's English, then access the DefineText object for that frame, change its font to the English font, and change its text to the English version of the text. However, I am not sure how I can access the DefineText objects from within an ActionScript? This is my first project using the JPEXS decompiler, so I'm very new to this. Any help would be appreciated.
As far as I know, DefineText and DefineText2 tags are static texts which do not have assigned any variable name. You must use DefineEditTexts, assign a variable name to them, then you can modify them while playing.
State: new→opened
Hmm, is there something special I need to do to access a DefineEditText tag that I've named? I've made a new DefineEditText tag with the variablename "ENtext32" (since it's meant to replace an existing DefineText tag with a chid of 32). Then I've added a script to the frame where the DET tag appears, and I've tried a trace statement just to make sure I can access it by the variable name. The statement is trace(ENtext32);, and I've also tried trace(ENtext32.initialText); to see if I can access the text, and trace(ENtext32.font); to see if I can access the font. However, in all 3 cases the trace returns "undefined". I'm not sure what I'm doing wrong?
The variablename attribute of DefineEditText specifies variable for its text. So if variablename is "myVar", then in the actionscript, you can assign a value to it myVar = "hello"; or get its value trace("var=" + myVar); There are no subfields like initialText or font. You can set the edittexts font by assigning it a value like '<font face="Times New Roman" size="20" color="#00ff00" letterSpacing="0.000000" kerning="1">abc</font>'. See attachment.
Downloadtextvar.swf (12 KiB)