AS3 AIR mobile urlloader progress bar - actionscript-3

I have an app (for iOS and Android) which has the ability for users to select an image from the cameraroll or take an image using the cameraui. After selecting the image it is then uploaded to a server using urlloader and urlrequestwrapper class. This all works great but I need to display a percentage uploaded progress text/bar to the user but having real trouble finding a solution.
Thanks

Listen ProgressEvent.PROGRESS:
var loader = new URLLoader();
loader.addEventListener(ProgressEvent.PROGRESS,progressHandler);
function progressHandler(e:ProgressEvent):void {
trace(e.bytesLoaded/e.bytesTotal);
}
But notice, that your server has to support dispatching progress event for flash. Read the same problem here link

Related

StageWebView Flash's White when Displayed

StageWebView Flash's White when Displayed
So I've been working on a project using Adobe Animate to create a universal Air application that can be ported to multiple platforms i.e. Mac, Windows, and iOS.
It uses StageWebView to display videos embedded on HTML pages that have their own custom html5 video player and everything works well except for one simple but annoying thing.
Whenever I display a Stage Web View you'll see a flash of white before the page displays.
Now I originally thought this was an issue with checking for a URL load completion or a poorly formatted HTML document but that doesn't seem to be the case.
What I did notice after several attempts of trying to remove the issue is that it did go away if I used the embedded Air WebKit opposed to using the native WebKit from the desktop device.
(Code Below) Causes white flash on load:
var webView:StageWebView = new StageWebView(true);
(Code Below) This gets rid of the issue but my HTML tags like video and progress are not supported by the embedded WebKit and no longer function properly.
var webView:StageWebView = new StageWebView();
Information from about the setting from Adobe:
useNative:Boolean (default = false) — When useNative is false, a version of WebKit embedded within AIR is used as the source of the
StageWebView created. When useNative is true, then AIR will use the
the system's default web engine. Mobile platforms only support using
the system web engine, so useNative is ignored on mobile platforms.
The frustrating thing is that I've set a listener to check for load completion and that doesn't get rid of the issue. So as a workaround I've hidden the displayed StageWebView off the screen and then moved it's location to where I want it to be after a delay which is not great.
Other attempts to display it small as a pixel resize it in place cause the issue still.
/* Check for Stage Web View Errors */
webView.addEventListener(ErrorEvent.ERROR, onError);
function onError(e:ErrorEvent):void {
trace("Stage Web View error: " + e);
}
/* Function to not show Stage Web View until loaded. */
function onCompleteHandler(e:Event):void {
webView.assignFocus();
// Delay the Stage Web View to fix white flash issue.
setTimeout(callWebView,500);
webView.removeEventListener(Event.COMPLETE,onCompleteHandler);
}
/* Multi-Function Stage Web View Loader, Just add file path string to call */
function webviewFilePath(path:String):void {
webView.stage = this.stage;
// Prep filepath
filePath = new File(new File(path).nativePath).url;
// Load file path
webView.loadURL(filePath);
// Add listener for Complete URL Load then Show
webView.addEventListener(Event.COMPLETE,onCompleteHandler);
}
/* Function to call Stage Web View independantly so it can be delayed with a timer */
function callWebView() {
webView.viewPort = new Rectangle(posX(viewX), posY(viewY), viewWidth, viewHeight);
}
Any hints or tips on how I can alleviate or fix the issue would be great.
Of course if Adobe just actually updated the embedded Air WebKit that would probably fix the whole issue in the first place but I doubt that's happening anytime soon.
Partial Fix
So the issue still exists when I initially load up the Stage Web View but I've managed to minimize its appearance during app use.
One major part of the issue was how I reset the StageWebView in preparation for a new page I wanted to load or when I wanted to close the view.
I went a little overboard on resetting StageWebView because audio in StageWebView has been known to continue playing even when it's hidden.
/* Function to Reset Stage Web View */
function resetWebView():void {
webView.loadString("<!DOCTYPE HTML><html><body></body></html>");
//webView.viewPort = new Rectangle(0, 0, 0, 0);
webView.stage = null;
//webView.viewPort = null;
}
I realized I could just simply hide the StageWebView and load up a blank page while it was hidden from view to stop any audio playing. That was easy enough to accomplish with a simple string loaded into it.
Although from time to time I'll still see that white flash it's occurrence is minimal.
private var webView : StageWebView;
webView = new StageWebView( true );
webView.stage = this.stage;
webView.viewPort = new Rectangle( 0, 0, 1024, 768 );

WP8 Play sound when application is onbackground

Developing tools : Visual Studio 2012, target wp platform : wp8.
I am facing the above problem:
When my application is running on background and i am receiving a notification i vibrate the phone successful and i want to play a specific sound.
What i have tried so far:
Player = new MediaElement();
Player.AutoPlay = true;
Player.Volume = 5;
Player.Source = new Uri("/data/alert.mp3", UriKind.RelativeOrAbsolute);
Player.MediaOpened += (Object s, RoutedEventArgs args) =>
{
Player.Play();
};
I i am not getting any exception but no sound. Neither on foreground nor background .
Am i missing something?
I will appreciate any help.
You can't use the MediaElement API to play notification sounds when the app is in background. In order to launch a notification and play a custom sound, you need to use the ShellToast and use the Sound property via reflection.
Here is how play a custom notification sound from background (MSDN link) Using custom sounds in toasts on Windows Phone 8 Update 3
EDIT: When the app is running in foreground, you can use the same technique (ShellToast with Sound).
Even MediaPlayer class can help you play songs and media in the background when you are showing a toast or a small pop up dialog.
Check here : http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.mediaplayer.play.aspx

Capture video without sound in Windows Store App

I want to write a Windows Store App that can capture video (without any sound) and take pictures. Imagine a digital camera: you can preview the picture on the screen of your device before pushing the button which takes the pic.
The problem I'm facing now is the fact that the Windows.Media.Capture namespace has only classes for objects that capture video with sound (CameraCaptureUI, MediaCapture). I'm not troubled by the objects' capabilities, but by the fact that I will have to include in the manifest of the app the Microphone capability and it does not make sense for the app to use it. I need a class that uses only the Webcam capability.
Any ideas?
I found the answer and I thought I should share it. I'm sorry for answering my own question, but here goes:
One can specify in the settings of the MediaCapture object, when initializing it, that it will use only the Video part:
var mediaCaptureMgr = new MediaCapture();
var captureSettings = new MediaCaptureInitializationSettings();
captureSettings.StreamingCaptureMode = StreamingCaptureMode.Video;
await mediaCaptureMgr.InitializeAsync(captureSettings);
RTFM!

AS3 AIR in app loading screen

I was wondering if someone could share some thoughts about how best to implement an in app loading screen.
I am building a mobile app using Starling and Feathers UI for iOS and Android and some times when a menu item is clicked to go to a new page it takes a few seconds due to the components that are on the stage on the called page. I would like to display a generic 'loading...please wait' screen which will have a message and a loading spinner which will be shown every time a new page is requested.
Thanks
This is how it's actually done, while you're directing your user to the frame, you make the loader MovieClip visible, the loader movie clip is a simple animation, like this:
loader http://www.pockettorah.com/wp-content/app/images/loader.gif
Make a movieclip and in instance name name it loader, and animate it like above
At the top of your code, say loader.visible = false;
In your code, after gotoAndStop/gotoAndPlay or whatever, say loader.visible = true;
There is no real way of displaying this, usually it's just a fake animation that displays while the data is being processed.
Its called a splash screen, it can be a simple jpeg. Adobe help here

How to control mobile softkeys from Flash application embedded in HTML

I have a flash application running Flash 9 (CS3). Application is able to control the Softkeys when this flash application is loaded in the supported mobile device. But, the application doesn't have control when the same is embedded in HTML page and browsed via supported mobile device. Any ideas how to make this work?
Thanks
Keerthi
There is no special way to receive soft key events when embedded in HTML - if the browser/OS gives the events to Flash, then you can catch them like any other key event:
var myListener = new Object();
myListener.onKeyDown = function() {
var code = Key.getCode();
if (code==ExtendedKey.SOFT1) {
trace("I got a soft key event");
}
}
Key.addListener(myListener);
However, you'll find that most phones/browsers will not give you soft key events when your SWF is embedded in HTML. This isn't part of the Flash Lite spec - strictly speaking I believe they could give you those events if they wanted to, but most phones simply use those keys for browser functions, and consume them before they get to Flash.
Note that you can check at runtime whether or not softkeys are available:
trace(System.capabilities.hasMappableSoftKeys);
trace(System.capabilities.softKeyCount);
If you use a switch statement, you can have more than one keycode associated with an action, you make a desktop version for testing too. I have done it myself.