Flex SDK Questions

Publishing Print2Flash Documents embedding them in Flex applications
Post Reply
SamK
Posts:2
Joined:Wed Jan 23, 2008 10:09 am
Flex SDK Questions

Post by SamK » Wed Jan 23, 2008 10:45 am

Hi,

I have recently downloaded the commercial trial (2.7:32 bit) of
Print2Flash and the SDK (2.7). So far Flex (Builder 2) integration is
going well, although I still have a few issues:

1. Is it possible to change the light blue background colour behind the doc?

If not with the public API, maybe there is a programmatic way I can do it?
I'm looking for any solutions here. If I'm unable to make the background
white this is going to be a show-stopper for me WRT Print2Flash.

2. Can I get the document to appear scrolled down slightly?

For aesthetic reasons, I need the doc to appear scrolled down a tiny bit.
I have tried hiding the document, setting the scroll using setScrollPosition,
then making it visible in the onLoaded event. Unfortunately the doc still
appears unscrolled then flicks down after about 1/2 a second. Any
suggestions on this?

3. Is it possible to change the Print2FlashDoc source property dynamically?

Ideally I would like a single Print2FlashDoc in my markup and load different
swf docs into it via script. I have tried setting the source property to a different
doc in script, but the new document does not appear.

If I can find solutions to the above issues, I would happily buy a full
commercial licence and go with Print2Flash for our site.

Many thanks

staff
Posts:267
Joined:Sat Dec 15, 2007 4:48 pm

Re: Flex SDK Questions

Post by staff » Sun Jan 27, 2008 4:51 am

1. Currently there is no function in Document API to set document area background color. However, if you used Print2Flash document from ActionScript 2, the color could be changed with the code like this:

Code: Select all

p2f.DocArea.setStyle("backgroundColor", 0x800000)
but as you are loading documents from Flex, this would not work as cross-scripting between AS2 and AS3 movies is not allowed. A possible solution is to embed a Print2Flash document into a "wrapper" AS2 movie (created with Macromedia Flash Professional or Adobe CS3 with AS2 support) which would load your document and sets the color using the code above. Then you could load that wrapper movie instead of the document itself into Print2FlashDoc Flex component.
This solution should work but it appears rather cumbersome and we'll probably include a direct API function for changing colors in future versions of Print2Flash
2. This is possible to achieve. The problem is document becomes visible before scrolling is completed due to asynchronous nature of AS2/AS3 interaction. To make it work, you need to do the following:
a) Hide the Print2FlashDoc component instance before loading the document by setting its visible property to false
b) implement an onLoaded event handler and put the code such as this there:

Code: Select all

doc.setScrollPosition(new Print2Flash.Point(0,5))
This will make the document to scroll a bit from the top
c) implement an onVisibleAreaChanged event handler and add this code there:

Code: Select all

if (event.area.vPosition==5) doc.visible=true;
This will make the document visible again after scrolling is completed
3. Please download the latest SDK (2.7.0.1) from http://print2flash.com/download.php This problem is fixed there

jaymz
Posts:14
Joined:Mon Jan 28, 2008 4:29 pm

Re: Flex SDK Questions

Post by jaymz » Mon Jan 28, 2008 4:47 pm

staff wrote:1. Currently there is no function in Document API to set document area background color. However, if you used Print2Flash document from ActionScript 2, the color could be changed with the code like this:

Code: Select all

p2f.DocArea.setStyle("backgroundColor", 0x800000)
but as you are loading documents from Flex, this would not work as cross-scripting between AS2 and AS3 movies is not allowed. A possible solution is to embed a Print2Flash document into a "wrapper" AS2 movie (created with Macromedia Flash Professional or Adobe CS3 with AS2 support) which would load your document and sets the color using the code above. Then you could load that wrapper movie instead of the document itself into Print2FlashDoc Flex component.
Beautiful! Thank you, this is just the solution I was looking for. I was already using a "wrapper" AS2 movie, just as you suggested, to gain access to the p2f onload event and to show a "loading" message as my server processes the document itself.

Are there other properties/methods that I am able to access in a similar fashion? For example, am I able to modify the background colors of other parts of the flash UI? Am I able to modify borders and border colors? [Are all of these properties already listed somewhere, and I'm just missing it?]

In particular, just like SamK, I would also like to make the background color white [already done - thanks!], but I want to show a darker border around each page, to distinguish pages from the background. Can this be accomplished? Thanks in advance.

SamK
Posts:2
Joined:Wed Jan 23, 2008 10:09 am

Re: Flex SDK Questions

Post by SamK » Mon Jan 28, 2008 5:29 pm

A possible solution is to embed a Print2Flash document into a "wrapper" AS2 movie (created with Macromedia Flash Professional or Adobe CS3 with AS2 support) which would load your document and sets the color using the code above. Then you could load that wrapper movie instead of the document itself into Print2FlashDoc Flex component.
Oh good. I thought I might have to implement my own "InternalInterface" to do this. I'll give it a go.
A new backgroundColor property in the next API would be great..
a) Hide the Print2FlashDoc component instance before loading the document by setting its visible property to false
b) implement an onLoaded event handler
c) implement an onVisibleAreaChanged event handler
This worked, thanks. I actually tried onVisibleAreaChanged at one point, but not with the vPosition check.
Please download the latest SDK This problem is fixed there
Will do, thanks for all the help.

staff
Posts:267
Joined:Sat Dec 15, 2007 4:48 pm

Re: Flex SDK Questions

Post by staff » Tue Jan 29, 2008 12:54 am

jaymz wrote: Are there other properties/methods that I am able to access in a similar fashion? For example, am I able to modify the background colors of other parts of the flash UI? Am I able to modify borders and border colors? [Are all of these properties already listed somewhere, and I'm just missing it?]

In particular, just like SamK, I would also like to make the background color white [already done - thanks!], but I want to show a darker border around each page, to distinguish pages from the background. Can this be accomplished? Thanks in advance.
Actually for scrolling the document pages Print2Flash uses standard ScrollPane Flash component. It has a number of properties and methods which you can use to achieve additional functionality. Here is the link to the help page on this component: http://livedocs.macromedia.com/flash/8/ ... 03977.html Colors of this component are controlled by styles which are detailed here: http://livedocs.macromedia.com/flash/8/ ... 03975.html

To draw a border around a page, you may obtain a reference to the page movie instance using this code:

Code: Select all

var page1=doc.Pages[0].movie
Here the 0 index refers to the first page, the 1 would refer to the second page and so on. Then you may attach an empty movie clip to this instance and draw on that movie using standard drawing capabilities of MovieClip class.

Note that all these methods are currently undocumented and may stop to work in future versions of Print2Flash. We plan to add documented methods for doing this in the future.

jaymz
Posts:14
Joined:Mon Jan 28, 2008 4:29 pm

Re: Flex SDK Questions

Post by jaymz » Tue Jan 29, 2008 12:24 pm

staff wrote: Actually for scrolling the document pages Print2Flash uses standard ScrollPane Flash component. It has a number of properties and methods which you can use to achieve additional functionality. Here is the link to the help page on this component: http://livedocs.macromedia.com/flash/8/ ... 03977.html Colors of this component are controlled by styles which are detailed here: http://livedocs.macromedia.com/flash/8/ ... 03975.html
Cool. This sounds just what I was looking for again! I'll check it out today. Thanks for your fast reply... keep up the good work, all!

Post Reply