A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Targeting a loaded swf

  1. #1
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80

    Targeting a loaded swf

    Hi all

    1. I'm loading an external swf onto my main swf.
    2. Then I'm tweening an object which is separate to the loaded swf.
    3. When the tween has completed I'm calling a function to make the loaded swf gotoAndPlay(2);

    It all works apart from telling my loaded swf to play. I'm really stuck please help.

    The code which I'm using is:

    //
    import caurina.transitions.Tweener;
    //load swf
    var externalSwf:Object;
    this.myRequest=new URLRequest("orange.swf");
    this.myLoader = new Loader();
    this.myLoader.contentLoaderInfo.addEventListener(E vent.COMPLETE, grabContent);
    this.myLoader.load(this.myRequest);

    //tween object
    function grabContent(event:Event):void {
    externalSwf=event.target.content;
    Tweener.addTween(banana, {x:-900, time:1, transition:"easeInCubic", onComplete:nextBuild});
    }

    //control loaded swf
    function nextBuild() {
    externalSwf.gotoAndPlay(2);
    }
    stop();

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Are you getting an error?
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80
    Not getting any errors. I've used trace(); to confirm that each part is working. It's just not perfoming that last request.

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    So the nextBuild function is not executed or it is but the externalSwf.gotoAndPlay(2); is not executed?
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80
    externalSwf.gotoAndPlay(2); is not being executed. The function is working as I have a confirmed trace. I can send you the flash files if want to see in detail. Thanks

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Post them here so others can have a look too.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80
    Here are all the files

    example
    Last edited by imagesinmotion; 11-12-2009 at 09:18 AM.

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You need to add the Loader to the Displaylist:
    var myRequest:URLRequest = new URLRequest("orange.swf");
    var myLoader:Loader = new Loader();
    myLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, grabContent);
    myLoader.load (this.myRequest);
    addChild(myLoader);
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80
    Thanks for your help cancerinform

    The working code is as follows, if anyone needs the files contact me and I will send them on.

    //import for the tween
    import caurina.transitions.Tweener;

    //load the external swf
    var externalSwf:Object;
    var myRequest:URLRequest=new URLRequest("orange.swf");
    var myLoader:Loader = new Loader();
    myLoader.contentLoaderInfo.addEventListener(Event. COMPLETE, grabContent);
    myLoader.load(this.myRequest);
    addChild(myLoader);

    //when the swf is loaded, the tween is initiated
    function grabContent(event:Event):void {
    trace("swf has been loaded");
    externalSwf=event.target.content;
    Tweener.addTween(banana, {x:-900, time:1, transition:"easeInCubic", onComplete:nextBuild});
    }

    //when the tween is complete, play the swf
    function nextBuild() {
    trace("the tween has completed and has initiated the nextBuild function");
    externalSwf.gotoAndStop(2);
    }
    stop();

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