dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Loader class and gotoAndPlay()

  1. #1
    dmacker = new Person()
    Join Date
    Jan 2005
    Location
    Woburn, MA
    Posts
    143

    Loader class and gotoAndPlay()

    I'm trying to control a SWF that's been loaded using the Loader class:

    PHP Code:
    var myLoader:Loader = new Loader();
    myLoader.load(new URLRequest("simpleTween.swf"));
    addChild(myLoader); 
    The loaded SWF has a stop() on frame 1. How can I issue a gotoAndPlay(2) command to get it to continue? The MovieClipLoader class handled this in AS2 by loading the content into a mc, but the new AS3 Loader class doesn't appear to have this functionality.

    Thanks!
    I am an instance of the Person class.

  2. #2
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361

  3. #3
    dmacker = new Person()
    Join Date
    Jan 2005
    Location
    Woburn, MA
    Posts
    143
    Thanks Senocular. I read the Help entry, but I need a bit more hand-holding on this. Here's what I tried:

    PHP Code:
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    myLoader.load(new URLRequest("simpleTween.swf"));
    myLoader.content.gotoAndPlay(2); 
    But alas, no progress. I couldn't find documentation on how to use the content property of the Loader class. Any help appreciated.
    I am an instance of the Person class.

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    I believe you can do something like:

    PHP Code:
    loader.contentLoaderInfo.addEventListener(Event.COMPLETEloaded);

    function 
    loaded(event:Event) {
        
    event.target.content.gotoAndPlay(2);

    Give that a shot. It should make sure the content is loaded before you try accessing any properties or methods.

  5. #5
    dmacker = new Person()
    Join Date
    Jan 2005
    Location
    Woburn, MA
    Posts
    143
    Thanks A.D.

    My problem turned out to be more complex than I imagined. Apparently you can't fully manipulate AS1/AS2 formatted SWFs with the AS3 Loader. Instead of loading them into a Sprite or MovieClip object, these legacy SWFs get quarantined into an AVM1Movie object that has no play() or gotoAndPlay() methods. (Bummer.) It does allow for a limited set of properties such as x, y, and rotation though.

    AVM1Movies are ActionScript 1 & 2 Virtual Machine objects which, unfortunately for me, are incompatible with AVM2Movies such as scripts written in AS3.

    If I've gotten any of this wrong, would someone please let me know? Thanks.
    Last edited by dmacker; 07-05-2007 at 12:33 PM.
    I am an instance of the Person class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center