0

I would like to use FileReference.save() in 4 different place in a flash game. All 4 methods are the same (copy & paste). Locally, all 4 work perfectly however when I put the swf in browser, facebook actually, only one of them works as expected and the others do not. In Chrome, all 3 have never worked. In Safari, they work sometimes but nondeterministic. What can be the reason? Any idea?

By the way, I compiled with Air 2.5 and Air 3.2 Desktop, I use Flash CS6

    private function onScreenShotButtonClicked(e:MouseEvent)
    {
        mScreenShotButton.removeEventListener(MouseEvent.CLICK, onScreenShotButtonClicked);

        var finalBitmapData:BitmapData = new BitmapData(810, 520, true, 0x00000000);
        var finalBitmap:Bitmap = new Bitmap(finalBitmapData, PixelSnapping.ALWAYS, false);
        finalBitmapData.draw(mParent.root);
        var finalData:ByteArray = new ByteArray();
        finalData = PNGSave.encode(finalBitmapData);

        var tempFileReference:FileReference = new FileReference();
        tempFileReference.addEventListener(Event.COMPLETE, onSaveCompleted);
        tempFileReference.addEventListener(Event.CANCEL, onSaveCancelled);
        tempFileReference.save(finalData, "boombox.png");
    }
  • Could you give a more elaborate description than "do not work"? Is there some sort of error, does it crash, no dialog box, etc? – puggsoy Apr 20 '13 at 11:24
  • add error listeners to tempFileReference –  Apr 20 '13 at 15:32
  • @puggsoy : Thank you for your response. It does not crash but nothing happens when I click the button, as you said, no dialog box pops up. – umut demirel Apr 22 '13 at 14:19
  • @LeeBurrows : Thank you for your response. Is there anyway to debug the swf on browser except using text label debug :) – umut demirel Apr 22 '13 at 14:20
  • take a look at http://stackoverflow.com/questions/13999626/can-i-build-a-debug-version-of-an-adobe-air-application/14000013#14000013 –  Apr 22 '13 at 14:36

1 Answers1

0

The common problem is that your method dont't have MouseEvent instance param. May be you call Filereference.save () but you don't have a event argument in function.

  • Thank you for your response. There is a MouseEvent instance param in the method "private function onScreenShotButtonClicked(e:MouseEvent)". What should I do with it? – umut demirel Apr 22 '13 at 14:26