Nudoru\Udon

flash, elearning, random thoughts

Archive for February, 2008

Drawing with Physics

Adobe’s John Nack has a great post with links to a few physics based drawing programs. I’d love to be able to play with one of these. I hope that Sophie get’s to – this would make a wonderful edutainment product for kids (and parents!).

Also check out the game Crayon Physics. Casey and I spent over an hour playing the free version of this. It’s a great idea for a game.

  • 0 Comments
  • Filed under: Random
  • .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);
    }

  • 7 Comments
  • Filed under: Flash, WiiFlash
  • 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.

  • 1 Comment
  • Filed under: Flash, WiiFlash
  • Via Tony KarrerVisualizing Information for Advoacy

  • 0 Comments
  • Filed under: Design
  • Gutenberg On Line has a wonderful navigation system. I love the menus. Via Smashing Magazine.

  • 0 Comments
  • Filed under: Design
  • 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.

  • 0 Comments
  • Filed under: Flash, WiiFlash
  • 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.

  • 3 Comments
  • Filed under: Flash, WiiFlash
  • More Wii Mote and VirtualMouse

    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.

  • 0 Comments
  • Filed under: Flash, WiiFlash
  • REALLY cool Flash site/gallery

    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.

  • 0 Comments
  • Filed under: Design, Flash
  • 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.

  • 0 Comments
  • Filed under: Flash
  • 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.

  • 0 Comments
  • Filed under: Flash
  • 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.

  • 5 Comments
  • Filed under: Flash, WiiFlash
  • Stupid cold

    It’s been one week and I’m still not over this damned cold! At least my fever isn’t 104F like Saturday. I’m getting tired of being tired.

  • 0 Comments
  • Filed under: Random
  • Pipwerks SCORM Class for AS2/3

    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!

  • 0 Comments
  • Filed under: Flash
  • AS3 speed optimizations

    May come in handy one day …

    http://osflash.org/as3_speed_optimizations#as3_speed_tests

  • 0 Comments
  • Filed under: Flash
  • TweenLite.to(speedTweeningBliss);

    I can’t believe that I hadn’t heard about this tweening engine before! Originally, I was using the Boostworthy system, but that was a pain the ass for the simple animations that I needed. I started Ramen using Tweener and was pretty happy. Steven Sacks mentioned TweenLite in the Flash Tiger list and I took a look at it. It was faster than Tweener and shaved 8k off of my file sizes! Sweet!

  • 0 Comments
  • Filed under: Flash
  • Ramen, take 2

    Ok, now I really mean that I’m going to learn AS3! In November, I started to work in a new web site framework, in AS3, as a practice exercise. I’m also trying to do it right, picking up a few design patterns along the way.

    The main player is about 35k. All graphics and fonts (except for the opening preloader) are external. The content is driven from XML files and each page is it’s own reusable SWF template.

    It’s got a few predefined design aids – text boxes, images, FLV player, hot spots, a transition system and event an event system for controlling other items on the page.

    There is still a lot of work to do, mainly around sound – but it’s shaping up pretty nicely!

    RAMEN.nudoru Player

  • 0 Comments
  • Filed under: Flash
  • My first political donation

    Made my first political donation to Barack Obama on Thursday morning. I really hope he wins this.

  • 0 Comments
  • Filed under: Random
  • Back to Vista

    I moved my Dell laptop back to Vista. I updated all of the drivers and picked a more stable nVidia driver. Now all my issues are gone! I had one outstanding issue with Flash CS3 running slow, but after switching it to run in “XP SP2 Compatibility mode,” it runs fine.

    I also probably helps that I added 2gb more ram – for 4gb total. This thing is fast now!

    I’m out of complaints for Vista. It took a year – but better late than never.

  • 0 Comments
  • Filed under: Random