0 Replies Latest reply on Aug 28, 2006 8:21 AM by mgschange

    Load internal SWF and control other SWF

    mgschange Level 1
      I have 96 questions with radio button responses that control movie clips. They are all in the same swf but I want to separate the questions and put them in a draggable, scalable movie clip so that the user could move the question box as convenient. Most of the ActionScript is associated with the MCs, responding to a radio button listener object. The two SWFs must advance from frame to frame synchronously.

      Here is what I did:
      1. Split the original FLA into 2 pieces, a MC FLA and a Question FLA
      2. Renamed rbListener as _global variable in MC FLA
      3. Used this code in the MC FLA:
      this.createEmptyMovieClip("loadQuestions_mc", this.getNextHighestDepth());
      loadQuestions_mc._height = 400;
      loadQuestions_mc._width = 600;

      loadQuestions_mc.onPress = function():Void {
      this.startDrag();
      };
      loadQuestions_mc.onRelease = function():Void {
      this.stopDrag();
      };
      loadQuestions_mc.createEmptyMovieClip("containQuestions_mc", this.getNextHighestDepth());
      loadMovie("mccolor4_SplitBottom.swf", containQuestions_mc);

      4. Used this code in the first frame of Questions FLA:
      function specifyListeningTargets () {
      i = cellNumber;
      eval("QA" + i).addEventListener("click", rbListener);
      eval("QB" + i).addEventListener("click", rbListener);
      eval("QC" + i).addEventListener("click", rbListener);
      }

      // Button pops up at x:400, y:600, What is 10? Depth?; clicking button advances to next frame.
      function popupNav () {
      i = cellNumber
      if (((eval("QA" + i).selection.data) > 0),
      ((eval("QB" + i).selection.data) > 0),
      ((eval("QC" + i).selection.data) > 0)) {

      this.createClassObject(mx.controls.Button, "popupNext_btn", 10, {label:"Go To Next Questions"});
      popupNext_btn._width = 20;

      popupNext_btn.move(250, 375);
      }
      function popupClicked() {
      this.nextFrame();
      _parent.nextFrame();
      }
      popupNext_btn.addEventListener("click", popupClicked);
      }
      5. Used this code in each frame of the Questions Fla:
      stop();
      cellNumber = 1;
      popupNext_btn._visible = false;
      popupNav ();
      specifyListeningTargets(); Text