6 Mar 2009
Dock and system tray with Adobe AIR
Nice tutorial I guess:
http://www.adobe.com/devnet/air/flash/quickstart/stopwatch_dock_system_tray.html
Markus Raab – All I don’t know.
Information Accumulation.
6 Mar 2009
Nice tutorial I guess:
http://www.adobe.com/devnet/air/flash/quickstart/stopwatch_dock_system_tray.html
6 Nov 2008
While developing the print functionality within a framework I got stuck on the behaviour of the Flash Player print implementation.
I couldn't solve the following steps:
I really thought this would be an easy task but now I think it's not possible. Several attempts later I figured out that after calling PrintJob.start() there is no way to use the flash event model! This means loading contents after calling PrintJob.start() is impossible!
WOW!
So I used a workaround: I create all the print pages like I mentioned before, but without calls on the PrintJob-API. I simply store every print page as BitmapData and afterwards I create the PrintJob within a loop.
Now I have multiple other problems:
Did I slip something?
Finally I created a small example to show you the disfunctionality (PrintJobProblem.as):
/**
* @author Markus Raab - derRaab.com / superclass.de
*/
public class PrintJobProblem extends Sprite
{
private var _numPrintOuts : int;
private var _printOutIndex : int;
private var _printJob : PrintJob;
/**
* Starts a event based printout test after a loop based
* test has successfully finished.
*/
public function PrintJobProblem()
{
_numPrintOuts = 2;
runLoopBasedTest( );
runEventBasedTest( );
}
/**
* Demonstrates and ensures the functionality.
*/
private function runLoopBasedTest() : void
{
_printJob = new PrintJob();
if ( _printJob.start() )
{
for ( var i : int = 0; i <_numPrintOuts; i++ )
{
addPage( i );
}
_printJob.send();
}
}
/**
* Demonstrates that after calling PrintJob.start() the internal
* eventmodel doesn't dispatch any events at all. Everything is blocked
* until the script times out.
*/
private function runEventBasedTest() : void
{
_printJob = new PrintJob();
if ( _printJob.start() )
{
trace( getTimer(), "PrintJob.start() called" );
_printOutIndex = 0;
startAddPagesOnEnterFrame();
}
}
private function startAddPagesOnEnterFrame() : void
{
addEventListener( Event.ENTER_FRAME, onAddPagesOnEnterFrameEvent );
}
private function onAddPagesOnEnterFrameEvent(event : Event) : void
{
if ( _printOutIndex == _numPrintOuts )
{
stopAddPagesOnEnterFrame();
_printJob.send();
trace( getTimer(), "PrintJob.send()" );
}
else
{
addPage( _printOutIndex++ );
}
}
private function stopAddPagesOnEnterFrame() : void
{
removeEventListener( Event.ENTER_FRAME, onAddPagesOnEnterFrameEvent );
}
private function addPage( pageIndex : int ) : void
{
var page : Sprite = createPrintPage( pageIndex );
stage.addChild( page );
var viewWidth : Number = page.width;
var viewHeight : Number = page.height;
var scaleX : Number = _printJob.pageWidth / viewWidth;
var scaleY : Number = _printJob.pageHeight / viewHeight;
var scale : Number = Math.min( scaleX, scaleY );
page.scaleX = page.scaleY = scale;
var printRect : Rectangle = new Rectangle( 0, 0, viewWidth, viewHeight );
try
{
_printJob.addPage( page, printRect );
}
catch( e: Error )
{
trace( getTimer(), "PrintJob.addPage() failed" );
}
stage.removeChild( page );
}
private function createPrintPage( pageIndex : int) : Sprite
{
var page : Sprite = new Sprite();
var textField : TextField = new TextField();
textField.autoSize = TextFieldAutoSize.LEFT;
textField.text = "Page " + pageIndex;
page.addChild( textField );
return page;
}
}
}
8 Oct 2008
I found this adobe help page but I didn't want to use command line for packaging an AIR installation file. Simply because I'm not used to it. So I was looking for a different way.
Well, actually Flex Builder provides the possibility to do that, but you must ensure to activate the "Copy non-embedded files to output folder" compiler option in the project properties. Otherwise Flex Builder won't let you select your additional sources.
And for that reason you have to put your additional sources to the src-folder.
8 Oct 2008
Another very basic information. I had to export multiple .fla files so I wrote my first .jsfl file:
var fileName;
var fileSrc;
var fileBin;
var fla;
for ( var i = 0; i <fileNames.length; i++ )
{
fileName = fileNames[ i ];
fileSrc = srcDir + fileName + ".fla";
fileBin = binDir + fileName + ".swf";
fla = fl.openDocument( fileSrc );
fla.exportSWF( fileBin, true );
fl.closeDocument( fla, false );
}
10 Sep 2008
Just a quick note because it took me a little while to find out that it's necessary to use "file://" syntax to access the local file system.
// or use a file reference:
var file: File = new File();
var url: String = file.url;
var loader: Loader = new Loader();
loader.load( new URLRequest( url ) );
17 Jul 2008
While developing an Flex based AIR Application I figured out an issue with the flash.filesystem.File class. I tried to access properties like exists, nativePath etc. before a nativePath was set using a browse method. So the while debugging the following error was triggered:
Well, I would expect to get at least some default values. For example File.exists should be false or something. But you will always get an exception. So after research I found a note about it here.
Anyway, the only chance you have is to catch the error.
But there is one thing more: If you publish the AIR application, install it and try it then, you won't get an exception. Everything works fine than.
17 Jun 2008
Well, it took me a little time to figure out how to select and load a local SWF file into an SWFLoader instance. Several times I got this error message:
“SecurityError: Error #3015: Loader.loadBytes() is not permitted to load content with executable code.”
After some research I found this "dreaming in flash" blog entry which basically contains the solution I was looking for.
But then it took me a little more time to figure out how to use this with the SWFLoader. So here is a basic code example:
// File reference
var swfFile: File;
// Open the SWF file
var fileStream: FileStream = new FileStream();
fileStream.open( swfFile, FileMode.READ );
// Read SWF bytes into byte array and close file
var swfBytes: ByteArray = new ByteArray();
fileStream.readBytes( swfBytes );
fileStream.close();
// Prepare the loader context to avoid security error
var loaderContext: LoaderContext = new LoaderContext();
loaderContext.allowLoadBytesCodeExecution = true; // that's it!
// Now you could use this with a Loader instance
var loader: Loader = new Loader();
loader.loadBytes( swfBytes, loaderContext );
// Or you could use this with a SWFLoader instance
var swfLoader: SWFLoader = new SWFLoader();
swfLoader.loaderContext = loaderContext;
swfLoader.source = swfBytes;
31 May 2008
I found great slides on Grant Skinners blog. They give a quick introduction in AS 3 and it's core benefits!
50 reasons why AS 3 kicks ass (Grant Skinner)
Also a must read for developers!
Update: And he also added more slides from a workshop here
29 May 2008
Since I have to use Microsoft Word 2008 for Mac I figured out some issue: During opening a clean XHTML file with external CSS declarations Word can find these CSS files only in the same directory. I tried serveral ways to declare the href tag, but only the last one works...
Maybe there is a solution? I can't figure it out.
10 May 2008
As a developer you should definitely have a look at this paper