hi
i am using flex plug in 3.2, flashplayer10.
i want to be able to load and unload a doc. here is your adapted code.
i realize i have to use the onUnloadCompletedEvent but i don't know how
i am trying to figure out how to add the listener
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:ns1="Print2Flash.*" width="910"
creationComplete="applicationComplete()" height="610" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
import Print2Flash.*
import weborb.data.DynamicLoadEvent;
import mx.controls.Alert;
private var totalPages:Number;
private var sourceSwf:String;
private var unloadCompletedEvent:UnloadCompletedEvent;
private function applicationComplete():void
{
parentApplication.addEventListener(LoadedArtist.LOADEDARTIST,updateArtist);
}
function Init(){
}
public function updateArtist(event:LoadedArtist){
if(sourceSwf){
sourceSwf = "galleries/swf_files_flash2print/" + event.artistSource + ".swf"
doc.unload()
}else{
sourceSwf = "galleries/swf_files_flash2print/" + event.artistSource + ".swf"
doc.source = sourceSwf
}
}
public function SetPageNo(page:Number):void {
PageNo.text = page+" of "+totalPages;
}
public function ongetNumberOfPages(num:Number):void {
//Alert.show( "Test ID","test" );
totalPages=num;
SetPageNo(1);
}
public function ongetUnloadCompleted(event):void {
//Alert.show( "Event","test " + sourceSwf );
var unloading = UnloadCompletedEvent(event);
unloading.addEventListener("loaded=",
function(event:DynamicLoadEvent):void
{
artistResult()
});
}
private function artistResult():void {
Alert.show( "Event","test doc " + sourceSwf );
doc.source = sourceSwf
}
]]>
</mx:Script>
<ns1:Print2FlashDoc x="10" y="41" width="733" height="549" id="doc" unload = "ongetUnloadCompleted(event)" onLoaded="doc.getNumberOfPages(ongetNumberOfPages)" onPageChanged="SetPageNo(event.page)"/>
<mx:Image x="10" y="10" source="images/dragbyhand.gif" click="doc.setCurrentTool("move")"/>
<mx:Image x="35" y="10" source="images/selecttext.gif" click="doc.setCurrentTool("select")"/>
<mx:Image x="63" y="10" source="images/fitwidth.gif" click="doc.setCurrentZoom("width")"/>
<mx:Image x="89" y="10" source="images/fitpage.gif" click="doc.setCurrentZoom("page")"/>
<mx:Image x="115" y="10" source="images/prevpage.gif" click="doc.PreviousPage()"/>
<mx:Image x="194" y="10" source="images/nextpage.gif" click="doc.NextPage()"/>
<mx:Image x="224" y="10" source="images/rotate.gif" click="doc.Rotate()"/>
<mx:Image x="253" y="10" source="images/print.gif" click="doc.printTheDocument()"/>
<mx:Image x="284" y="10" source="images/newwindow.gif" click="doc.OpenInNewWindow()"/>
<mx:Image x="312" y="10" source="images/help.gif" click="doc.OpenHelpPage()"/>
<mx:Label x="145" y="16" width="47" id="PageNo" textAlign="center"/>
</mx:Canvas>
load and unload
Re: load and unload
To load another Print2Flash document using the same Print2FlashDoc component instance, you need to call unload method of the component, wait for onUnloadCompleted event and then load another document using source property of the component.
To declare onUnloadCompleted event handler you need to use this component embedding code:
To staring unloading you may use this code:
And your onUnloadCompleted event handler may look like this:
To declare onUnloadCompleted event handler you need to use this component embedding code:
Code: Select all
<ns1:Print2FlashDoc x="10" y="41" width="733" height="549" id="doc" onUnloadCompleted = "ongetUnloadCompleted(event)" onLoaded="doc.getNumberOfPages(ongetNumberOfPages)" onPageChanged="SetPageNo(event.page)"/>
Code: Select all
doc.unload();
Code: Select all
public function ongetUnloadCompleted(event:Event):void {
doc.source="newdoc.swf"
}
Re: load and unload
I'm at the same point, loading different documents in the Print2FlashDoc component, using external controls to handle the document manipulation.
When unloading current one and loading the next, the LocalConnection seems to take some time (long time, between 20-60 seconds) to update the new data, showing meanwhile the old document data (page quantity i.e) while buttons don't work. After some time, data updates and quantity of pages and controls works ok.
Looking inside the print2FlashDoc component, I can see that the LocalConnection is closed and reopen ok when I load the next doc, but calls to OnAPILCStatus (LocalConnection StatusEvent handler) whit a null code and status level fires constantly until data is updated.
Aditionally, when you iterate trough the proccess (Load A, B, C then again A, B, C) the problems dissapears. Delay is similar between long and short documents, so I think is more related to something around LocalConnection or probably something around loaderInfo not unloading.
Since LocalConnection implementation is browser/OS dependant, probably this could vary. Anyway I,m working on a fairly general setup: Windows Vista + IE , Vista + FF , Flash Player 10, Flex 3 (sdk 3.2), Print2Flash SDK 2.7.3
Any idea about where to look or workarounds are welcome. Can post some example if needed
Jorge
When unloading current one and loading the next, the LocalConnection seems to take some time (long time, between 20-60 seconds) to update the new data, showing meanwhile the old document data (page quantity i.e) while buttons don't work. After some time, data updates and quantity of pages and controls works ok.
Looking inside the print2FlashDoc component, I can see that the LocalConnection is closed and reopen ok when I load the next doc, but calls to OnAPILCStatus (LocalConnection StatusEvent handler) whit a null code and status level fires constantly until data is updated.
Aditionally, when you iterate trough the proccess (Load A, B, C then again A, B, C) the problems dissapears. Delay is similar between long and short documents, so I think is more related to something around LocalConnection or probably something around loaderInfo not unloading.
Since LocalConnection implementation is browser/OS dependant, probably this could vary. Anyway I,m working on a fairly general setup: Windows Vista + IE , Vista + FF , Flash Player 10, Flex 3 (sdk 3.2), Print2Flash SDK 2.7.3
Any idea about where to look or workarounds are welcome. Can post some example if needed
Jorge
Re: load and unload
Hi, after the unloading is completed, I've again put the source but now it says "undefined". Any ideas?
Re: load and unload
Solved: I used p2f.callLater(..), seem's the p2f is not ready yet after I've unloaded.
Re: load and unload
orRomeo wrote:Solved: I used p2f.callLater(..), seem's the p2f is not ready yet after I've unloaded.
callLater(function (someArg:String):void {
something.text = someArg;
}, 'Something')