2 Replies Latest reply on Aug 24, 2007 4:40 AM by Newsgroup_User

    Problems accessing child swf from parent class

    7_below
      First off: Hi. I'm new - to the forum and to Flash.

      I'm currently writing a flash app that requests a XML feed from a Java controller and loads child swfs into various parts of the stage based on the settings/URL details received from the XML feed.

      Its nearly there and I've got my head round a couple of weird things, but theres one thing left that I've found impossible to solve. Once the loader class has loaded the swf, it can't access its methods or set its variables and the child can't access the parent either (or access the parent's variables full stop). From what I've read this should be possible. Heres some of my code plus pseudo code:

      Note the Panel class is not linked to a symbol and uses composition to act like a movie clip, rather than inheritance.

      quote:

      class Panel{

      function Panel(owner:MovieClip, insName:String, depth:Number){
      initiates properties etc....

      panelMovie = owner.createEmptyMovieClip(insName,depth);
      }

      ....
      listener.onLoadComplete = mx.utils.Delegate.create(this, scheduleModule);
      loader.addListener(listener);
      loader.loadClip(moduleX.url, panelMovie);
      ....

      function scheduleModule(){
      .....
      trace(panelMovie.key);
      trace(panelMove.keyTest());
      panelMovie.key = "dave";
      trace(panelMovie.key);
      .....
      }


      Child swf:

      quote:

      var key:String = "test";


      As you can see I create an empty movieclip which I store a reference to in this class under the field "panelMovie". I then use this (instead of target_mc like you might do with an event handler) to try to access the child swf. The output is:

      trace(panelMovie.key); = "test" (Works fine)
      trace(panelMove.keyTest()); = (Nothing returned)
      panelMovie.key = "dave";
      trace(panelMovie.key); = "test" (Previous line = no effect)

      Is this something related to using a class? Really would be preferentially to keep all code outside of the fla.

      I've also tried a lot of different combinations of _root, _parent and _levelx. None of which I truly understand.

      Any help would be much appreciated! Plus any good tutorial links on timeline and referring to objects in it!

      (Couldn't find the code tag/button...)