Thursday, 12 August 2010

DIV again

OK, next problem.

I realised that I very stupidly, and I won't say too much about the details, put, shall we say...sensitive info...right there in the viewable source of the html file. Pretty much rendering the whole thing completely useless.

Rather than make large and potentially catastrophic changes to the flash file, I want to tell the html file to hide the info when it has finished passing it to the swf, using DIV tags.

I have recorded on this blog how to change attributes, but forgot to mention how to change the stuff between the div tags! Stupid me. I know I worked it out before, but now I have forgotten and will have to do the whole thing all over again.

But this time, I will, insha Allah, record it for posterity.


<script type="text/javascript">
function alterTags() {
var tTag = document.getElementById("tElement");
tTag.innerHTML = "tag content";
}
</script>
<div id="tElement"></div>


That should work.

UPDATE:

OK, that code above does work - but it won't do what I want it to. You see, the page changes according to what the DIV tags say, but when you view the source, you still get to see the original.

So I will have to make some serious changes to the Flash file.

Friday, 6 August 2010

Line breaks

OK, so...

I am entering text in a flash text field, which gets sent to a mysql database. This later gets retrieved by php, and folded into a javascript function, so that another swf can use that data.

The problem is, if there are any line breaks in the initial text, then that ends up in the javascript function, and is seen as an error.

So to solve it, I will attempt to get the php file that takes the text out of the database, to convert that line break into something that the javascript function can stand, and that the swf can interpret.

Continuation -

Yeah, that worked. First I tried nl2br, which is supposed to put html linebreak tags where the line breaks are, although I din't see this effect. But this would have required me to make changes to my flash file.

So I used:

$lineBreaks = Array("\n","\r");
$iQuestion = ...get text from MySQL database
$oQuestion = str_replace($lineBreaks,'\u000d',$iQuestion);

$lineBreaks is an array of possible ways in which the line breaks may come down, I wasn't sure if this would differ depending on the user's operating system etc.