thomasfrank.se

FlashPaper 2 -- links to internal functions

July 4, 2006

Using FlashPaper to quickly convert text into Flash content can seriously speed up your production of Flash applications. If you use a nice Word template your graphic design doesn't have to suffer either. Excellent!

What -- no internal links?

The hyperlinks you create in FlashPaper, via Word, can only point to different web sites. Wouldn't it be nice to be able to point to internal Flash functions as well? Having a link that says "start this part of the program" that really works? I think it would, so I've written a small solution for you.

Let us modify the FlashPaper API

The API for FlashPaper 2 has a method called goToLinkTarget. And fortunately Macromedia's programmers use their own API -- they call this method each time you click a link in a FlashPaper document.
In the example below the API of FlashPaper is accessed through the object fpAPI (if you unsure about how to create such an object read Macromedias API specs, see the link above).
// store original FlashPaperAPI-method
_global.originalFlashPaperAPI={
	goToLinkTarget: fpAPI.goToLinkTarget
}

// replace with our own API-method
fpAPI.goToLinkTarget=function(x,y){
	if (x.indexOf("www.asfunction.com")<0){
		// use original link-function
		originalFlashPaperAPI.goToLinkTarget(x,y)
	}
	else {
		// convert hyperlink to function call
		x=x.split("?")[1].split(",")
		_root[x[0]](x[1])
	}
}

Creating internal links in Word

You can now call any function you desire at _root-level in your Flash-application by creating a link in a Word-document:
  1. Right-click in your Word document and choose Hyperlink.
  2. Write your link address like this:
www.asfunction.com?myFunction,parametervalue

When you're happy with your Word document:
  1. Convert to FlashPaper 2.
  2. Load the FlashPaper document into your Flash application.
  3. Try out your links.
[comments]