Why am I receiving a flash player security error when trying to access facebook graph api photos? - actionscript-3

I'm using the flash debug player(version 16) and I'm trying to access a users photo from within flash as3. Firstly, the Security error i'm receiving, here it is.
SecurityError: Error #2122: Security sandbox violation: Loader.content: http s://graffiti-galore.herokuapp.com/fb/GraffitiGalore.swf?build=0001 cannot access http s://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/c46.46.570.570/s50x50/398269_10152199084495525_2139734276_n.jpg?oh=29be37fd74f7d338a7b5c23b9aadd474&oe=5548F552&gda=1431395518_d142c304e8b8afa8df340e6cac093b29. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
at flash.display::Loader/get content()
at PictureBox/onCompleteLoadingImage()
I'm using the free Heroku dino that is being offered and I'm simply doing a fetch call to the graph api users object. fetching the id,first_name, last_name,picture.
The picture url comes back as hosted on https facebook servers.
https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/c46.46.570.570/s50x50/398269_10152199084495525_2139734276_n.jpg?oh=29be37fd74f7d338a7b5c23b9aadd474&oe=5548F552&gda=1431395518_d142c304e8b8afa8df340e6cac093b29
Links like the one above. For some reason i'm receiving this Security error whenever loading up the image from my flash as3 facebook app.
Below is the code i'm using to fetch the image.
[code]
public function setupPhoto(url:String):void
{
removeAllChildren();
var urlRequest1:URLRequest = new URLRequest(url);
this.loader1 = new Loader();
this.loader1.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteLoadingImage);
this.loader1.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onErrorLoadingImage);
this.loader1.load(urlRequest1);
//imageLoader = new ImageLoader(url);
//imageLoader.addEventListener(Event.COMPLETE, onCompleteLoadingImage);
//imageLoader.load();
}
private function onErrorLoadingImage(e:IOErrorEvent):void
{
debugPanel.writeLine("ERROR LOADING IMAGE!!!");
debugPanel.writeLine(e.text);
}
public function onCompleteLoadingImage(e:Event):void
{
//var sprite:Sprite = this.loader1.content as Sprite;
//updatePicture(sprite);
updatePicture1(this.loader1.content);
}
[/code]

this works for me with Facebook:
var lc:LoaderContext = new LoaderContext(true, null, null);
// now add the LoaderContext to your loader
this.loader1.load(urlRequest1, lc);
you don't have to create a LoaderContext every time, just create it once and use everywhere.

Related

Actionscript(AIR) Cant return FB access_token from HTMLLoader

Im simply trying to get my users access token from FB using HTMLLoader. When i trace the output from the location change event all i get are Google/FB urls, none of which have the token.
Here is my code:
var loader:HTMLLoader;
function onChange(e:Event):void {
if(loader.location.indexOf("#") != -1) {
trace("Found token");
}else {
trace(loader.location);
}
}
function connectFb() {
loader = new HTMLLoader();
loader.addEventListener(Event.LOCATION_CHANGE, onChange);
loader.width = 640;
loader.height = 480;
loader.load(new URLRequest("https://graph.facebook.com/oauth/authorize?
client_id=1234567890123456&redirect_uri=http://google.com&type=user_agent"));
}
My Codes output:
https://graph.facebook.com/oauth/authorize?client_id=164534120383085&redirect_uri=http://google.com&type=user_agent
http://www.google.com/
I tried every tutorial on the net and even bought a book on AS3 facebook dev & still cant figure this out; Any help would be VERY appreciated since this is a fairly important project to me
From what I understand, you're trying to retrieve an oauth access token from the facebook API, right? That's what you're expecting to get back from that URL? Correct me if I'm wrong, but HTMLLoader is for (unsurprisingly) loading HTML content. If you're expecting HTML content (ie, an 'authorize' page from FB), then you need to add the HTMLLoader to the display list with:
addChild(loader); // where 'loader' is an instance of HTMLLoader
On the other hand, if you were expecting just the token (and not HTML content), then you should be using URLLoader, and not HTMLLoader.

AS3 ahow to control the pause button of the external swf

I just trying to control buttons of external loaded swf .
var swfRequest:URLRequest = new URLRequest('http://mysite.com/player/001.swf');
var swfLoader:Loader = new Loader();
swfLoader.load(swfRequest);
var holder:MovieClip = new MovieClip();
holder.addChild(swfLoader);
addChild(holder);
And in main swf I created new button with Instance Name : pauseBtn , I want this button communicate to external swf witch has pause button with Instance Name : pausebtn in action script 2.0
external btn:
on (release)
{
status_playing = false;
playbtn._visible = true;
pausebtn._visible = false;
stop ();
}
Please help me how to communicate with these buttons.
Normally, I don't think you can directly communicate between AS3 content and AS2 content. One way around it is using a LocalConnection object to handle the communication between the two.
How it would work after creating the objects and connecting them, is the main swf would send a message to it's LocalConnection object and the loaded swf would receive that message on and use it to handle whatever you need it to.
LocalConnection - AS3 Reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/LocalConnection.html
LocalConnection - AS2 Reference: http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001176.html#312868

AS3 using the loader CLASS with .content

I've been working on a program, but currently I'm stuck.
My problem is the .content statement in my script. Since I'm loading a PNG from the web I have the Local playback security set to "Access network only". When I load pictures locally (of course with settings at "Access local files only", and local URLRequests) the program works just fine, but when loading from the web the .content makes my program stop, I've found this out with lots of testing. It seems the .content only works when the SWF file only uses local requests, is this correct?
I know that I can use addChild(loader), but I need to get the PNG file out of the loader so that I can turn it into a bitmap and edit it. Any ideas? The script is below.
var loader:Loader = new Loader;
var ar:Array = [];
var teller:Number = 0;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, paste);
knapp.addEventListener(MouseEvent.CLICK, neste);
function paste(evt) {
ar[teller] = loader.content;
ar[teller].x = ar[teller].width*teller;
addChild(ar[teller]);
}
function neste(evt) {
teller ++
loader.load( new URLRequest ("http://www.minecraft.net/skin/Notch.png"));
}
loader.load( new URLRequest ("http://www.minecraft.net/skin/Notch.png"));
Cross-domain policies prohibits image data manipulation for images loaded from another domain than the one the swf file is loaded from:
http://www.dwuser.com/flashslideshow/v4/help/advanced_topics/understanding_flash_player_cross_domain_loading_restrictions.html

Connect to IP in application layer, Adobe Air

I'm working on a project about "controlling embedded system by smartphones via wifi",
I developed my app on adobe Air, and built my system on PIC microcontroller to accept connections on application layer (Http), the ip address is 192.168.20.60:80(responsed when browsing from web browsers).
Instead of using sockets to connect through port 80, I used urlloader to read HTML pages (urlrequest("x.com")).
But when I tried to connect to ip address IOexception appears,
here's the code:
var PicPage:URLLoader=new URLLoader();
PicPage.load(new URLRequest("192.168.20.60")); //worked using DNS
lgn.addEventListener(Event.COMPLETE,ff);
function ff(e:Event):void{
var s:String=e.target.data;
trace(s);
}
As Pixel Elephant said, You need to have http:// in front of the IP you are trying to contact. You don't need to specify port 80 though.
Try the following code:
var PicPage:URLLoader = new URLLoader();
PicPage.addEventListener(Event.COMPLETE, onLoaded);
PicPage.addEventListener(IOErrorEvent.IO_ERROR, onError);
PicPage.load(new URLRequest("http://192.168.20.60/"));
protected function onLoaded(e:Event):void {
var s:String = e.target.data;
trace(s)
}
protected function onError(e:Event):void {
// Handle the error in any way you'd like
}
I've used this code ( and variations of it ) multiple times myself and it has served me well.

record video using flash media server 4.5

Hello i am trying to capture my camera as an flv file with fms 4.5 i am doing the following:
protected function rec_clickHandler(event:MouseEvent):void
{
nc = new NetConnection();
nc.client = { onBWDone: function():void{ trace("onBWDone") } };
nc.connect("rtmp://localhost/vod");
nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
}
private function netStatusHandler(e:NetStatusEvent):void {
var code:String = e.info.code;
if(code == "NetConnection.Connect.Success"){ //in case of recording...
ns = new NetStream(nc);
ns.attachCamera(cam);
ns.attachAudio(mic);
ns.publish("filename","record");
}
else{
trace(code);
}
}
but i get the following error:
Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Record.NoAccess
Can anyone help? what am i doing wrong?
This status message, NetStream.Record.NoAccess, generally indicates that you don't have write permissions to the stream. Check the permissions of your streams dir to see if it is read only.
If that is not the issue, check which application are you trying to publish to, does not SSAS that has code to deny write access to stream
Make sure the previously recorded video is not being opened in any video player. If it is being accessed by some other program, it will not allow you to record or rewrite it.