my interests and experiences
RSS icon Email icon Home icon
  • AS3 - how to do eval() the right way

    In AS2 we used to be able to refer to an instance name of an object by coding:

    ///AS2.0\\\
    eval("my_mc"+i);

    This would allow you to create and/or refer to instance names using a string. I have heard quite a bit of negativity about eval() but it did come in handy at times. In AS2, you could also use:

    ///AS2.0\\\
    _root["my_mc"+i];

    which worked well for me when pushing items to an array, before AS3 was available.

    Now, the correct AS3 way to do it is either this:

    ///AS3.0\\\
    this["my_mc" + i];

    or:

    ///AS3.0\\\
    this.getChildByName("my_mc" + i);

    I would recommend the second way of doing it, because to me it just makes more sense.

  • Updated

    Just updated to the new version of Wordpress - One thing I noticed is that I had a flash folder in the wp-admin folder that I had to recopy over after the upgrade.  I guess I should probably relocate that folder.  Otherwise it was an easy upgrade!

    Thanks wordpress!

  • Biking… what more can I say

    This is an ongoing list of the rides I’ve been on, I will probably enhance this a bit in the future.

    April 5, 2008 - http://www.mapmyride.com/ride/united-states/wi/sussex/894990639

    April 20, 2008 - http://www.mapmyride.com/ride/united-states/wi/sussex/894990639
    the same as 4/5 but reversed

    May 10, 2008 - http://www.mapmyride.com/ride/united-states/wi/sussex/111907771228

  • create chapters in an FLV like a DVD

    Since flash doesn’t have anything built into it for setting chapters or in and out points in an flv, I thought I would take it upon myself to figure it out.

    Here is what I came up with:

    (Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

    1. Add an instance of the FLVPlayback component to your stage and give it an instance name of “flv” - catchy, hey?

    2. add the following actionscript to the first frame of your timeline

    var listenerObject:Object = new Object();
    var curTime;
    function playChapter (startSecond:Number, endSecond:Number) {
    listenerObject.playheadUpdate = function (eventObject:Object):Void {
    curTime = flv.playheadTime;
    trace(curTime);
    if (curTime>=endSecond) {
    flv.pause();
    }
    }
    flv.seekSeconds(startSecond);
    flv.play();
    }
    flv.addEventListener("playheadUpdate",listenerObject);

    3. link the instance of your FLVPlayback component to an flv of your choice.

    4. create chapter buttons on the stage

    5. place this code on the buttons

    on(release){
    playChapter(2,5); //change these numbers to your start time and stop time, in seconds
    }

    **Note** Make sure you encode your FLV with at least a keyframe every 1 second otherwise you won’t be able to start and stop at the correct times.  For this example I have it keyframe every 15 frames, cause the video plays 15fps.

    Good Luck!