Category: Flash

  • How to get DataProvider API functions without the List component

    Lee, lee da dee… lee da dee…
    rave, rave, rave…

    Do you want the DataProvider API functions for your array’s without having to include the List component in your SWF for them? Then do:

    import mx.controls.listclasses.DataProvider
    
    class MyClass
    {
            static var mixIt:Boolean = DataProvider.Initialize(Array);
    }
    

    The DataProvider.Initialize function basically adds the DataProvider functions to the Array’s prototype. I’m writing my own class that adds and removes items from an array, but they aren’t really item’s, but they follow the same pattern, so I figured I wouldn’t re-invent the wheel.

    public function addCowAt(index:Number, someCow:Object):Void
    {
            cow_array.addItemAt(index, someCow);
    }
    
  • Initialization Order in Flash MX 2004

    Did I mention homework sux? Taking a break between 10 billion essays + discussion board assignments to spiel some Flash stizz-nuff.

    Someone commented on a really old blog entry asking a question about init order of components. Here’s the four one one.

    In Flash MX, you had this compile time operator called #initclip. You would wrap your class code, typically on frame one inside of the movie clip that was your component. You’d place a number next to the #initclip to specify in which order the class should initialize in so you made sure your super classes instantiated before your sub-classes, and components that were used by other components were instantiated first, and then the ones using them followed.

    I personally was ever able to break this, and I think it was because I would always place my component inside the component that used it… I’m not sure if that forces it correct, overrides the order #, or what… anyway, here was Flash MX:

    #initclip 5
    function MyClass()
    {
            initTheManWithThePlan();
    }
    #endinitclip
    

    In Flash MX 2004, the IDE handles this for you. It can detect the classes your utilizing/inheriting from, and with the IDE’s help of assets, it’ll auto-write the #initclip orders; you can see these if you decompile the SWF. You build your classes, then place the component inside the component that uses it. If it’s just a class with no GUI (damn programmer…) then as long as you have an import, or a fully qualified class path in the class that uses it, your good.

    I’m sure I skrait foobarred some semantics, but the easiest way to get smart people to talk is to be dead wrong and they’ll happily correct you, so there I go.

  • Mass Symbol Swapper

    Dude on LJ had 1000 instances he needed to swap from Symbol A to Symbol B. Didn’t want to do it manually, so I wrote this command for him. Maybe you’ll find a use for it too.

    You select a frame, and it’ll swap all instances to use a different symbol that you specify. Instead of clicking the instance on the stage, clicking swap, and repeating for each symbol, this just does it en-masse at light speed.

    *** Updated to 1.0.1 ***

    Mass Symbol Swapper – MXP | ZIP

  • getNextHighestDepth Gotcha

    Ok, this one pisses me off hardcore. It technically works correctly on paper, but so did Marxism… or so the saying goes… whatever.

    I’ve been using getNextHighestDepth for movie clips that are expendable. Timers, counters, one time processes, etc. However, movie clips created in negative depths are protected, meaning removeMovieClip will not work on them. The same goes for movie clips created at or above 1048576. Unfortunately, getNextHighestDepth will return that depth. I haven’t pinned down at what situation those depths are returned. With nothing, it’ll return 0. With a clip at 1000, it’ll return 1001. I guess at some point it just jumps to that value.

    At any rate, tracking down some bugs, and this is the 2nd time I was burned by this gotcha. I don’t give a flying fizz-nuck-chuck what ECMA says, this is bs functionality. In my understanding, this command was to help me not worry about depth management. Now, however, I’m back to where I started: worrying about depth management.

    Consider yourself warned.