FightSkillz.com - Life, Code, & Idiocy

Posts Tagged ‘Flex’

Adobe Flex/Air Bug – Serving Content via PHP

Monday, February 1st, 2010

I've been using a php script as a gateway to fetching certain content from a server, mainly mp3 files. There are a bunch of reasons for doing this, the main ones would be to be able to easily log which files are being accessed, when, and by who - and if you plan on creating widgets for your users to stream the content they upload to your site and they happen to put it on a heavily visited part of the web you can temporarily disable or limit that user's widget's access to content giving your other user's priority and preventing your server from crashing or being overworked.

So in the Flex/AIR app I've got a URLRequest that's used to load a Sound object. Instead of specifying the index.php it had been accessing http://domain.com?var1=blah&var2=blah. Usually this will redirect to the index.php sending it the post variables and letting it do it's thing and fetch the mp3. It works on Adobe AIR for Mac, it works in a browser on Mac/Windows. But in a URLRequest from Windows it doesn't work, confirmed for XP and 7. It doesn't just redirect to the /index.php file and drop the POST/GET variables, it actually just doesn't redirect anywhere, and you get an IOError. You'd think the redirect would be handled entirely by the server and transparent to the client, but it appears that for whatever reason, Adobe AIR on Windows just returns an IO Error.

Either way it's easy to fix, you just have to specify the index file in your URLRequest like so: http://domain.com/index.php?var1=blah&var2=blah.

Adobe AIR, Flex, and Socket Policy Files

Monday, January 25th, 2010

You probably found this because you're trying to make a socket connection from Flex/Flash and getting the following error:

SecurityError: Error #2123: Security sandbox violation:

Adobe went through a number of phases making the rules for serving and checking Policy files stricter. There are different security sandboxes. If you publish your flex/flash application on domain.com, and the application attempts to load content from domain2.com, it will look for a Cross Domain Policy File at domain2.com/crossdomain.xml to get permission. It does this automatically, however you could specify the location of the Cross Domain Policy File in your flex application using the following method:

Security.loadPolicyFile("http://domain.com/remote_content/crossdomain.xml")

A Cross Domain Policy File only has authority to grant access to content below it in the folder hierarchy. So a policy file in /remote_content/ can't grant access to content in the root folder, and in addition a Policy File at the domain root can override any other policy file. It has maximal authority. Subdomains are considered separate domains - which as a side note most search engines see subdomains that way too.

Now that's Cross Domain Policy Files, In general Adobe Air applications operate in one of the local system sandboxes and has thus have access to content on any domain. This post is about Socket Policy Files. When you access regular web content you're generally connecting to your server on port 80 and being served content by Apache or whatever web server you happen to be running. When you do this you're using http protocols under the hood and never have to deal directly with that crazy stuff. If you want to make a raw socket connection to your server you will need to serve up a Socket Policy File on a specific port.

First I just want to stress the difference between a Cross Domain Policy File and a Socket Policy File. For some reason my dyslexia and the ton of misleading, vague, and now out of date and incorrect information I kept thinking they were the same thing. Second there is no way as far as I'm aware to serve a Socket Policy File with Apache.

The default port for flex/flash to search for a socket policy file on port 843. There are several places on the web that talk about being able to connect to higher port numbers without a Socket Policy File, well that doesn't seem to be the case anymore. Just assume that any raw socket connection from a flex/flash client requires a Socket Policy File.

You can serve the Socket Policy File from the port you're connecting to, but this is tricky considering the manner in which Flex/Flash goes about loading the Socket Policy File and rewriting the service to serve this up, especially if you're using server software built by someone else, means it's just better to keep the Socket Policy File Server as a separate always running entity on the system.

Now in the simplest implementations you need a process either written in python, perl, c++, php cli, or whatever. It needs to be listening on port 843. It has to wait for - very specifically - the following string<policy-file-request/> followed by a NULL byte. Upon receiving that it needs to serve up the policy file which needs to at least have allow-access-from domain set to *, and to-ports set to *. You should use the links at the end of this post to familiarize yourself with the differences between and all options you can specify in Policy Files. It's easiest to keep the Policy File as an actual file, instead of adding the text of the file to your custom server code. And that's it!, now you can go on with a better idea of what information out there is out of date or not.

Here are some important links to help you on your journey:

Adobe on setting up a Socket Policy File Server

Adobe on Policy File changes for flash 9 and 10

Adobe on the structure of Policy Files

An intro to Sockets

Working PHP Cli Socket Policy File Server

Composite Update on Things Cause More Than One Post Seems Silly

Friday, September 25th, 2009
Google is working on Google Chrome Frame, which is a plugin for Internet Explorer. Think of it like the Flash plugin, except instead of Flash, it gives IE the ability to read modern Javascript and HTML and even more importantly the ability to read Javascript without failing, throwing errors and the incompatibility that Internet Explorer innately has with all other browsers, code, and between versions of itself. Google Chrome Frame is a WebKit/V8 plugin - for browsers who's developers refuse to follow the standards. You can now easily prompt IE users to install the plugin and the page renders like it would in Chrome and Safari. It's still early on in the project, and requires XP SP2 or greater. I don't believe anyone still using Internet Explorer has the where with all to install a Service Pack, but if they did they'd also have upgraded at least from IE6 and yet there are still plenty of people stubbornly using it. I think Google Chrome Frame is ingenious, but doubt it will be the silver bullet needed to kill off IE. I'd like to see some accurate market research on browser/os share, who's using what and why. I believe people still using IE fall into two categories. Those that are ignorant, hate the web, or themselves; and those who are forced to by stuffy silly IT guys at work who outrageously believe that IE with all it's gaping unpatched security holes and incompatibilities is somehow a good choice for their IT environment. Also on the Google side is Google Analytics for Flex/Air applications. There's been workarounds for a while where you could bridge to Javascript from Flash to trigger Analytics events. Now you get some Actionscript tracking code and classes which you can call as part of your navigation/deeplinking procedures. Next step is to be able to index Flex/Air apps... hmm... Also from Google, I've stumbled across it before but if you haven't go have fun in their Code Playground Next up is Intel, who've developed a new technology to replace copper wires called Light Peak. Essentially Fibre Optics for the wires inside your computer, and possibly everywhere else. Capable of transmitting data at 10Gb/s (1.25GB/s) with future versions being capable of up to 100Gb/s (12.5GB/s). At those speeds you could copy the entire contents of a 1TB hard drive in under 2 minutes. Wow, pretty soon YouTube will be in Blue-Ray quality and Blue-Ray will go the way of VHS.. anyone surprised? Also Intel related are the new Core i7 chips that are slowly being rolled out. And the rumours surrounding Apple's October Special Event, where word on the street is they'll be unavailing Core i7/i5 chips across the board and price reductions to compete for the holiday season. If only they'd get better screens on the iMac... here's hoping. In the open source world I was introduced to FLARToolKit today. Augmented reality for Flex developers. The demos have you print out an image marker that the code looks for. You turn on your webcam and it calculates the 3D space based on the marker and superimposes a 3D animation that in real time follows the marker around rotating tittling and putting on a really impressive show. There was other stuff but I'm writing this when I should be coding, and I could have done without the 30 articles I just read too..

Interactive ChalkBoard

Tuesday, January 13th, 2009
We've put up an interactive chalk board on my company's website. Draw us something cool, fill out some optional details, and submit it for a chance to be featured in our gallery. If we like your website we'll contact you to do a spotlight on your blog/site/company. All the artwork submitted, including those that don't make the cut for the main gallery, will be featured here on FightSkillz with a link back to your site. Here are the links you'll need to check it out: Draw us something: http://www.chalk-it-out.com/#/Draw/ The main gallery: http://www.chalk-it-out.com/#/Draw/Gallery/ The runner up gallery: http://fightskillz.com/chalkboard-gallery/ You can submit as many chalk boards as you like, the sooner you submit the more people are gonna see it. While you're at Chalk-It-Out, have a look around we're a software development and consulting company. We build web, desktop, and rich internet applications, and offer a range of other services like brand creation and design, custom widgets, web sites and more.
If you want to record yourself drawing your ChallkBoard post it in reply to this YouTube video. http://www.youtube.com/watch?v=38uTZwbUHdY http://www.prlog.org/10166524-fun-interactive-web-site-promotion.html