Sunday, 26 September 2010

Embedding Fonts

Hey, I just found out that if you embed text in a text field, it loses that horrible grainy look that text has when it is loaded from another source!

Cool, I hate that grainy look.

UPDATE:
And now I just found out that embedded fonts allow dynamic text to show through a mask - just saved me about an hour's work, that may be an overestimate...

Saturday, 25 September 2010

Line Breaks - Apple vs Windows

Well, it's that time again...

What time?

Time to be incomprehensibly inconvenienced by stupid differences between one version of something and another version.

Why oh why is there a difference between text files in MS Windows, and Apple? It's a text file for goodness' sake - that's about as simple as it gets isn't it?

Apparently not.

First of all the text file wouldn't even load into Flash, because it had all this invisible gobbledygook at the beginning - visible in Notepad or Dreamweaver, but not MS Word...

And even when that is all deleted (I copied the text from MS Word and pasted it into Dreamweaver) there are still invisible line breaks!

So I'm going to do a search and see if I can find an alternate way of saving this so I don't have to go through and manually add unicode line breaks.

UPDATE:

OK - First I tried looking at the invisible characters and using 'Shift+Enter' and also, changing the format to 'Normal-No spaces'.

Neither worked.

And now I've tried saving it as Unicode and other txt formats, but nothing worked, the invisible characters are still there. So I will have to go through and change all the line breaks to %0d.

Oh well.

Wednesday, 22 September 2010

SetInterval

I hardly ever use this, but in all honesty, it is very useful.

The code below is what I have used for a button which starts or stops the setInterval method. This is AS2 code.

var methInterval = null;
btn.onRelease = function () {
if(methInterval == null) {
methInterval = setInterval(meth,200);
} else {
clearInterval(methInterval);
methInterval = null;
}
}

There may be a more graceful way to do this, but this worked for me. If you trace the interval after clearing it, you get numbers anyway, and I think the number goes up by one each time you set it, so why not just set it to null when you are not using it?!

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.

Monday, 12 July 2010

Sending/Loading... Something

I have to look this up every single time, so I thought I would put it somewhere easy to find:

function submitData() {

var nRequest:URLRequest = new URLRequest('backend.php');
nRequest.method = URLRequestMethod.POST;
var dataObj:URLVariables = new URLVariables();
dataObj.someInfo = 'some information';
nRequest.data = dataObj;
var loader:URLLoader = new URLLoader(nRequest);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(nRequest);

}

function onComplete(evnt:Event) {

var rVariables:URLVariables = new URLVariables(evnt.target.data);
trace(rVariables.someReturnedValue);

}

So in summary,

URLLoader --> URLRequest --> URLVariables

Friday, 2 July 2010

Events and Priorities

Just a note for future reference:

I tried using the priority parameter of a MouseEvent listener, to make the listener on the root get called before the listener within the movie clip, but it wouldn't work.

It was, however, able to distinguish between two listeners on the root timeline...