• Home
  • About
Subscribe: Posts | Comments | E-mail
  • Business
  • Interests
  • Life
  • Productivity
  • Technology
  • Web Design

STC Blog

Posted on February 16, 2008 - by Alex

Calling Methods in the Timeline in AS 3.0 - Flash CS3

Web Design

When first transitioning to Actionscript 3.0 and the new Flash CS3 O-O model, a lot of things became cleaner and easier to accomplish with code. One notable exception to that however, was calling methods in a timeline, specifically those in an externally loaded .SWF.

The short answer to this is: when calling a method in this scenario, the external SWF must be cast as a MovieClip prior to interaction occurring. I know that sounds strange- “cast a MovieClip as a MovieClip ..??” -but with the new 3.0 object hierarchy, there is a reason:

To grab an external Movie (.SWF), you’d probably use a loader (it’s the cleanest way IMHO):

public var swfMovie:Loader = new Loader();
swfMovie.load(new URLRequest(”movieclips/mc1.swf”));

Once this happens, your main (parent) clip sees this .SWF as a Loader’s content. So it looks at the clip as essentially a child object contained within the instance of the swfMovie loader - specifically it’s .content property.

var externalSWF = MovieClip(swfMovie.content);
externalSWF.startMe();

So to cast it, use the syntax illustrated to create a new MovieClip (you may have to import the MovieClip class def.) variable, and cast the swfMovie’s content property. From there just call the method!

As a side note: the external movieclip’s playhead must be on the frame(s) with the method you’re calling to function properly. E.g. this external .SWF was stopped in the first frame, which also had the startMe() definition in it.

This entry was posted on Saturday, February 16th, 2008 at 11:58 am and is filed under Web Design. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

0 Comments

We'd love to hear yours!



Leave a Comment

Here's your chance to speak.

  1. Name (required)

    Mail (required)

    Website

    Message

  • Flickr Photos

  • RSS Delicious

    • Taste of Ink Studios | Business Card Design | Company Logo Design | Custom Business Cards | Website Development September 4, 2010
    • Simon Collison | Colly | The Celebrated Miscellany September 4, 2010
    • Siiimple Wordpress Themes « Siiimple: A minimalist css gallery September 3, 2010
    • Time Zones September 1, 2010
    • Amazon.com: Serious Creativity: Using the Power of Lateral Thinking to Create New Ideas (9780887306358): Edward De Bono: Books August 25, 2010
  • Twitter

    • "Day in the life of an external auditor" (NSFW): http://bit.ly/9RKxd3 1 week ago
    • This is in a field adjacent to my hotel. Thank you Ohio, thank you. http://yfrog.com/49ppvpj 1 week ago
    • @JordanDoneskey I just think that means you're a baller. in reply to JordanDoneskey 1 week ago
    • More updates...
  • Archives

    • February 2009
    • April 2008
    • February 2008
    • January 2008
© 2008 STC Blog - Life and technology, in no particular order.
The Papercut theme by WooThemes - Premium Wordpress Themes