soledad penadés
repeat 4[fd 100 rt 90]

Archive for the ‘flash’ Category

20080717 How to crash Flash Player in few lines

I tried this with the stand-alone Flash Player, versions 9.0.45 and 9.0.124. I was hoping to crash the browser too when executing the malicious code inside a browser but that didn't work :-/

Anyway this is how you would proceed if you wanted to crash your Flash Player. Or this is what you shouldn't do if you do not want that to happen…

  1. Create a URLStream
  2. Add to it an event listener for HTTPStatusEvent.HTTP_STATUS
  3. Load a url which won't return a 200 OK status code
  4. When you receive the HTTP_STATUS event, close the URLStream
  5. CRASH!

This only happens in Windows.

And here's the bug in Adobe's bug management system (mainly so that I can remember where is it and because the search engine there is terrible too!)

20080228 Open source Flex is great

As I found about the news, I spent some time yesterday having a look at the project's files. It's always interesting to have a look at the internals of the software for curious-like-a-cat people like me… but honestly, I'd rather have the Flash player open sourced. That would help to fix, or at least to explain, those absurd issues one finds from time to time when working with Flash.

Even worse: each new version of Flash player introduces slightly different issues. Or bugs, if you prefer. For example, the latest one (9.0.115) has a funky way of playing sound files. If the sample is 44KHz, everything is fine. But if you had a one minute sample with a different rate (say, 22KHz), you can't simply say go to the second 30 and play, because it will instead go to the second 60 (and hence, finish playing!).

And yes, the issue tracker is now accessible to the general public and so you can directly report these odd behaviours directly to Adobe. See here, here and here for some flash.media.Sound errors already reported.

I'm sure if more people could have a look at the player source, these oddities would be fixed way earlier, or at least they wouldn't be released to the general public with a major bug like that one introduced so lightly.

It would also make easier to have updated versions of the Flash player in platforms which currently are always a step behind, because they need to wait for Adobe to release them, or do not have support at all, like Linux PowerPC (at least, it hadn't, last time I tried).

Unfortunately I have the feeling this won't happen any time soon. With DRM dangerously approaching the path of the player it would be quite surprising to have the source code so that everybody could find work-arounds to those restrictions if they feel like. And it would destroy Adobe's monopoly too, of course. Which I guess they prefer not to happen.

20071211 UTF-8 checklist

Following the discussion in the previous post (Reasons for using UTF-8) I thought it could be interesting to gather a series of steps needed to get a UTF-8 friendly environment.

I'm going to focus on php and mysql, because using mysql and ruby/rails and utf8 tends to be kind of easier (specially since newer Rails versions suggest mysql which charset to use when connecting automagically for you), but the advice can be applied to both platforms in any case.

In your preferred editor

Make sure your editor is set to use UTF-8, specially when editing templates and any other file which is used for building output content. If you include any non-ASCII content (for example, accented words) and they are mixed with more UTF-8 content (from other templates or sources), things will get messed up.

In your html/xml code

Make sure the document's charset is specified.

In HTML documents you would accomplish this with the content/type meta tag, which you should place in the header:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

In XML documents this is done in the XML declaration, which needs to be placed at the immediate beginning of the document:

<?xml version="1.0" encoding="UTF-8"?>

I have heard recommendations for placing the page title immediately after the Content-type has been declared, so that browsers can switch to the right charset immediately if the page title includes any non-ASCII code, but it sounds a little urban myth to me.

I have also seen people recommending to specify the encoding in every form you have in your site, but I haven't found any difference between doing it or not.

In Apache

Make sure the content is being served as UTF-8. A good AddDefaultCharset utf-8 should do. You don't need to change all your hosted content into UTF-8 if you don't want to, charsets can be configured per virtual hosts as well.

In the database

Make sure mysql is configured to use UTF-8 at server level.

Before issuing any other query, and right after you've connected to the server, execute

SET NAMES 'utf8';

It seems otherwise mysql will not recognize properly the character set that the client is using (!!) and will return bad data.

Of course, when you create the tables, make sure that every column which can include text data (this includes TEXT, VARCHAR, etc) is using utf8 as well.

In php

I rarely need to send a header specifying the content-type, but if things are not working totally fine you could also try to manually specify the content type with the header:

header('Content-type: text/html; charset=utf-8');

Or application/xml, whatever you need!

In Flash (or Flex)

Do not use systemCodepage. Flash assumes XML is UTF-8 so if everything else has been properly set up, Flash will be served UTF-8 content, which is what it expects, and we'll be happy :-)

One more thing

Although generally it's a good idea to run a validator, it's even a better idea if you're doing utf-8 stuff and want to make sure you're not outputting bad stuff inadvertently. Validators are picky (even more if we speak about XML validators) and will cheekily reveal your inappropriate characters.

Missing something? Anything wrong?

I'm not an expert and I may easily have forgotten something so if you think something is missing or plainly wrong you know what to do ;-)

And before you ask - I don't have any experience with Pylons, Django, TurboGear, Zope or whatever your favourite Python framework is, so feel free to share with us your experience.

20070924 Security sandbox violation? How come!

I've received a few error reports on a for-fun-only flash thing/experiment/joke I did some time ago, the next captcha generation for myspace forms.

At first I thought it had been my fault, due to my inexperience in flash, but after having been working more time with sounds in flash, I found the problem is not in my code but in Flash's internals. For some reason, if you're calling, for example, computeSpectrum in one movie and at the same time there's another flash movie being executed and playing any type of media in another tab, your movie will begin to trigger Security sandbox violation errors.

It seems to happen because the player doesn't distinguish between different movies, and treats all the sounds as if they belonged to the same soundspace (like a namespace, but for sounds :D), hence it tries to mix them all together and process the soundSpectrum of this global mix. Obviously, they don't belong to the same domain, and that's why you'll soon get errors.

And you might wonder what's going wrong, because you've got your policy files and everything sorted out, everything seems fine but it's not when you try to access global sound stuff. Hopefully now you know why (although you can't do anything about that).

I'm not sure if this should be an expected behaviour or they just didn't think that we could execute several flash movies in different tabs. Obviously, this only shows up if you're using the debug version of the player. In any other case, all these errors are lost in a flash log file which is hidden somewhere in your hard disk.

Anybody knows of any solution or work around? It seems to be happening to a few more people as well.

20070713 Thumbs up for FlashDevelop

Some weeks ago I said bye bye to php, html, css and all those pain inducing drugs for a while, and switched to work mainly with Flash. At the beginning I was using only the Flash IDE and external editors, as I had done since ActionScript2 appeared on stage (pun!!). But I still had a pending task in my to-do list: to have a look at FlashDevelop, specially since Zarate talks so much about it ;-)

I started using FlashDevelop a couple of days ago and I must say that it absolutely makes a difference, and what difference! Once configured, it detects my classes, methods and properties (showing an Outline panel) and helps me writing code with some autocompletion love each time I press the magical dot key, unfolding a list with available methods and properties for the active object.

I suddenly got back that I'm programming for a compiled language feeling. It was so cool! It felt like programming in Java again, but without Java annoyances.

There are some small details that I still haven't had time to tweak, like the sorting method in the outline (currently it seems to be listing everything in the same order than it was defined), or configure it to use Flex2 compiler and all that. But even if I'm just scratching the surface of what can be done with this program, I strongly recommend it. The autocomplete feature is worth a try by itself!

On a side note, I still don't get how Flash's IDE is so 1998 in what regards to the Code editor (the Actions panel). It looks as if it hasn't been given much attention, presumably because they dedicated more resources to Flex and its editor instead.