Category: Flash

  • Shared Whiteboard using Flash 8, Flex, & Flashcom: Map Revealer

    After reading this article about using Flash 8 in Flex 1.5, and failing to prove it wrong, I still figured I could blend the best of both worlds.

    Background

    I’ve always wanted a Map Revealer, like Fantasy Grounds has; here’s a screenshot. The goal it accomplishes is it allows players in the game to see where they have explored, but not the whole map until they’ve explored it. That way, they have a visual aide to track their progress, and it gives a sense of accomplishment to those explorers in the party. If you walk down the hallway (and don’t fall in a trap), then that hallway is revealed on the map.

    Taking ideas from my JXLScratch Off component, I tried to do this pre-Flash 8 by having about 2000 (20×20 10 pixel tiles) loaded on top of a large bitmap. You could, as the presenter (DM) toggle their visibility since they were just clickable MovieClips. Even at that low-level on my Alienware, though, she chugged. The redraw froze the app for 3 seconds. I’m sure I could of done 1 redraw and just synchronized it amongst clients, but… bleh, don’t think so.

    Now that we have the pixel pushing power of Director, with the addition of half-pixel support, I figured I could implement what I truly wanted; an anti-aliased fog of war that could be used to reveal a map to a list of clients connected, with the Presenter/DM controlling the revealing.

    The original Baldur’s Gate had a GIF transparency approach; pixel on, pixel off. It was actually more close to the Fireworks 1bit transparency you can do with single color images by making every other pixel transparent, alternating rows. You can see an example here.

    The sequeal improved it by making what you didn’t see solid black, revealing it with a nice, soft gradient transparency edge seen here, and re-covering visited areas with a transparent gray.

    Finally, I can do that in Flash!

    Whiteboards Rendering Engines, BitmapData, and Flashcom

    …then I hit a snag. You can’t send a BitmapData instance over the rtmp wire… although, you CAN send an image pixel by pixel! To me, though, that doesn’t count, heck with that.

    Most Whiteboards done in Flash consist of a rendering engine. They take shapes, and render them to the screen. Each shape is unique, and has attributes that are set when it is created and manipulated by the user. When those attributes are changed, they are sent over the wire so each rendering engine on the client can show the same whiteboard state. That way, you have small pieces of data, and when a new piece comes in, your code goes “oh, this is an ‘arrow’, it’s red, is so large, and sits at these screen coordinates.” This process repeats for when an object is manipulated, those changes are sent over the wire. If it’s deleted, those changes are sent as well.

    The pros? The data sent over the wire is extremely small since the rendering engine is capable of drawing a lot of objects (arrows, text boxes, drawings, etc.). The cons? Too many frikin’ objects… Flash Player has a lot of overhead (currently, hehe) when creating objects; that’s why when you create a lot of MovieClip’s, things start to slow down. RAM & CPU get ravished.

    What’s a bitmap? 1 object. Yeah, it’s a series of pixels, but showing 1 bitmap in Flash is cake, utilizes low resources, and if you change it, it’s still 1 bitmap!

    My Implementation

    Since you can’t shove it over the wire, though, I had to utilize the best of both worlds. I created a rendering engine based off of Senocular’s code, specifically the Erase & Draw’s example that will draw the changes to the bitmap based on a stored array of mouse movements. This has been done before by GE, but they utilized a vector line. While that certainly does NOT limit ones creativity, the presentation and ability to manipulate bitmaps has been more mature for awhile, and the implementation of such effects in Flash does what bitmaps do best; render well with low resource usage. While erasing the mask, or covering it back up again, I record the mouse movements. You can then run through this recorded array of x and y coordinates to redraw the bitmap exactly as the user did. The sending of the data over Flashcom wasn’t as latent as I thought; there is a noticeable delay, but considering I’m sending almost a thousand numbers in 4 arrays across, it’s not bad.

    Pros & Cons

    And now, time to tear it to pieces. First off, I do not record the order in which you erase and then re-draw, so if you swap the order, it doesn’t matter; the engine does 2 passes; 1 to do the erasers, and then 1 do to the redrawing of the mask you just erased. Secondly, I could of put a bunch of info objects into 1 array to make the code simpler, OR I could of put each object on a unique slot on the SO to allow the data changes to stream; however, to me, you typically draw the image, and when ready sync it so the rest of your viewers can see. I felt that was a reasonable tradeoff since you only throw that big message every once in awhile. Third, while the erasing of the image mask is a nice anti-aliased (smooth gradient) brush, the redrawing of the mask is not. Couldn’t figure out how to get it to work. Fourth, while “seeing the drawing draw itself” is a novelty, that wasn’t the goal; the goal was to update state and syncronize it across many clients. If you screw up and erase a part, it records that… so it’s not a perfect drawing engine. Finally, it’s a white mask if you are not the presenter; I wanted black, but putting the black color in there doesn’t work since it’s an alpha… or something.

    Whiteboard(s) In Our Future

    Anyway, after seeing what I could in a few hours after 2 nights, I can DEFINATELY infer what Breeze 6 will have; the most powerful and ubiquitious multi-user whiteboard on the internet. If Macromedia’s smart they’ll withold the key feature for Breeze, like they did with Screensharing for Flashcom, to allow BitmapData objects to be shared over Flashcom. The whiteboards out there currently for Flash/Flashcom are pretty good, but you ain’t seen nothing yet. Either way, if someone spent a few weeks on one… sick!

    Map Revealer Demo + Source

    Here’s my Map Revealer in action; 2 clients, 1 a presenter, and the other an attendee, share the Whiteboard over the wire. Source FLA + AS in ZIP.

    Map Revealer – See It | Source ZIP

  • Sparkle Hype Thresher: Duty Bound Flasher

    First, some updates. Skip to “Duty” if you’d prefer.

    Personal Updates

    Choosing your contractual future whilst capitalizing on your satisfactorely ability to communicate effectively in hopes of ensuring no bridges are torched in signing such binding agreements is… diffucult. I’m basically working on doing what I’ve always wanted to do; have a company ensure me a steady stream of Flex work without having to be an actual employee.

    Problem is, there are a lot of players battling for my time, I hate saying no, and previous ventures into contracting were either a failure, or never provided enough incentive to go full time. If there’s a book on this stuff, I haven’t read it, so instead I depend on my smart networking contacts, both old and new, and heed their advice since this is new territory for me. The short: be honest, and know exactly what you want.

    It’s still challenging though as these decisions must be taken with respect and given their due time to think them through. I just keep the beer I’ll savor Friday eve forefront in my mind.

    Duty

    So, amongst this barrage preliminary work & negotiations, I’ve been barely able to keep my head above water following the blogs. I’ve been trying to shed the “Flash Developer” moniker from my various titles since I don’t see my future in Flash, but rather Flex development where Flash merely plays backup.

    …and yet, reading this update by Jon Meyer, I had disturbing recollections of Slashdot. Whilst many Flashers will agree, it’s pointless to do battle there anymore; there is no point. While spreading correct information is great, why waste your time on those who have no interest in listening? Frankly, if I were John Dowdell of Macromedia, sure, I’d still do it because it was my job.

    At any rate, this hit a nerve, so whether this is an emotional response hidden under the guise of noble duty, or not… so be it. He’s just 1 blog, not the cacophony, patience trying of Slashdot.

    Let’s dissect.

    To clarify my position, yes, Jesse Warden wants to utilize Sparkle. It sounds cool as hell; please give me pre-alpha/beta copy, thank you much!

    I’m no longer a professional designer, although I can still do some design work thrown my way. That is not what makes me yearn for Sparkle, however. It’s the easy ability to make Windows Applications look good. My background is doing applications that look cool; utilizing Director and Flash for Fat Clients. Like using Flash in Screenweaver/Zinc, or embedded into custom holders like Visual Basic and custom C apps. I’ve always loved the endless power that such situations give, as well as the ability to make them look damn good. That is what makes Sparkle appealing to me since Day 1 of Sparkle’s blog appearence.

    This statement, however, is based on 1 example which does not support his point:

    Macromedia Flash, in my opinion, is becoming less of a significant player as developers shift from Flash to using DHTML and “Ajax” to create applications like GMail and Google Maps. Today many developers view Flash as a tool best suited for web video and advertising, and not for the “heavy lifting” required in substantial applications. I see this trend continuing, unless Adope significantly enhances Flash, e.g. with 3D, more audio and video formats, access to native code, a revised security model, more sophisticated text, faster script execution speed, and an open runtime of the breadth and richness of .NET.

    He cites Flickr’s changes to making their images being housed in Flash to instead be an image that has it’s URL dynamic via DHTML.

    That wasn’t a decision to “use DHTML instead of Flash”, that was the right decision. Not being able to right click on an image was stupid, and it was trivial to get the image through view source. Case in point, this was a bad use of Flash, more importantly, a bad decision. …and they fixed it, go Flickr.

    But this wasn’t a “choosing to use AJAX/DHTML instead” scenario he describes. If you read their reasoning, they changed it because of user feedback, and their AJAX offerings were additional pieces of functionality having nothing to do with the Flash change.

    Next, homeskillet definately has the Avalon bug. Associating “3D” with “substantial applications”. Am I to concur that 3D helps make an application substantial?

    Additionally any of these developers who “view Flash as a tool best suited for web video and advertising, and not for the ‘heavy lifting’ required in substantial applications” need to have a talk with me, and plenty of others who can give a different perspective than I. While I agree the current development paradigms for making applications suck, as soon as Zorn comes out and is cheap, problem solved. I’m a Rich Internet Application Architect; I do this for a living, and would love to discuss how Flash CAN solve those heavy lifing needs, and integrate well in your workflow.

    I’m really confused on the request for a “revised security model”. The one we have currently works great, is very secure, and drives Flash & Flex Developers batty in that it’s so secure.

    I’m also confused on the “more sophisticated text”. Huh? We can utilize system fonts installed on a user’s machine, we can embed fonts ensuring the user sees what the designer inteded even allowing them to be used in input/dynamic text fields, and also now having a font display engine rivaling PDF’s, called Saffron. What more do you want?

    Everything else he asks for, I agree, I want to… but it’s easy as nuts for .NET; they are OS specific with a 60+ meg runtime vs. a cross platform, under 1 meg runtime.

    Conclusion

    It’s pretty apparent to me: We as Flash/Flex Developers are most definately a “significant player” if Microsoft makes an application to respond to Flash, but only a framework to respond to AJAX.

  • Dofus: Flash-based MMORPG Launches

    Mirroring the post at XD.

    Darron told me about this game months ago. I downloaded it, managed to get a login (I don’t read/speak French, although I dig the accent), and got on.

    At that point, I almost went for a career change. Seriously, I have been trying to create games of that quality for the past 6 years, and I was just blown away at what these gents did in Flash. I always knew it could be done… just never did it to prove it.

    Anyway, after playing for about an hour, it’s just like any MMORPG should be, which is great because it means you don’t need phat C++ & OpenGL skills to help satiate that market.

    Dofus

  • RadioButtons & Damn Doctors

    Just a note about RadioButtons; they do some cleanup via an onUnload. What this means is, you can’t remove them (removeMovieClip/destroyObject) and immediately repopulate their depth until they have run their onUnload command. Therefore, it is an appropriate place to utilize a doLater (basically waiting 1 frame).

    A sore throat & 1 degree tempature; symptoms which cause panic hysteria at my house if my wife showcases them. Take her to the doctor, and they confirm it’s a minor virus, like a minor strep throat, that one can get easily, and isn’t infectious.

    BS. I have been hot as a mug (even with a semi-fixed AC) since 11:00, and my throat is sore. This ensures I’ll not be hitting that rave that was at the Compound this weekend and instead sitting at my parents house in the west-side version of middle of nowhere, getting fauned upon by mother who makes good coffee for her sick son, while I’ll fiddle with “experimental software” on the new wireless they don’t need, but I plan to setup for them whilst my her majesty is up north giving a baby a shower.