MediaScannerConnection for AS3/AIR? - actionscript-3

import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
These are classes available in Java to refresh the detected images on an SD card on an Android device.
If you save an image to the SD card, it's there, but not visible unless you mount the device, unmount the device. These Java classes fix that problem.
But I'm building an App using AS3 and AIR, does anyone know the equivalent classes for AIR, AS3?

You can use Adobe Air's File class to poke around the device (also cf., Working with Files). Once you figure out what code gets you to the USB device, you can load it as a ByteArray and convert that to an image.
If you are looking for image import/conversion code, just search for what you need; there are numerous posts out there, and the answers are fairly standardized.

Related

AFEFontManager in Adobe AIR. How to embed fonts now?

I have been building my games using FlashDevelop with Flex SDK compiler all the time, but now I need ASC 2.0 with adobe air. So I have migrated to it. But one problem came out, which I just can't find a solution for. I need to embed TTF fonts, which I used to always add additional compiler option -managers=flash.fonts.AFEFontManager for. In this new AIR SDK all I get is the next warning:
command line
Warning: 'compiler.fonts.managers' is not fully supported.
And of course fonts do not embed.
Is there a solution for it?
Here's how I embed them
[Embed(source = "VERDANA.TTF", fontName = "verdana")]
private static var Verdana: Class;
Well, the answer to this is that Adobe (for some unknown reason) have cut font pretranscoding out of ASC 2.0, so all fonts must be pretranscoded now to be able to embedded into code. The easiest way is to use Adobe Flash pro, to embed font and pack it as SWC. Then attach it to your project somewhow, and register font via Font.registerFont(Arial); (or some other class you have attached to it). Bingo! Now you can use it.
The second, more complicated, but cheaper way is to use fontswf utility from adobe
Details can be found here http://www.bytearray.org/?p=4789 and here: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f5f.html (at the bottom of the page)

Creating Preloader for SWF in AS3 Flash Builder

I'm a relatively new developer in AS3 using Flash Builder. My objective is to create a quick/fast loading small SWF preloader for a larger (30mg) SWF application. I can't include the larger SWF inside the preloader, but I can use external interface calls to get jquery to tell me what the speed of internet the users are using and figure out how long it should take to load based on the size of the larger SWF.
Right now, we have a large web application that takes around 5 mins to load if the client has a slow internet connection. So, we wanted to use a small SWF preloader that will display a loading circle or loading bar, and display options if the SWF takes longer than 5 mins to load. Kind of like error handling. For instance, for Safari, sometimes the player actually has to click the SWF in order for it to load. Is it possible to have a button on the SWF that will make it start loading?... Is it easier to create the preloader in jQuery? I'm just wondering if it's just going to create more issues using a SWF to load a SWF. Any ideas?...
Any ideas on how to tackle this beast? I've read almost every article about preloaders but there is nothing that references preloaders created in Flash Builder.
I can't use Flash Professional or timeline. It has to be in Flash Builder.
So I tried to use the below tutorial and I wasn't able to actually get anything to appear when I test it. I'm getting an error at the "run()" function:
Error: Error #2136: The SWF file http://local.myproj.com/MyProject.swf contains invalid data.
at Preloader/run()[/Development/MyProject/src/Preloader.as:109]
at Preloader/onEnterFrame()[/Development/MyProject/src/Preloader.as:46]
References:
http://fortheloss.org/how-to-preloader-in-flash-builder-4-7/
I worked until two years ago with a lot of these things and I know I have a few good scripts in my databases, but you are talking about Preloaded & activated loading were as in a preloader it is out of the hands of say a visitor what he or she can or cannot do, and in using a button (possible of course) the visitor has a choice to download or not! From memory there was never really a lot published yet over years of using Flex Builder I have collected some good AS3 scripts and modified them (including a progress-bar - but without time Indicator) to download in web Apps. or FLEX AIR etc. with AS3.
The small problem would only be to adapt any of it from mx to fx depending on what FLEX Builder you use!
I used my scripts mainly to download high resolution Images, Calendars, SWFs etc. with up to compressed 22 mB! Anyway, if Interested I have to look up my FLEX databases & Application to get it to you! rgs Aktell

WinRT barcode scanner component

I have a Windows Store (Metro) application. I need to add support for scanning barcodes.
I tried using ZXing first. From what I was able to get working, you actually need to click and save an image for it to do the processing. There's no nice overlay of a red line "scanner" nor does it process a live feed. This isn't a very elegant solution. It works far better on Android. Basically, this won't work as I need a constant video and a constant search for a barcode to be in focus.
This blog (http://www.soulier.ch/?p=1275&lang=en) mentions that extrapolating a frame out of a WinRT video stream is not allowed in managed code which means I'd need to use C++.
So, are there any components out there that do this? Anything free or paid that I can get that would be written in C++ and can find and extrapolate a barcode? Learning C++ is not on my bucket list.
You can capture frames while displaying a preview with C# only. Here's an example control that does it:
https://winrtxamltoolkit.codeplex.com/SourceControl/latest#WinRTXamlToolkit/Controls/CameraCaptureControl/CameraCaptureControl.cs
Basically you need to create a MediaCapture object and associate it with a CaptureElement control to display the preview. Then you can use CapturePhotoToStreamAsync() to capture a frame to a stream of your selected encoding format and then have a go at it with your bar code reading code.
I made a lib for WinRT using ZXing & Imaging SDK.
It works well (but does not include any additional focus feature).
There is a lib and a sample app that you can try.
It works for barcodes and QRCode (barcode by default but just change the optional parameter in the scan function code to use QRCode)

FLVPlayback without Flash CS

I'm implementing Google video Ads in flash game, using FlashDevelop. Google has a sample where they're using FLVPlayback component to display video... problem is, I don't have this class anywhere.
I've searched how to add it, but all solutions say "link to C:\Adobe\Flash CS\Components\etc" path, which obiouvsly without Flash CS I don't have... and don't want to install it just for this :)
I wonder if there is a way to get the FLVPlayback without installing Flash CS?
You can try import external adobe components swc through Flashdevelop interface.
Maybe this can help you: link
I quit and just installed the Flash Professional CC, and there linked to the component path, but it didn't work for some reason. Then I included the FLVPlayback.swf component inside my AS3 app, which compiled etc. but as I learned FLVPlayback wasn't really what I needed.
After some fumbling I made it work with Flex Spark component - VideoPlayer, used inside AS3. You can find some code on the devlist: https://developers.google.com/interactive-media-ads/community?place=msg%2Fima-sdk%2Fc3KH11vxSd0%2FeLuYneYpch4J

Create SWF video of images through Adobe Flex

I don't know whether it's the right place to put this up. But I've been trying from past 12 hours and haven't found anything related.
I'm creating a Adobe AIR project (which'll run on desktop), it'll ask for image locations on the local pc.
After the user is done selecting images. I want to output a SWF video (slideshow) of the selected images.
How to do the second step. Please guide. I want to create an output file (SWF) from my AIR Flex Desktop Application.
Check out https://github.com/claus/as3swf to compile SWFs at runtime...
This individual seems to have had a similar issue AS3 to Generate Dynamic SWF?
You can try following options from SWFtools
JPEG2SWF Takes one or more JPEG pictures and generates a SWF slideshow from them. Supports motion estimation compression (h.263) for better compression of video sequences.
PNG2SWF Like JPEG2SWF, only for PNGs.
GIF2SWF Converts GIFs to SWF. Also able to handle animated gifs.
Here is what I did :
Install the as3 compiler (mxmlc)
Run the command mxmlc.exe sample.as3 using NativeProcess