Adobe Flash AS3 FLVPlayback metadata - actionscript-3

Trying to adapt this example given here
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00002413.html
Getting Error
1046: Type was not found or was not a compile time constant void.
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.metadataReceived = function(eventObject:Object):Void {
trace("canSeekToEnd is " + rmys01.metadata.canSeekToEnd);
trace("Number of cue points is " + rmys01.metadata.cuePoints.length);
trace("Frame rate is " + rmys01.metadata.framerate);
trace("Height is " + rmys01.metadata.height);
trace("Width is " + rmys01.metadata.width);
trace("Duration is " + rmys01.metadata.duration + " seconds");
};
rmys01.addEventListener("metadataReceived", listenerObject);
rmys01.contentPath = "rhym01.flv";
var vidsiz:TextField = new TextField();
vidsiz.text = "Video Size " + (rmys01.metadata.width) + " by " + (rmys01.metadata.height);
vidsiz.width = 550;
vidsiz.height = 700;
vidsiz.x = 450;
vidsiz.y = 300;
addChild(vidsiz);
im trying the read the actual Dimension of the flv video file.

In the example it's written as a comment in the beginning:
/**
Requires:
- FLVPlayback component on the Stage with an instance name of my_FLVPlybk
*/
I assume you are missing this and you don't have the component on stage with instance name 'rmys01', as I don't see you declaring it anywhere. Otherwise looks fine.

import mx.video.*;
So, do you work on AS3 project or AS2?
For AS3 project you should adapt this Tutorial.

Related

upload video to facebook from air android app

i am attempting (for some time now) to upload a video to Facebook from an air for android app. i have recorded the video on the device, saved it to the device and have the path to the video stored in a string. i was advised to convert the video to byteArray and pass that into the FacebookMobile.uploadVideo method of the as3 Facebook api which i attempted to do but am getting a 353 You must select a video file to upload. error (from Facebook i presume).
file to byteArray
public function UICompleteHandler(event:MediaEvent):void
{
trace("Welcome back from the camera");
var media:MediaPromise = event.data;
trace("file info "+media.file.url + " - " + media.relativePath + " - " + media.mediaType);
filePath = media.file.url;
trace("Object encoding is: " + inBytes.objectEncoding + "\n\n" + "order file: \n\n");
readFileIntoByteArray(filePath, inBytes);
trace("length 1: "+inBytes.length);
trace("position 1: "+inBytes.position);
inBytes.position = 0; // reset position to beginning
inBytes.uncompress(CompressionAlgorithm.DEFLATE);
trace("position 2: "+inBytes.position);
inBytes.position = 0; //reset position to beginning
}
private function readFileIntoByteArray(fileName:String, data:ByteArray):void
{
var inFile:File = new File(fileName);
trace ("file to byte array "+ inFile.url);
trace ("file name var : "+fileName);
inStream.open(inFile , FileMode.READ);
inStream.readBytes(data);
inStream.close();
}
Upload to Facebook(attempt)
public function handleUpload(ev:TouchEvent)
{
trace ("posting to facebook - FileName: "+ accessCamera.fileName + " - FilePath: " + accessCamera.filePath);
var params:Object ={
title:'test upload on FB api',
description:'test upload on FB api',
fileName: accessCamera.fileName,
video: accessCamera.inBytes
}
//trace ("params.video = "+params.video);
FacebookMobile.uploadVideo('me/videos', onComplete, params);
}
private function onComplete( result:Object, fail:Object ):void
{
trace("facebook post onComplete called" );
if (result)
{
//result.id is id of post that was just posted
trace ("great");
}
else if (fail)
{
trace("post Failed");
trace('code: '+fail.error.code);
trace('message: '+fail.error.message);
trace('type: '+fail.error.type);
}
}
when i uncomment the trace params.video i get a huge amount of random characters which i thought to be the data of the byteArray
any guidance or help from anyone would be appreciated

as3 converting video to byteArray

i am attempting to upload a video to facebook using the as3 api(FacebookMobile.uploadVideo) which accepts a video as either fieleReferance or byteArray. a followed the example # http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7d54.html for creating the byteArray i ma getting a 2058 error when uncompressing the byte array (this may be because i dident compress it but neither did adobe in the example).
if i comment this bit out i am getting an #353 You must select a video file to upload error from Facebook.
Byte Array Code:
public function UICompleteHandler(event:MediaEvent):void
{
trace("Welcome back from the camera");
var media:MediaPromise = event.data;
trace("file info "+media.file.url + " - " + media.relativePath + " - " + media.mediaType);
filePath = media.file.url;
trace("Object encoding is: " + inBytes.objectEncoding + "\n\n" + "order file: \n\n");
readFileIntoByteArray(filePath, inBytes);
trace("length 1: "+inBytes.length);
trace("position 1: "+inBytes.position);
inBytes.position = 0; // reset position to beginning
//inBytes.uncompress(CompressionAlgorithm.DEFLATE);
trace("position 2: "+inBytes.position);
inBytes.position = 0; //reset position to beginning
}
private function readFileIntoByteArray(fileName:String, data:ByteArray):void
{
var inFile:File = new File(fileName);
trace ("file to byte array "+ inFile.url);
trace ("file name var : "+fileName);
inStream.open(inFile , FileMode.READ);
inStream.readBytes(data);
inStream.close();
}
Handle Upload Code:
public function handleUpload(ev:TouchEvent)
{
trace ("posting to facebook - FileName: "+ accessCamera.fileName + " - FilePath: " + accessCamera.filePath);
var params:Object ={
title:'test upload on FB api',
description:'test upload on FB api',
fileName: accessCamera.fileName,
video: accessCamera.inBytes
}
trace ("params.video = "+params.video);
FacebookMobile.uploadVideo('me/videos', onComplete, params);
}
private function onComplete( result:Object, fail:Object ):void {
trace("facebook post onComplete called" );
if (result)
{
//result.id is id of post that was just posted
trace ("great");
}
else if (fail)
{
trace("post Failed");
trace('code: '+fail.error.code);
trace('message: '+fail.error.message);
trace('type: '+fail.error.type);
}
}
when i trace out the params.video i get a load of random characters. the problem seems to be facebook dosnt appear to see the bytearray(if i even success fully created it) as a video.

AS3 AIR - black screen when packaged

When I run the application from Flash Develop everything is fine, both in Debug and Release.
After the application is packaged and installed, I just get a black screen when run.
However if I add a 'debug' file to applicationDirecty\META-INF\AIR\debug the application runs normally.
What could be causing this? and how can it be solved?
A debugging utility seemed to be causing the problem in the release build... removing calls to this solved the issue.
/** Gets the name of the function which is calling */
public function Log(prefix:String = "", suffix:String = "", params:* = null):void
{
var error:Error = new Error();
var stackTrace:String = error.getStackTrace(); // entire stack trace
var startIndex:int = stackTrace.indexOf("at ", stackTrace.indexOf("at ") + 1); //start of second line
var endIndex:int = stackTrace.indexOf("()", startIndex); // end of function name
var lastLine:String = stackTrace.substring(startIndex + 3, endIndex);
var functionSeperatorIndex:int = lastLine.indexOf('/');
var ClassSeperatorIndex:int = lastLine.indexOf(':');
var objectName:String = lastLine.substring(ClassSeperatorIndex+2, functionSeperatorIndex);
var functionName:String = lastLine.substring(functionSeperatorIndex + 1, lastLine.length);
trace(prefix +" " + "[" + objectName + "]" + " > " + functionName + " " + suffix);
}
Open Run.bat and replace
set OPTIONS=-connect %DEBUG_IP%
with
set DEBUG_IP=%DEBUG_IP%

Problems Displaying Profile Picture in Flash swf

I followed this tutorial Loading Facebook Profile Picture Into Flash SWF Using Graph API to get the users profile picture to show in my flash game, but I'm having some issues.
import com.facebook.graph.Facebook;
import com.facebook.graph.data.FacebookSession;
import com.facebook.graph.net.FacebookRequest;
import flash.events.Event;
import flash.events.IOErrorEvent;
//place your APP ID here
const APP_ID:String = "app_id";
//Initialize facebbok library
Facebook.init(APP_ID, HandleLogin);
function HandleLogin(response:Object, fail:Object):void
{
if(Facebook.getSession().accessToken)
{
LoadMyInfo();
LoadMyPicture();
}
}
function LoadMyInfo():void
{
Facebook.api("/me", MyInfoLoaded);
}
function MyInfoLoaded(response:Object, fail:Object):void
{
nameTextField.text = response.name;
}
function LoadMyPicture():void
{
debug.text = "Entered loadMyPicture() function ";
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, MyPictureLoaded, false, 0, true);
var request:URLRequest = new URLRequest("facebookProxy.php");
var variables:URLVariables = new URLVariables();
variables.path = Facebook.getImageUrl(String(Facebook.getSession().uid), 'large');
debug.appendText(" \nvariables.path: " + String(variables.path));
request.data = variables;
debug.appendText(" \nrequest.data: " + String(request.data))
loader.load(request);
debug.appendText(" \n" + String(loader.load(request)));
}
function MyPictureLoaded(event:Event):void
{
debug.appendText(" \nEntering MyPictureLoaded");
var loader:Loader = event.target.loader;
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, MyPictureLoaded);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, MyPictureLoadError);
var bitmap = Bitmap(loader.content);
bitmap.smoothing = true;
//Note: picturePlaceholder is just a blank movie clip on the Stage
bitmap.x = picturePlaceHolder.x;
bitmap.y = picturePlaceHolder.y;
bitmap.width = picturePlaceHolder.width;
bitmap.height = picturePlaceHolder.height;
picturePlaceHolder.addChild(bitmap);
debug.appendText(" \nBitmap is null: " + String(bitmap == null) +
" \nBitmap X: " + String(bitmap.x) + " Bitmap Y: " + String(bitmap.y) +
" \nBitmap width: " + String(bitmap.width) +
" \nBitmap height: " + String(bitmap.height))
}
function MyPictureLoadError(e:IOErrorEvent):void
{
debug.appendText("Loading Error");
}
This is what my code looks like after following the tutorials on the link above. With the debug I noticed that the function MyPictureLoaded is never called.
They never specified where I would call the function LoadMyPicture. I assumed it would go together with LoadMyInfo so I placed it there. They have a working example but no source code, so I'm hope someone here would shed some light on this.
EDIT 1
Here is what it looks like when I put it up on facebook. The last line debug.appendText(" \n" + String(loader.load(request))); is outputting undefined. I also made a change in the variables.path = Facebook.getImageUrl(String(Facebook.getSession().uid), 'large'); I added (String(), 'large') because in the docs it saying to pass strings into there. Edit: I realized adding String() is pointless.
var request:URLRequest = new URLRequest("facebookProxy.php");
Did you do the part of the tutorial that writes a server-side PHP proxy loader on your server?
If you don't have a file named facebookProxy.php on your server where you run this it won't work (the code is requesting "./facebookProxy.php" which probably doesn't exist). If you want to run this in the debugger on your local machine, you will need to make that file in the same directory as your swf and make sure you have apache/php running on your localhost.
If that's too much work for you, I would suggest following some of the examples from the API' project page: http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Examples_1_6.zip&can=2&q=

ActionScript 3.0 add border to movie clipe

I had created the script below but the cordinate is not working right. please see my scripts and let me know what is wrong with my scripts.
thanks
/*mcc is the Instance name*/
var myMovieClip:Sprite = new Sprite();
trace("x" + mcc.x + "y" + mcc.y + "width" + mcc.width);
myMovieClip.graphics.lineStyle( 1, 0xFF0000 );
myMovieClip.graphics.drawRect( 0, 0, mcc.width+1, mcc.height+1 );
myMovieClip.graphics.endFill();
myMovieClip.x = -(mcc.x/2);
myMovieClip.y = -(mcc.y/2);
mcc.addChild(myMovieClip);
would need to know more about mcc looks like we're assuming that mcc has the content centered instead of the top right corner of mcc being at [0,0]
Try using the getBounds method instead.
something like this... though I haven't tested it
var bounds:Rectangle = mcc.getBounds(this)
myMovieClip.graphics.drawRect(
bounds.left-border/2, bounds.top-border/2,
bounds.width+border, bounds.height+border
);
myMovieClip.x = (mcc.x);
myMovieClip.y = (mcc.y);
mcc.addChild(myMovieClip);
thank you, it is working now, i used the getBounds and set the myMovieClip.x = (0); . It doesn't make sense but it works good now.
Anyway, the mcc could be anything, event rotate angle too.
var border=1;
var myMovieClip:Sprite = new Sprite();
myMovieClip.graphics.lineStyle( border, 0xFF0000 );
trace("getbound on mcc" + mcc.getBounds(mcc));
trace("parser" + mcc.getBounds(mcc).y)
trace("getbound on this" + mcc.getBounds(this));
trace("Other x " + mcc.x + " y " + mcc.y + " width " + mcc.width+ " height " + mcc.height);
var bounds =mcc.getBounds(mcc)
myMovieClip.graphics.drawRect(bounds.left-border/2, bounds.top/2,bounds.width+border, bounds.height+border);
myMovieClip.graphics.endFill();
myMovieClip.x = (0);
myMovieClip.y = (bounds.y)/2;
mcc.addChild(myMovieClip);
trace("New bound" + mcc.getBounds(mcc));