Click or scroll down Circle me on Google+ Fork me on GitHub Follow me on Twitter Ask me on Stack Overflow Gild me on Reddit Code Ninja, Entrepreneur, Idiot ChalkHQ — consulting, prototyping, mentoring HighF.in — resolve innefficiencies in your startup's workflow DearDrum.org — online open-mic / creative space The Dirac Equation (click to WikiPedia) A maxim Sun Tzu references in his magnum opus The Art of War

If you know the enemy and know yourself, you need not fear the result of a hundred battles.
If you know yourself but not the enemy, for every victory gained you will also suffer a defeat.
If you know neither the enemy nor yourself, you will succumb in every battle.
Fork me on GitHub

Tags

actionscript ad-hoc networks Adobe AIR anonymous Apple array Browsing convert Debugger Error Facebook file permissions Flash Flex fonts function future Google Google Plus grid hackers html javascript logs loop network p2p php privacy regexp Security Server social ssl technology terminal time Twitter upgrade Web 2.0 Web 3.0 Web 4.0 Web 5.0 wordpress

Featured Posts

  • Javascript: Undefined parameters
  • The Web, A Look Forward
  • Let Postfix send mail through your Gmail Account – Snow Leopard
  • Archives

  • April 2013
  • December 2011
  • July 2011
  • June 2011
  • March 2011
  • February 2011
  • January 2011
  • November 2010
  • October 2010
  • September 2010
  • July 2010
  • May 2010
  • Categories

  • Code
  • Design
  • Opinion
  • Security
  • Tools
  • Uncategorized
  • Tag: Flash

    Why I Chose OGG Vorbis as the Audio Format on DearDrum.org

    This is from http://deardrum.org/about/html5

    What is HTML5 and why do I need it?

    To put it simply HTML is what websites are made of. HTML5 is just the newest version.

    DearDrum.org uses some pretty advanced stuff under the hood that's only available in HTML5. So in order to play audio on the site and do some other cool things you need a Web Browser that understands HTML5. (more on this below)

    Fortunately there are a few really amazing web browsers out there that do support HTML5 really well. And if you're not comfortable switching to a new browser there's probably a plugin for your browser to get you on board.

    Here are some quick links so you can get started, you only need one, but why not try them all if you have time. I'll go into a bit more detail and walk you through the issues below that if you're interested or confused by any of this.

    Links:

    Google Chrome is - in our professional opinion - the best web browser out there, hands down.
    Download Google Chrome

    Firefox is phenomenal too, and by far the most widely used browser that supports HTML5.
    Download Firefox

    Internet Explorer is, well, incompatible with everything. Google made a plugin called Chrome Frame which brings HTML5 to Internet Explorer. Despite some recent claims to the contrary IE9 will never support HTML5 by itself and requires Chrome Frame in all cases (more on this below).
    Download Google Chrome Frame for Internet Explorer

    Safari is in the same boat as Internet Explorer with regards to HTML5. They claim to support it but intentionally cripple its functionality. On a Mac you can install a plugin called XiphQT which will bring you up to speed. On Windows you'll need to switch to another browser to get proper HTML5 support.
    Download the XiphQT plugin for Mac

    Opera is a less known web browser that totally supports HTML5, and we love them for it.
    Download Opera

    So What is a Web Browser?

    Yeah yeah, I get it. Now What is HTML5? Really.

    You may have seen the code that makes up web pages. If you right click on this page you should see an option to view the source code of the page. That's HTML. Now the internet is an open place and as you can see there are lots of different browsers. So everyone kind of has to agree on the specifics of the HTML language. The specs for HTML5 aren't finalized yet but some of the more advanced browsers are already supporting most of HTML5 already. There is however a big argument going on surrounding HTML5 audio and video.

    At the end of the day HTML5 will have to be open, because the web needs to be open. Imagine if you had to pay $5000 a month to use Google, and that money wasn't even to pay Google, it went to some licence holder who owned use of the letter E... That would be terrible and there'd be no innovation on the web. There'd have been no Facebook or WikiPedia, and no DearDrum.org.

    What exactly is this HTML5 argument about?

    Up until now HTML has not had any built in support for audio or video. If you wanted to play audio or video on the web you had to use a plugin like Adobe Flash Player. Which is fine, but Adobe is a profit motivated company and the web is an open place, so in the interest of choice and freedom the new version of HTML, HTML5 does have built in audio and video support.

    Now the standards body that decides on what HTML5 will be is called W3C. Unfortunately the W3C is dominated by massive corporations who tend to dictate the standards in favour of their profit margin instead of what's best for an open, innovative web, and what's best for all of us. Up until now there hasn't really been much to debate over and it's been a long time since HTML4 came out anyway. Up until now Internet Explorer had majority market share and deliberately didn't follow the standards so web developers would have to focus on supporting IE's defunked and broken interpretation of HTML4. IE's massive market share was purely the result of being packaged with Windows. Microsoft has been sued over this anti-competitive practice because it directly hurt the web for so many years. During this time the other web browsers pushed to become faster and add amazing features to try gain as much market share as possible. It was IE vs. the world and Mozilla was their biggest rival with Firefox. If it wasn't for Firefox we'd all be eating dirt and living in shacks right now in a world where an open DearDrum.org could never even be conceived of.

    The problem with HTML5 audio/video support is that everyone needs to agree on an audio and video format; in the same way .txt is a text format and .jpg is an image format. The issue is licensing. There happen to be some really great audio and video formats out there that are open source, meaning they can be freely used and improved upon by anyone. There also happen to be a lot of big faceless corporations in the W3C, see a list here, some of whom own part of the licensing rights to a particular format known as H.264.

    When it comes to web browsers you have two sides of the argument. Those for an open web, and those whom want to charge everyone obscene amounts of money to use H.264. Currently the H.264 license allows people to use it. This free use has been extended to 2016 for the purposes of convincing non owners in the W3C - and the greater public, that it's free. After 2016 and quite frankly with the right high priced law firm any old time, that could expire and everyone would suddenly be charged $50 a day to watch youtube videos. Or $5000 a year to upload YouTube videos. If H.264 becomes the standard it would be a twisted joke and we would all be royally screwed.

    Microsoft and Apple both own part of the H.264 licensing rights. So they've chosen only to support that format. They could easily support both H.264 and WebM(the open, free format), but they don't because they're hoping that they can prolong the debate long enough that developers will have to support H.264 to reach the majority of people who use those two browsers - both packaged and preinstalled with their respective operating systems.

    Mozilla by it's very nature will always push for an open web, and Google's profit margin is directly tied to people's ability to generate content. Google went so far as to purchase the WebM format AND absolve the entire world from licensing fees should some obscure patent be discovered down the road and some sadistic person try capitalize on it. To Google it's a business expense, but it happened and it benefits everyone.

    The WebM format is a container format, which uses VP8 for video, and OGG Vorbis for audio. For DearDrum.org we decided to use OGG Vorbis as our audio format.

    Wow that was a lot to take in, so why does DearDrum.org use OGG Vorbis instead of MP3?

    While most your music is probably in .mp3 format, it costs a lot of money to transcode audio into the .mp3 format due to licensing. And who knows when that price will go up. When creating DearDrum.org I didn't want to be at the mercy of some company, and we didn't want to charge people to download and use the DearDrum.org Desktop App. We went in favour of choice, freedom, and openness because we value those ideals; and we want the web to remain an innovative grounds for inspiring new ideas.

     

    Flash FileRef Mysterious IOErrorEvent #2038

    This happened twice in the last two days and for the second occurrence I totally forgot what the issue was the first time I fixed it. So the lesson is blogging about this stuff as it happens saves time regardless of deadlines.

    So you're in Flash or Flex and your fileRef is failing to upload. Flash(Flex) Builder is telling you there's an IOError, but the line number given is where you set the local path of the File Reference. "WAHT!," you try an Event Listener and it does nothing. You vain atry/catch statement and it catches nothing. Despite what the compiler is telling you, you expand the try/catch statement to your whole uploading function hoping to narrow the issue down, but it does nothing. Finally you resort to Debugger breakpoints throughout the function and you discover it's actually being triggered by the call to fileRef.upload();. The possible causes just increased by an order of 50.

    Before you break something in your office, you should know that File Reference IOErrors can be triggered by a failing server upload script. Now hold on, you'd think IOErrors would only happen if the upload script URL was wrong or broken, like if you missed a semicolon in your php or some silly thing like that. But thankfully Adobe went the mysterious route and made this as ambiguous as possible. There are a ton of reasons why your upload script might fail in such a way that it triggers this error in flex, or in a non-debug version of your app just stay stuck at 0%, and it might not be immediately apparent or fun to track down. Reading this now you are appropriately upset, but wait another second.

    The first time this happened to me yesterday it happened because the upload name when I was getting the filesize of the temp upload file was wrong. In the following code that's the upfile1 part.

    $filesize = filesize($_FILES['upfile1']['tmp_name']);

    Then about 20 minutes later the same mysterious IOError popped up, but this time it was the server path I was moving the upload to. The path's are relative and I'm dyslexic, nuff said.

    move_uploaded_file($_FILES['upfile1']['tmp_name'], $incorrect_relative_file_path)

    Today however I was _shocked_ to find the crazy IOError because this time I knew all the paths were correct. In fact everything related to files was correct. I was sure, and I felt betrayed. (Once I re-realized that it wasn't a regular rational IOError... again). After a quickly unpleasant hunt through 1000+ lines of code I found a mysql query that was failing outside of an if/else clause. The reason it suddenly broke was that while editing the database at 5am this morning on no sleep I hit the wrong button -- so instead of deleting a column I accidentally dropped a whole table. There were two knew columns added since I backed it up that I had forgotten about in the haze, one of which caused the MySQL query to fail.

    I collapsed asleep last night with this unsolved, I had nightmares that alluded to it. Really. But after 5 hours the frustration overwhelmed my capacity for dreaming and I leaped out of the surreal scene and into another one --Dreamweaver. Now knowing this had a solution and that I'm not gonna have to run through a field at night with a town's worth of pitchforked locals chasing me I feel expansive relief. Makes me wonder if I'm doing this to chase that feeling or if it's just a side affect.

     

    Weird Flex Error #2006

    I was getting this weird error whenever switching from a given state to it's parent state in a Flex 3.5 based project.

    RangeError: Error #2006: The supplied index is out of bounds.
    	at flash.display::DisplayObjectContainer/addChildAt()
    	at mx.core::Container/addChildAt()
    	at mx.effects::EffectManager$/removedEffectHandler()
    	at Function/http://adobe.com/AS3/2006/builtin::apply()
    	at mx.core::UIComponent/callLaterDispatcher2()
    	at mx.core::UIComponent/callLaterDispatcher()

    It threw me for a minute because I hadn't made any changes to effects since I last tested the application and I couldn't see any connection between the code I had just written and any effects in the app. But after hunting around I found the culprit. There's a set of components in a Canvas that gets removed when moving to the parent state. What I had done was separate those components into two Canvases(Canvi?). For whatever crazy reason the new second Canvas can't have a RemoveEffect. The code works fine if just the first Canvas has it, but if both or just the second Canvas has it then it throws that error.

    side note: the reason it took me a while to find the source of the error was because I copy/pasted the canvas declaration only changing the id, and I forgot that there was a removedEffect associated with it.

    But wait there's more. The reason I split the components into two distinct Canvases was so I could position one below and the other on top of a third major component in z-space. The solution was to add the first Canvas as a "firstChild" and the second Canvas as a "lastChild". That it seems was the problem. In mxml when changing states you apparently can't add a firstChild before adding a lastChild. so I copy and pasted the first Canvas below the second one, so that all the lastChild additions occurred before all the firstChild additions and voila, presto, it works.

    The reason is that when you move from a state back to its parent state it follows the order in which you add components in the state declaration to remove them. If the first component you add is added as a firstChild then that get's removed first changing the indexes and number of children of the parent container. I guess the underlying state changing function already calculated what the lastChild index was, so when trying to remove a Child with the pre-calculated index of lastChild it triggered an index out of bounds error.

     

    Flex 4 Spark Button Weird Label Behaviour

    I'm currently migrating DearDrum.org Desktop to flex 4. Using an embedded font for the main navigation buttons; which are used to switch between states. When you're in a specific state the nav button for that state switches to a "selected button" skin which is just a copy of the regular skin with a few colours changed. The reason for doing that instead of just disabling each nav button in its given state is so they stay interactive, and are used when in the state to refresh/reload the state.

    This worked fine but now in it's spark implementation when moving between random states the button label if it contains a single space will occasionally jump around - providing you've rolled over the button before changing state. It would take a boring while to explain it in more detail so I just recorded the behaviour. Best watched in full screen.

     

    Flash Snippets for Flash Builder 4

    I'm getting used to Flash Builder 4, man is it fast. I came across this plugin by Lee Brimlow, it's SnipTreeView adapted to work with .mxml files and in FB4. Just download it from his blog and add it to the plugins folder, then restart. There's a quick video how to, highly recommended.

    Flash Snippets [http://theflashblog.com/?p=1494]

     

    The Future of Flash – Apple’s iPad

    The internet is a buzz with talk of the downfall of FlashFlash, the only web platform with 99%+ penetration rate cross platform, and 90%+ penetration rate for their latest version only 3 months after release. The platform that powers the web's content, games, and more than 75% of all interactive online media. That's now able to power desktop and mobile applications, and with the imminent release of Flash 10.1 will bring far more efficient and lower memory/ram usage. So much lighter on cpu in fact that it's able to play HD Youtube videos on mobile phones and netbooks without a problem. Yes, Flash, the downfall of Flash.

    There are two main arguments to this. The first is the emergence of HTML 5. HTML 5 finally allows video and audio playback without any plugins, and canvas - a tag which allows for complex drawing, embedding fonts, etc. etc. Things Flash has been able to do for years, has a huge head start on, and does really well. Flash has supplied us with everything from video streaming to blackjack, and even website design as a whole, and yet HTML 5 is supposed to just oust the holder of the crown and sceptre when it's finalized? I don't think so. The problem nobody seems to get is that Internet Explorer still has a majority market share, by a lot depending on who you ask - and Microsoft will likely NEVER support standards because it directly counters their business model. Aside from that, and the fact that every browser that will support HTML 5(ie: everyone else), will implement it differently from each other, with different aesthetics, features, code, BUGS, etc. But even more crucial the HTML 5 spec itself is not even complete yet. It's not even finished, and it's unfinished in a deadlock between the web giants who not only can't decide or agree on which video and audio formats are the best performance wise, but also who owns the rights to implement those formats in their browser and who'll have to pay massive royalties should the true patent holders (still somewhat unknown for sure) decide to cash in. No one wants to properly look this up for a variety of reasons and so HTML 5 - supposed to bring the web together and herald a new dawn of the internet can only work if EVERYONE does in fact come together and implement it in exactly the same way; disregarding that ubiquitous HTML 5 means EVERYONE loses something, some everything.

    The other main argument is the Apple iPad - just announced. Which like the iPhone doesn't support Flash. Apple uses the old "Flash is too resource intensive" argument to convince you that limiting you from the full web is a good thing. This simply isn't true. It's false. Both iPhone 3Gs and iPad could happily run the current version of Flash or Adobe AIR just like your laptop/desktop. And it's also entirely up to the developer and how they program and how resource intensive they make their flash app/widget/game/etc. The only reason, listen up, the ONLY reason Apple does not support Flash, is because the Flash platform already powers so many games and useful tools and full blown applications on the internet it threatens Apple's very business model of the Itunes/App Store. Apple wants companies to develop all their apps again specifically for the iPlatform and invest in it. If you could make a Flash app that ran on the iPhone it would also run on Android and every other smart phone. But if you invest in the iPlatform your app will only run on the iPlatform. If Apple was a monopoly the FTC would be pushing them down for their anti-competitive vindictive behaviour.

    Apple doesn't block Flash support in their mobile products because they want to push innovation in HTML 5. If HTML 5 was advanced enough, or popular enough to be worth creating the caliber of applications possible on Flash, Apple would immediately configure mobile Safari to block, impede, and hinder the advancement of standards just like Microsoft with IE. In a heart beat. Apple promotes HTML 5 because they know it'll be years before it's anywhere close to where Flash is today, if ever. In fact Apple is one of the "powers that be" preventing the HTML 5 spec from being finalized in the codec wars. Apple wants you locked into their platform. Apple doesn't care about advancing the web, or a better user experience, they care about the big media companies bringing their content online through Apple's platform. Apple wants the iPad to replace your tv, radio, and other media consumption devices. They do not care about the open web.

    Adobe on the other hand continues to open up the Flash platform and benefits from creating a ubiquitous platform across desktop and mobile. There are fully open source versions of their Streaming and Application servers, and free and open source ways to develop for their platform. Anyone can build a Flash application, for the browser, desktop, Windows, Mac, Linux, Safari, Internet Explorer, Chrome, Firefox, Opera, etc. etc. Build one application and deploy everywhere using an incredibly powerful, scalable, and mature toolset. Apple on the other hand - should you decide to invest in it, puts you in a position where you may or may not after months of development time and costs even get your application onto a device, regardless you'll have payed Apple to be a developer and to submit it in the first place or even get access to their development tools, and should you get through the random and gauntlet of barriers they can still remove your software from their platform and devices at a moments whim. They can and do literally remove your application from people's phones after being downloaded and used without warning to backup the data put into or created by your app. Anytime for any reason. AND if you're lucky enough to get your application through all these extra months of hurdles and costs and lost revenue you're only gaining access to one small subset of mobile devices.

    It is absolutely ridiculous to think the HTML 5 is going anywhere anytime soon, let alone even coming close to eclipsing Flash in any way. Not from Apple, they don't want anything to compete with their platform for getting applications on their devices - Flash or otherwise(HTML, Java, Silverlight), and not from anywhere else because it's just not mature, complete, or will over the next 12-24 months be implemented uniformly or consistently across browsers or operating systems. Even in the event that somehow all these competitors come together to reduce their own profit margins and upset shareholders in the name of benefiting the user and happy popcorn rainbows, it will still only have the capabilities of Flash 8-ish. By then Flash Player 11 will be out and all the best web apps will have an Adobe AIR application front end and you'll use an Adobe AIR application to browse through a market place of Adobe AIR apps. Yes we're moving towards the cloud, and yes the cloud and desktop are becoming indistinguishable, but moving into the browser is only a temporary measure for some companies before they build a desktop front end for their service.

    The iPad, iPhone, and iPod are toasters. Every person with an iMobile device also has a desktop or laptop for work and actually managing their digital life. Every single person I've seen raving for HTML 5 and the downfall of Flash depends heavily on Flash and its phenomenal capabilities. They're all idiots.

     

    Disable Flash Debugger Error Messages

    If you have Adobe CS, Flex Builder, Flash Builder or otherwise use the Debuggerversion of Flash Player you quickly realize that a lot of sites out there don't bother with error handling in their apps and widgets.  This sucks because everywhere you go you get these error messages and all you can do is click them away and contact the developers, who if they cared would have dealt with the errors in the first place.

    You can easily disable these error messages and then just re-enable them when you're debugging something. So here's how to do that:

    1. Find or create a file called mm.cfg in the following folder:
      OS X: /Library/Application Support/Macromedia
      Win XP: C:\Documents and Settings\username
      Win Vista: C:\Users\username
      Linux: /home/username
    2. Add the following line to the file and save it:
      SuppressDebuggerExceptionDialogs=1
    3. That's it, to turn debugging back on change that value to 0