flash, elearning, random thoughts
11 Apr
Ryan Taylor point’s to an article on Grant Skinner’s blog about a bug in FP9 where loaded SWFs are not removed from memory when you tell Flash to.
This is a problem that I’m seeing with ramen just as Ryan is seeing with his PGA app. I was watching the memory usage of a current project and it was taking up >90mb of ram, GC ran and then it went down to 60mb. Still to high, but damn! I was pretty careful when I was coding it null out references and stop listeners/timers – but I think that I need to make another pass as it.
11 Apr
The BAC Wii project has come to an end for now – we delivered our final report yesterday. Hopefully word of what we’ve done will spread and we’ll be ask to share it with more groups. It was a really cool project to be on – the potential of the Wii and kinesthetic learning is an interesting area – and I don’t think that many people are doing much with it yet. Replacing the mouse with a Wii remote is a great way to increase engagement – I wonder if I could find a way to apply to compliance training? Would make for an interesting course assessment.
Anyway, I’m posting my outline of the Wii controller class that I spent all of January developing. It makes programming for WiiFlash super simple – just instantiate it and boom – Wii support in any Flash app. Works with all typical mouse events.
Wii Controller Engine
9 Apr
WiiFlash 0.4 has been released today! New features include: 4 IR points on the sensor bar, tracking the size of the IR points (for determining depth), and battery information from the Wii remote.
Since Jason has been busy trying to get a good depth (z-axis) reading with the 0.3.2 release – this is very welcome news. I’d wondered how Nintendo managed to get this information and it never occured to me that the size of the IR point would be it – but it makes perfect sense.
Sadly our Wii research project ends tomorrow – we give our final presentation to the sponsors at 1pm. I hope that we get to keep the Wii motes and sensor bars – there are a few minigames that I’d like to make. It would be cool to make some WiiFlash games that Sophie could play.
9 Apr
This is a short presentation that I gave to the Bank’s Flash Platform Developer Community group 2 weeks about. Its about the event bubbling system in AS3 and includes an example of how I’m using it to trigger events in ramen Player. Also includes a screen shot of my current project at work – a demo for the new LMS system using an avatar character.
The more I learn about events the better they get and more possibilities appear. I’ve added an audio player page object type that can control the avatar SWF by events. The whole thing is setup using XML – so it’s completely customizable. You can do so much more than was ever possible in AS2 and with much less code. Probably doesn’t sound impressive, but they fact that they are all separate SWFs running though a player SWF with XML defined event data responding to custom events being passed from SWF to SWF, blah, blah, blah makes it sound more way more exciting.
9 Apr
I’ve finally gotten around to writing a short page about my ramen Player that I’ve blogged about over the past few months. At least the posts have a little context now.
8 Apr
Greensock has released TweenMax. Looks really sweet – I don’t do many bezier tweens, but having the ability to do that, filter and color tweens in one class is appealing. I’m going to try to integrate it in to Ramen so that I can use it for my rebooted Nudoru site.
Draw Logic has a good list of the availble animation packages. Matt Przybylski comments and links to an article on his blog on getting started with animation packages.
19 Mar
A user on the FlashTiger list asked how to load classes dynamically at run time – this Adobe live doc covers it nicely. I’d thought of trying something like this before but was never clear on how to do it. Anyway, linked so that I’ll remember to look at it later
11 Mar
I’ve been using Hyrdotik’s Queue Loader in RAMEN to manage the loading of “theme” files for the interface. I’m not taxing it too much – just 7 files.
Bulk loader looks promising also – many more features, but it’s a lot bigger.
11 Mar
Been busy at work lately! I’ve got a tight deadline on a big project that involves a system demo with an avatar character.
I’ve been working in XML and dynamic Flash for so long with my inFlite system (more info soon) that I have a hard time thinking in terms of time line based animation. So, I’ve forked RAMEN and am creating a version for work. I’m getting the opportunity to add a few cool features (which probably won’t mean anything since I haven’t shared much about RAMEN here): timer based animation triggers, image distortion, targeting MC’s inside of a loaded SWF, shape objects, eventmanger objects, blah blah blah.
The hardest thing with be to get it to talk to Lectora so that I can make a cohesive template.
4 Mar
Is it just me or is the NOAH Animated Avatar just creepy? Who would design anything and use an army of these little people to communicate about it to the users? You can control the size of them, but the detail that’s drawn into their outfits does not allow for them to be scaled too big.
29 Feb
.crux. added a comment about a different way to smooth out the data from the Wii controller – create an array of the last 10 values and average them. I’ve modified my code to try out this idea, and it’s not too bad. The data does wobble a little, but it’s more precise than my method. If you increase the size of the array, it gets smoother, but will also increase the cpu power required. Partial code below.
 private var WiiRollDegAry:Array = new Array();
public function get roll():int {
return averageIntArray(WiiRollDegAry);
}private function updateData(pEvt:WiimoteEvent):void {
WiiRollDegAry = addValueToLimitedArry(WiiRollDegAry, int(TheWiimote.roll * TO_DEG));
}private function addValueToLimitedArry(a:Array, v:int):Array{
a.push(v);
// increase to smooth out data
if (a.length > 10) a.shift();
return a;
}private function averageIntArray(a:Array):int {
var len:int = a.length;
var c:int = 0;
for (var i:int = 0; i < len; i++) {
c += int(a[i]);
}
return int(c / len);
}
28 Feb
Jim Foley has recreated Johnny Lee‘s head tracking VR Wii experiment with Papervision and Flash. I really need to find the time to start learning PaperVision. I’m missing out on the fun.
26 Feb
Not so much a tip but a point in the right direction. These tips are really out of order!
Once you have WiiFlash working and you have your senor bar, you need be able to read X and Y values based on where you’re pointing the controller. I tried a few approaches for this, but none worked better than the code that Andrés Santos developed. Check out his wiimoteIR class and demo code. I’m using a very slighly modified version of it in my classes and it’s working great.
26 Feb
This is tip #2 in my series on WiiFlash.
Once you have data coming in the from a Wii controller, the first thing you’ll notice is how precise it is. I don’t have it in front of me, but the precision goes about 15 places past the decimal (4.042584267432343…). If you just convert the data from radians to degrees, WiimoteObj.roll*(180 / Math.PI), and apply it to a sprite with an enter frame event, you’ll see it wobble all like mad.
There are two things that you must smooth out to best use the Wii controller – the roll, pitch and yaw of the controller, and the animation of the Wii mouse pointer.
1 – Smoothing Roll, Pitch and Yaw Data
I’m only going to demonstrate for the roll value – it’s the same for pitch and yaw. There are probably numerous ways to optimize this code, but it’s working me right now. My method involves comparing the current value to the last value and checking to see if it’s outside of a tolerance value. If so, then the value is updated, if not, then it’s ignored. I’ve found that 10 degrees works well for me, but you can change it depending on how precise you need it to be. This code assumes that you have an instance of the Wiimote class, WiimoteObj, and have the listeners set up to call the updateWiiMoteData function when the WiimoteEvent.UPDATE event occurs.
private var WiiMPitchDeg:int;
private var WiiMPitchDegPrev:int;
// to convert radians to degrees
private static const TO_DEG:Number = 180 / Math.PI;
// smoothes out roll, pitch and yaw values, smaller = more precision
private static const WIGGLE_TOL:int = 10;private function updateWiiMoteData(pEvt:WiimoteEvent):void {
WiiMRollDeg = int(WiimoteObj.roll*TO_DEG);
var rDelta:Number = Math.abs(Math.abs(WiiMRollDegPrev) – Math.abs(WiiMRollDeg));
if(rDelta < WIGGLE_TOL) WiiMRollDeg = WiiMRollDegPrev;
}
As you can see it’s pretty simple and works well.
2 – Smoothing out the Wii mouse cursor
This one is very easy. All that you need to do is to slightly tween your cursor sprite from it’s current location to the location that the Wii more is pointing to. Here’s my function, same assumptions as above. wiiPoint is a Point object containing the location you calculated for where the controller is pointing to. I’m using Tweener for the animation.
 private function updateCursor():void {
var newx:int = 0;
var newy:int = 0;
var newr:int = 0;
try {
newx = wiiPoint.x;
newy = wiiPoint.y;
newr = WiimoteObj.roll;
} catch (e:*) {
// no good data – the ‘mote hasn’t seen the IR points
newx = 0;
newy = 0;
newr = 0;
}
Tweener.addTween(CursorSprite, {x:newx, y:newy, rotation:newr, time:.1, transition:”easeOutQuad” } );
}
For your VirtualMouse object, be sure to set it’s x and y properties to the location of the cursor sprite, not where your code says the Wii is pointing at.
26 Feb
Since I posted the Wii mote as a mouse tip, I’ve seen the same method pop up on a few blogs. Unic8 has a good demo with source of this working in Flex.
I’m finally coming back out into the open after being burried at work, so I’ll post more WiiFlash stuff soon. I’ve been playing around with the Nunchuk today. The analog stick is a little tricky.
22 Feb
Credit to Jason Merrill for finding this site:
Inspiration. WHITEvoid, an interactive design firm in Berlin, developed a really cool user interface that makes liberal use of real 3D in Flash. You have to experience it to appreciate what I mean.  Check it out at whitevoid.com/application. It gave me some ideas for a portfolio gallery and other uses of 3D for “non-real world object” interactivity. Oh and if you get a chance, just for fun, check out their “MIDI Gun” on the site.
15 Feb
The eLearning Guild is soliciting tips for elearning with the Flash Platform. This includes any authoring tool that outputs to a SWF format. Results will be published in an ebook to be released in late March 08.
15 Feb
I posted 2 simple classes from the Ramen player to the GTAL forums.
1. RandomLatin – generate strings of random latin text. Good for quickly adding sample text to dynamic text fields during prototyping.
2. GradRect – creates a nice gradient filled, web 2.0 style rectangle.
14 Feb
I’ve been doing a lot of really cool stuff with WiiFlash at the Bank – but I can’t really share any of the code. So, to help any aspiring WiiFlash developers out there, I’ll post a few tips over time with things that would have helped me out. If you don’t know anything about WiiFlash, take a look at their site, it’s a pretty cool hack. Now that I’ve got a good working class system, I just want to sit around and create mini-games. I wish that I had the free time!
Tip #1 -Using the Wii Controller as a mouse in Flash
The toughest problem that I’ve come across so far: “how do you use the controller as a mouse (click on buttons) in a Flash movie without relying on WiiFlash’s crappy mousemode?”The “mousemode” feature takes over control of the system mouse pointer and uses the controller to point and click. I didn’t want this – I just wanted a nice Flash sprite moving around and still allow the user to click on things with their real mouse. But I wasn’t quite sure how to have this sprite fire off mouse events.
Solution: Senocular’s VirtualMouse class.
Once you’ve figured out how to read the IR points from a sensor bar (a future tip), and have a pointer moving around the screen, just set your virtual mouse instance’s X and Y values to the same as the pointer sprite. Trap the A button press event to fire off a virtual mouse CLICK event and that’s it! Well, I guess there are a few details to fill in still – but you get the general idea. Get it working properly and you can interact with your movie/game with the mouse and the Wii controller.
12 Feb
Thanks to Erick Emde on the AWARE list for pointing out the Pipwerks SCORM API wapper class to me. It looks like a great solution to creating SCORM compliant courseware in Flash with minimal fuss. It could use a wrapper class that so that a novice didn’t need to know the CMI variables and syntax, but other than that – it looks great!