2 Replies Latest reply: Jun 16, 2006 1:47 PM by RyanDeluz RSS

    Linking to a part (anchor) in FlashPaper

    deluz
      I am trying to create a simple system that will let me open a FlashPaper .swf file to a certain section.

      I need this navigation to come externally, such as passing a link in, calling a variable, etc. I have Macromedia Director and have FlashPaper working in Director. I could also pass the call via an html page.

      Is there any way to do this?

      Ryan Deluz
        • 1. Re: Linking to a part (anchor) in FlashPaper
          RyanDeluz
          The quick answer is the function goToLinkTarget, but this is very poorly implemented in version 2 of FlashPaper.

          My solution and code to help goToLinkTarget work better follows:

          I am going to use Zinc to pass the link in via command line (as I couldn't get FlashPaper in director to resize properly). I created a function that will read the original names as shown in my Word Document.

          FlashPaper starts by changing the names of the links (anchors) when a word document is converted. It does not expose an interface to get these new names, so I don't know how people were assumed to use the goToLinkTarget function.

          The following code should work to load a .swf FlashPaper and create a map of its links for easy use. I hope this helps people.

          This also includes code to dynamically resize FlashPaper so that it looks good in a resizable player.

          //LOAD FLASH PAPER
          Stage.scaleMode = "noScale";
          Stage.align = "TL";
          //create MovieClip holder for FlashPaper
          //create instance of MovieClip holder and place on stage
          var mFlashPaperMC:MovieClip = _root.createEmptyMovieClip("mFlashPaperMC", _root.getNextHighestDepth());
          var mFlashPaper;
          var mBookmarkMap:Object;
          //flash paper interface
          var mFlashPaperListener:Object = new Object();
          mFlashPaperListener.onLoaded = function(mFlashPaper:Object):Void {
          //loading is complete, so we can now adjust the current page, zoom, etc.
          //mFlashPaper.setCurrentPage(mFlashPaper.getNumberOfPages());
          //mFlashPaper.setCurrentZoom(33);
          mFlashPaper.addListener(this);
          mFlashPaper.showUIElement("Brand", false);
          mFlashPaperMC.toolbar_mc.brandClip_mc._visible = false;
          mBookmarkMap = mapBookmarks(mFlashPaperMC);
          goBookmark("Home", mFlashPaper, mBookmarkMap);
          //mFlashPaper.setCurrentPage(mFlashPaper.getNumberOfPages());
          };
          //LISTENS FOR RESIZE AND RESIZES FLASH PAPER
          var mStageListener:Object = new Object();
          mStageListener.onResize = function() {
          mFlashPaper.setSize(Stage.width, Stage.height);
          };
          Stage.addListener(mStageListener);
          loadFlashPaper("QuickStartHelp.swf", mFlashPaperMC, Stage.width, Stage.height, mFlashPaperListener);
          stop();
          function loadFlashPaper(path_s, dest_mc, width_i, height_i, loaded_o) {
          var intervalID = 0;
          var loadFunc = function () {
          dest_mc._visible = false;
          mFlashPaper = dest_mc.getIFlashPaper();
          if (!mFlashPaper) {
          return;
          }
          if (mFlashPaper.setSize(width_i, height_i) == false) {
          return;
          }
          dest_mc._visible = true;
          clearInterval(intervalID);
          loaded_o.onLoaded(mFlashPaper);
          };
          intervalID = setInterval(loadFunc, 100);
          dest_mc.loadMovie(path_s);
          }
          function mapBookmarks(flashPaperMC) {
          //associative array to store book marks
          var asArray:Object = new Object();
          trace(flashPaperMC);
          trace(flashPaperMC.fpBookmarks_array);
          trace(flashPaperMC.fpBookmarks_array.length);
          for (var i = 0; i<flashPaperMC.fpBookmarks_array.length; i++) {
          trace(flashPaperMC.fpBookmarks_array .publicName_str);
          asArray[flashPaperMC.fpBookmarks_array
          .publicName_str] = flashPaperMC.fpBookmarks_array .anchorName_str;
          //store this bookmark name
          for (var j = 0; j<mFlashPaperMC.fbBookmarks_array
          .length; j++) {
          asArray[flashPaperMC.fpBookmarks_array [j].publicName_str] = flashPaperMC.fpBookmarks_array[j].anchorName_str;
          }
          }
          trace(asArray.toString());
          return asArray;
          }
          function goBookmark(theName, flashPaperI, bookmarkMap) {
          flashPaperI.goToLinkTarget("anchor:"+bookmarkMap[theName]);
          }
          • 2. Re: Linking to a part (anchor) in FlashPaper
            RyanDeluz Community Member
            FYI the internal name / anchor structure looks like this:
            /*
            Variable _level0.mFlashPaperMC.fpBookmarks_array = [object #116, class 'Array'] [
            0:[object #117, class 'Object'] {
            subBookmarks_array:[object #118, class 'Array'] [
            0:[object #119, class 'Object'] {
            anchorName_str:"_FPB1",
            publicName_str:"2 Inhibits – 1 Reward"
            },
            1:[object #120, class 'Object'] {
            anchorName_str:"_FPB2",
            publicName_str:"1 Inhibit – 1 Reward"
            },
            2:[object #121, class 'Object'] {
            anchorName_str:"_FPB3",
            publicName_str:"Multiple Inhibits"
            },
            3:[object #122, class 'Object'] {
            anchorName_str:"_FPB4",
            publicName_str:"Alpha / Theta"
            }
            ],
            anchorName_str:"_FPB0",
            publicName_str:"Choosing a Training Type"
            },
            1:[object #123, class 'Object'] {
            subBookmarks_array:[object #124, class 'Array'] [
            0:[object #125, class 'Object'] {
            anchorName_str:"_FPB6",
            publicName_str:"No Game"
            },*/