Archive for the 'Closer Look' Category

A Closer Look: Using MovieClip.addFrameScript()

A Closer Look

A Closer Look

In a recent post, I looked at using the undocumented MovieClip.addFrameScript() method. It is a solution for accessing MovieClip objects with embedded tweens using external ActionScript 3.0. Not only is this important for controlling animations, but it is also a way to add code in classes that are part of a Design Pattern with ActionScript 3.0 files. In other words, you don’t have to use the Timeline or the Actions panel at all in taking advantage of the animation capabilities of Flash and at the same time have all of the advantages of using Design Patterns. In the initial use of the MovieClip.addFrameScript(), I didn’t take time to really look at what the method can do or even exactly how it works other than by example. This short post, tries to provide better documentation for this undocumented feature and an example of using it. Clicking the Play button provides an experience of the final product.(It just plays explosion flashes from the tweens in the movie clip in the library.)
play
Continue reading ‘A Closer Look: Using MovieClip.addFrameScript()’

  • Share/Bookmark

Hitchhiker’s Guide to ActionScript 3.0: Dragging through the Galaxy—Part 1

A Closer Look

A Closer Look

I have no idea how things pop into my head or why. However, they do, and like unscratched itches, if I don’t attend to them they stay put. One such idea that cropped up was…

How do you drag a live video across the screen?

I have no idea why someone would want to do that either; so don’t ask. For 95% of you reading this, the answer is simple, but for the 5% of you in rehab this post may be of some use—at least until the pink elephants go away.

Because this is a Design Pattern blog, I should include some design pattern. I could slap a Singleton in front of it, but I pretty well shot my chances of doing that with my ongoing persecution of that miserable pattern. So I need to pose my question in a broader context,

What design pattern could be used to drag anything across the screen?

Well, put that way, we can make a more interesting project. This short post simply examines how to embed and drag a non-Sprite object in a Sprite object. In Part II, we’ll see how to create a design pattern that easily allows production of objects and placing them into a Sprite instance for dragging anything.

Hitch Your Wagon to a Sprite

Back in the days before ActionScript 3.0, about the only thing you could address on the stage was a MovieClip instance—or a derivative of a MovieClip. For some of us, the lesson was too well learned, and I often think, MovieClip instead of Sprite. Anyway, you can address a Sprite just as well and you don’t have the Timeline to go along for the ride. The trick back in the day was to dump anything you wanted to go along with the MovieClip into the movie clip. So if you had a graphic symbol, for instance, that you wanted to drag, you’d just put it into the MovieClip object and drag the movie clip. However, because the key methods of startDrag() and stopDrag() are part of the Sprite class, you can use the Sprite to do the same thing.

Continue reading ‘Hitchhiker’s Guide to ActionScript 3.0: Dragging through the Galaxy—Part 1′

  • Share/Bookmark

A Closer Look: Programming Library MovieClips to an Interface

A Closer Look

A Closer Look

Gentle Reader Every now and then I run into something of possible interest to ActionScript 3.0 and Design Patterns. Since I spend a lot of time in the forest (Design Patterns), I may miss the trees (Program Elements). So what I may run across might be known (and obvious) to all but me. On the other hand, some may find these short digressions of possible interest and use. So as to alert readers to these random snippets I put together a Closer Look logo for these small posts that live in the nooks and crannies of OOP and Design Patterns.

Programming with MovieClips in the Library

When you create a MovieClip in the Library and set it up for Export to ActionScript, you can treat it as a child of the MovieClip class. Basically, a named MovieClip in the Library is the same as setting it up as:

        public class MyMC extends MovieClip …

One of the fundamental design pattern principles is program to an interface; not an implementation. For example, instead of declaring a movie clip instance as,

        private var myInstance: MyMC = new MyMC()

Continue reading ‘A Closer Look: Programming Library MovieClips to an Interface’

  • Share/Bookmark