change variable in SWF with PHP
I have written a php script that changes the value of a string within a SWF file. I use the php script on the server side to hard code new values for variables in a SWF.
I wrap values in xml tags to identify the variables. For example, in the Flash authoring tool I create an actionscirpt variable:
fristname = "<fn>First Name1</fn>" // has 20 characters
The php script opens the SWF, and finds and replaces the text within the <fn> tags with my new text value.
The problem is that the SWF file expects the character length of the variable value to be the same length as the original value (20 characters in the above example). There is a binary value that defines the length of the firstname variable. Flash will not display the swf if the value is not the exact length that the binary value defines. I can work around this when I pass values shorter than the original, by padding the string with spaces, but do not have a solution for longer values.
// pad the new 7 character string with 5 spaces so the entire string totals 20, including the tags
firstname = "<fn>new val_____</fn>"
My next goal is to use php to change the binary value of the variable length so that it matches the string I want to insert, so I do not have to truncate strings that are too long and pad strings that are too short.
So I want to be able to use php to write any new string into a given variable.
Are there any PHP based open source solutions that do something similar? I am using a shared web server and cannot install c libraries like MING or com objects. So this would be a php solution only.
If not, can someone help me understand how I would find and change the binary value of the variable? I can follow up with php specific questions in another forum, I am just trying to get some understanding of how a script might find the variable corresponding to a given text within a SWF file, read and write the binary value defining the length of the variable.
Thanks for any help or suggestions.