Wednesday, October 27, 2010

Bitmap Smoothing with ActionScript 3

Bitmaps Actionscript 3

Controls whether or not the bitmap is smoothed when scaled. The above images were scaled at 300%. When you load an image using a loader and would like to increase the size of the image, use the smoothing property. If true, the bitmap is smoothed when scaled. If false, the bitmap is not smoothed when scaled.

The Code

import flash.display.Loader;
import flash.display.Bitmap;

var myPicLoader:Loader = new Loader();
myPicLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
myPicLoader.load(new URLRequest("http://www.theflashstudio.net/images/flashstudioSmooth.jpg"));

var myPicLoader2:Loader = new Loader();
myPicLoader2.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete2);
myPicLoader2.load(new URLRequest("http://www.theflashstudio.net/images/flashstudioSmooth.jpg"));

function onComplete(event:Event):void {
var bitmapImage:Bitmap = event.target.content;
bitmapImage.smoothing = true; // APPLY SMOOTHING
myPicLoader.x = 52; // X Placement
myPicLoader.y = 25; // Y Placement
myPicLoader.height = 200;
myPicLoader.width = 168;
addChild(myPicLoader);
}

function onComplete2(event:Event):void {
var bitmapImage2:Bitmap = event.target.content;
bitmapImage2.smoothing = false; // APPLY SMOOTHING
myPicLoader2.x = 307; // X Placement
myPicLoader2.y = 25; // Y Placement
myPicLoader2.height = 200;
myPicLoader2.width = 168;
addChild(myPicLoader2);
}

 

Using Video Smoothing Blog Post

Video Smoothing with ActionScript 3

Flash Video Actionscript 3

Originally posted on backroom.bostonproductions.com

Video Smoothing

Smoothing specifies whether the video should be smoothed (interpolated) when it is scaled. For smoothing to work, the player must be in high-quality mode. The default value is false (no smoothing).

When you use the Flash Only Full Screen and high quality publish setting with a low resolution video, the smoothing comes in handy.

video Settings

If you want to allow any zoom effects on the video, allow the user to resize it, or maybe create a low-res version for use on the web, you’ll need to enable smoothing on the video.

The NetStream Class

var video:Video = new Video();
var nc:NetConnection = new NetConnection();
var ns:NetStream;
//
//Call the function below
startVideo();
//
//This function adds the video elements
function startVideo(){
//Add the video to the stage
addChild(video);
//
//connect the netStream/netConnection with the video
nc.connect(null);
ns = new NetStream(nc);
ns.client = {onMetaData:ns_onMetaData, NetStatusEvent:ns_onPlayStatus};
video.attachNetStream(ns);
ns.play("http://yoursite.com/movie.flv");
//
//Start with video being smoothed
video.smoothing = true;
}
//
function ns_onMetaData(_data:Object){
//put stuff here if you want.
}
//
function ns_onPlayStatus(e:NetStatusEvent){
//put other stuff here if you want.
}
//
//See the difference between video being smoothed and not smoothed by
//pressing "s"
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKey);
function checkKey(e:KeyboardEvent):void{
if (e.keyCode == 83){
video.smoothing = !video.smoothing
}
}

The FLVPlayback class

Use the FLVPlayback component and set its parameters in the properties Inspector, then add the code:

function smoothVideo(){
var myVideo = FLVPlayback_Instance.getVideoPlayer(0);
myVideo.smoothing = true;
}

Tuesday, October 26, 2010

Using the Microphone with the Flash Player to View Activity Levels

Flash Player Actionscript 3 Images
  1. Choose a microphone
  2. Click the close button.
  3. Allow access to activate microphone

Use the Microphone class to capture audio from a microphone attached to a computer running Adobe AIR. Use the Microphone class to monitor the audio locally. Use the NetConnection and NetStream classes to transmit the audio to Flash Media Server. Flash Media Server can send the audio to other servers and broadcast it to other clients running Adobe AIR.

A system might not have a microphone or other sound input device attached to it. You can use the Microphone.names property or the Microphone.getMicrophone() method to check whether the user has a sound input device installed. If the user doesn't have a sound input device installed, the names array has a length of zero, and the getMicrophone() method returns a value of null.

Calling the Microphone.getMicrophone() method without a parameter returns the first sound input device discovered on the user's system.

The Sound Player

  1. Create a dynamic text field with instance the name of activity_txt
  2. Create a dynamic text field with instance the name of width_txt.
  3. Create a dynamic text field with instance the name of status_txt
  4. Draw a line with instance the name of line_mc.

The Code

import flash.media.Microphone;

var myMic:Microphone = Microphone.getMicrophone();
Security.showSettings(SecurityPanel.MICROPHONE);
myMic.setLoopBack(true);
myMic.setUseEchoSuppression(true);
myMic.addEventListener(StatusEvent.STATUS, this.onMicStatus);

function onMicStatus(event:StatusEvent):void
{
if (event.code == "Microphone.Unmuted")
{
status_txt.text = "Microphone access was allowed.";
}
else if (event.code == "Microphone.Muted")
{
status_txt.text = "Microphone access was denied.";
}
}

stage.addEventListener(Event.ENTER_FRAME, stage_EnterFrame);
function stage_EnterFrame(e:Event)
{
line_mc.width = myMic.activityLevel*5;
activity_txt.text = "Activity: " + String(myMic.activityLevel) + "%";
width_txt.text = "Line_mc Width: " + String(line_mc.width) + "px";
}

  1. Calling the Microphone.setUseEchoSuppression() method with a parameter value of true reduces, but does not completely eliminate, the risk that audio feedback will occur.
  2. The activity level is an integer (whole number) from 0 – 100 (no volume/full volume).
  3. Test the SWF and if you have a microphone you will see the levels on the bar and text fields change.

ActionScript 3.0 Language and Components Reference Using the Microphone class

Adobe Releases Air 2.5 with Smartphone, Tablet and Television Support

AIR Flash Builder ActionScript 3
Adobe Releases Air 2.5 with Smartphone, Tablet Support

"With the release of Air 2.5, more than three million Flash developers can now build a single game or application and easily deploy it across multiple application stores and devices," said David Wadhwani, Adobe's senior vice president of Creative and Interactive Solutions. "This is a huge step forward for developers looking to build rich, engaging applications but who have historically had to incur the cost of building them separately for each device and platform."

Adobe Air technology is supported on a range of devices, including smartphones and tablets which are running on platforms like iOS, Android and Blackberry, as well as PC-based operating systems like Windows, Macintosh and Linux.

Adobe AIR for Android

AIR developers will be able to upload AIR applications to the Android Market to be distributed for free or sold to users. These users will be able to download AIR applications just like any native Android application. If the AIR runtime is not already installed on the Android device, users will automatically be directed to download the AIR runtime from the Android Market. We are currently working with Android device OEMs to preinstall AIR to further improve the user experience.

Adobe AIR for TV

To make the optimizations in AIR 2.5 for TV available to developers, we added new APIs and enhanced others, including enhancements to the Keyboard APIs, the new StageVideo API, new Native Extension capabilities for hardware manufactures, and our new content protection solution called Flash Access 2.0. Flash Access enables content creators to deliver high value content right to the living room by having a protected delivery path from source to playback, including hardware security on the device using the device's hardware accelerated AES and RSA cores and secure key stores. By providing this high level of security, content creators and studios can have the comfort they need to delivery the highest-value Hollywood content directly over the Internet to a living room device.

With the introduction of AIR 2.5 for TV, Adobe is super excited to have Samsung as a launch partner, bringing the best platform for building rich content together with the largest TV and Blu-ray maker. Samsung is a leader in opening up the TV, starting with their Free the TV Developer Day in August 2010. Adobe has been working with Samsung throughout the year, porting and optimizing AIR for TV to run exceptionally well on their platform to allow developers to create best-in-breed applications. For developers to distribute their content, Samsung Apps is a platform that enables consumers to download and purchase applications on their TVs and Blu-ray players that come from many sources and use many technologies. Note that Samsung Apps is also connected to the Adobe InMarket service, which gives Flash and AIR developers a one-stop-shop to distribute their content to all the different platforms and devices that are enabled by Adobe AIR.

ADC article Optimizing Video and Content for Flash Platform on TV.

The impact of the new Air platform will be felt, especially as more and more devices begin to enable Flash. Already one of the top free apps on Android Market, Flash for Android brings rich Flash based content to mobile devices inside the browser.

New Adobe AIR Desktop Features

  1. CSS @font-face support
  2. CSS shadow support.
  3. StageWebView
  4. H.264 video hardware decoding for Windows.

Adobe Edge, a prototype for creating animation and transitions with HTML5

Adobe Fellow Mark Anders provides a sneak peek of a tool codenamed "Edge," a prototype of a tool for creating animation and transitions using the capabilities of HTML5.

Related Posts Plugin for WordPress, Blogger...