Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 3 of 3

Thread: Controlling loaded swf files help

  1. #1

    Controlling loaded swf files help

    Hello, Iím trying to create a universal fla file (shell.fla) in which I can load any swf file and control it from buttons in the shell itself. The buttons being play, pause, rewind, magnify etc. Iíve done all this in AS2 and now I have to do it in AS3. See my website http://www.eudv.de/Pages/flash.html - E-Training - Motor to get a better idea of what I mean.
    The shell file has three buttons so far with instances called playMovie, stopMovie changeMovie and a dynamic text field - movieNumber. It is bound to the class Shell. The swf files to be loaded are numerical 1.swf, 2.swf, 3.swf etc. If I can get playMovie, stopMovie to work I can then do the rest.
    Here is my code so far for the class Shell.as:

    package {
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.Loader;
    import flash.net.URLRequest;

    public class Shell extends MovieClip {

    var movie:MovieClip;
    var N:uint;

    public function Shell() {
    // Buttons to control the movieClip instance movie
    playMovie.addEventListener(MouseEvent.CLICK, onPlayClick);
    stopMovie.addEventListener(MouseEvent.CLICK, onStopClick);
    //Button to change movieClip
    changeMovie.addEventListener(MouseEvent.CLICK, onChangeClick);
    //maybe not necessary?
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    private function loadHandler(event:Event) {
    var movie:MovieClip=event.target.content;
    private function onChangeClick(event:MouseEvent):void {
    //Dynamic text to show which swf file is running
    if (N>0) {
    //loads the next swf file
    var nextMovie:URLRequest=new URLRequest(N+".swf");
    var swfLoader:Loader = new Loader();
    swfLoader.contentLoaderInfo.addEventListener(Event .COMPLETE, loadHandler);
    public function onPlayClick(event:MouseEvent):void {
    public function onStopClick(event:MouseEvent):void {
    public function onEnterFrame(event:Event):void {
    The problem:
    1. How can I kill, unload, removeChild the preceding swf file which has been loaded? When I load a swf file it creates a new loader.
    2. On the onPlayClick and onStopClick buttons I get the following error message:
    TypeError: Error #1009: Der Zugriff auf eine Eigenschaft oder eine Methode eines null-Objektverweises ist nicht mŲglich.at Shell/onPlayClick()

    Has anybody got any ideas please?

  2. #2
    I have been doing something very similar myself recently. I made a simple loader class, when the swf is loaded I create a variable to hold that reference and then null the loader for the garbage collector.

    var newSWFmc:MovieClip = myEasyLoadClass.getSWF();
    myEasyLoadClass = null;

    That first line is pretty much what you're doing with the event.target.content part of your script.

    Don't know if you noticed, but your Event .COMPLETE should be Event.COMPLETE (no space).
    Last edited by plumpnation; April 30th, 2010 at 05:32 AM.
    no more denturists or truckers please...

  3. #3
    Thanks for the reply. I'm looking into it. Haven't quite got the philosophy of AS3 yet.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012