External swf loaded from link doesn't work in some browsers - actionscript-3

I'm developing a game that due to its extension needs to load external swf. This game is on some flash portals and loads these external swf from urlrequest and loader. Some browsers like Chrome or Opera are loading these external swf totally fine, but I'm having problems with Firefox (and I'm not totally sure if also with Microsoft Edge). ALL players that are running the game on Firefox can't load the external swf from the link (http address).
I have the "allowDomain" and "allowInsecureDomain" correctly added in both (main and external) swf files.
Which is the problem? Firefox security settings with external http addresses? Is there any way to solve it?
Any help will be appreciated!
Edit: this is the code I used:
//on the 1st frame of my main .fla
import flash.system.Security;
Security.allowDomain("*");
Security.allowInsecureDomain("*");
//on the frame I want to load the external file
var ldr:Loader = new Loader();
var bytesLoaded;
var bytesTotal;
var scene01:MovieClip;
var percentLoaded:Number = bytesLoaded/bytesTotal;
function progressListener (e:ProgressEvent):void{
trace("Downloaded " + e.bytesLoaded + " out of " + e.bytesTotal + " bytes");
percentLoaded = Math.round(percentLoaded * 100);
}
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadfile);
ldr.load(new URLRequest("http://img110.xooimage.com/files/e/7/e/external_file.swf"));
ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
function loadfile(e:Event):void {
scene01 = MovieClip(ldr.contentLoaderInfo.content);
ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadfile);
addChild(scene01);
scene01.gotoAndPlay(2);
}

Related

Unable to Load an external Swf

I am trying to learn Action Script (self study) and therefore I took a project for myself.So this question might be way too simple or idiotic. If it is i apologise.
The goal is simple. I have 2 swf to embed within my swf. when my swf will run, it will load 1st swf by default. when you click a button, it will load the second swf.you can return back to the first swf using a different button.
After researching I came up with the action script mentioned below. The buttons work and the 1st swf work. But the second swf does not load for some reason. No compilation error found (but got an output error "TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event#2e1785d9 to OpenEvent." but i think that is comming for the working swf because of the xml it is trying to load) . wondering why the second swf is not loading even though I used a similar code as the first and how to rectify it.
url to my swf : http://itnotes.in/RLC/swf/Radio/muses-1.2/radio-tv.swf
my fla file (flash cs6 as3) : itnotes.in/RLC/swf/Radio/muses-1.2/radio-tv.fla
Any help deeply appreciated
Security.allowDomain("avastarentertainment.com")
Security.allowDomain("itnotes.in")
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
var Xpos:Number = 110;
var Ypos:Number = 180;
var swf:MovieClip;
var loader:Loader=new Loader();
loader.load(new URLRequest('http://itnotes.in/RLC/swf/Radio/muses-1.2/muses.swf?url=http://listen.181fm.com:8002&lang=auto&codec=mp3&tracking=true&volume=65&autoplay=true&buffering=5&skin=http://itnotes.in/RLC/swf/Radio/muses-1.2/simple-gray/ffmp3-simple-gray.xml&title=Vishara%20Designs'));
loader.x=Xpos;
loader.y=Ypos;
addChild(loader);
/////////////////////////////////////////////////////////////////////////////
//Radio Function
radio.addEventListener(MouseEvent.CLICK, RadioBtnClick);
function RadioBtnClick(event:MouseEvent):void{
removeChild(loader);
SoundMixer.stopAll(); //stop all sounds...
loader.load(new URLRequest('http://itnotes.in/RLC/swf/Radio/muses-1.2/muses.swf?url=http://listen.181fm.com:8002&lang=auto&codec=mp3&tracking=true&volume=65&autoplay=true&buffering=5&skin=http://itnotes.in/RLC/swf/Radio/muses-1.2/simple-gray/ffmp3-simple-gray.xml&title=Vishara%20Designs'));
loader.x=Xpos;
loader.y=Ypos;
addChild(loader);
}
/////////////////////////////////////////////////////////////////////////////
//TV Function
tv.addEventListener(MouseEvent.CLICK, TvBtnClick);
function TvBtnClick(event:MouseEvent):void{
removeChild(loader);
SoundMixer.stopAll(); //stop all sounds...
loader.load(new URLRequest("http://avastarentertainment.com/avanced2avan/AVAncedPlayer_TX_DeSiRe_TGZ_MS_vww861102_181powerTop40_4_29_16rev11EpCc_SSER.swf"));
loader.x=Xpos;
loader.y=Ypos;
addChild(loader);
}
Your codes don't have any problems, test your project's output on your browser {in maximized window mode}.
Note:
The file
AVAncedPlayer_TX_DeSiRe_TGZ_MS_vww861102_181powerTop40_4_29_16rev11EpCc_SSER.swf
doesn't work in another domain. so it must load within http://avastarentertainment.com/
domain (another contents required for loading this file, which are accessible only on that domain {copyright} )

Adobe Flash: How to join several separate .swf files into one .exe file?

Noob ask:
I have many separate .swf files, they are like stairs..
for example:
menu.swf load scene1.swf
scene1.swf load scene2.swf
and so on...
There is a button in menu.swf to load scene1.swf and there is a button in scene1.swf to load scene2.swf and so on...
*every .swf file has it own code, I use Adobe Flash CS6 and Actionscript 3.0
I use loader to load those .swf file
var myLoader:Loader = new Loader();
var intro:URLRequest = new URLRequest("Intro.swf");
myLoader.load(intro);
addChild(myLoader);
My problem:
When I create project on menu.swf to menu.exe... press the button... it can't load any .swf file.. T-T"
so.. what should I do..?
here is sample of my project:
https://drive.google.com/folderview?id=0B7S5VF_EUl_dbEg1WmNCYVBfQTA&usp=sharing
*based on my project Little Red Riding Hood.swf is the main menu. It works fine when I run it with .swf
Edit:
This is my full code of the menu, perhaps anyone can help me out.. ^^
*this code works fine when I run it with .swf
btnRead.addEventListener(MouseEvent.CLICK, read);
btnPlay.addEventListener(MouseEvent.CLICK, read);
function read(event:MouseEvent):void {
var myScene1:Loader = new Loader();
var scene1:URLRequest = new URLRequest("scene1.swf");
myScene1.load(scene1);
addChild(myScene1);
}
btnAbout.addEventListener(MouseEvent.CLICK, about);
function about(event:MouseEvent):void {
gotoAndStop(4);
}
btnScene.addEventListener(MouseEvent.CLICK, scene);
btnScene1.addEventListener(MouseEvent.CLICK, scene);
function scene(event:MouseEvent):void {
gotoAndStop(5);
}
import flash.system.fscommand;
btnQuit.addEventListener(MouseEvent.MOUSE_DOWN, closeApp);
function closeApp(event:MouseEvent):void {
fscommand("quit");
}

Load External Swf From Link [As3]

I am trying to call a swf from a link in as3. I searched on internet and i used this code
var my_Loader:Loader = new Loader();
var my_url:URLRequest=new URLRequest("http://gurselgunacar.web44.net/flash/yalitimhesabi.swf");
my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
my_Loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
my_Loader.load(my_url);
function finishLoading(loadEvent:Event) {
addChild(loadEvent.currentTarget.content);
}
function errorHandler(errorEvent:Event):void {
trace("file missing");
}
as3 call link but i cant do anything in swf. In output flash give security error. And i tried crossdomain.xml thing and it didnt work :S
The file http://gurselgunacar.web44.net/crossdomain.xml does not exists. You should create one.
The Loader will always look for a crossdomain.xml file at the target server.
Humm. Try to add these Security things:
Security.allowDomain("*");
Security.loadPolicyFile("http://gurselgunacar.web44.net/crossdomain.xml");
And use this in the URLRequest:
var my_url:URLRequest=new URLRequest("http://gurselgunacar.web44.net/flash/yalitimhesabi.swf?" + new Date().getTime()); //this will avoid caching old swf.
I tested on a EXE projector and it seems to work.

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

ActionScript 3 External Interface callback is not working?

I would highly appreciate any help in getting this issue resolved. I have been at it for two days now and have not been able to resolve this issue. I am trying to call an AS3 function from JavaScript via ExternalInterface API which is simply not working at all. If I to call a JavaScript function form html loaded swf, it works beautifully.
I am following this tutorial:
http://www.viget.com/inspire/bi-directional-actionscript-javascript-communication/
I am using swfobject to load the swf into a div.
JavaScript code:
<script type="text/javascript">
swfobject.embedSWF("testRun.swf", "myContent", "550", "400", "9.0.0");
function getFlashMovie(movieName)
{
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function callFlash(flash)
{
//alert(flash);
getFlashMovie(flash).sendToFlash();
}
</script>
AS3 Code:
import flash.external.*;
import flash.events.*;
import flash.text.*;
JAVASCRIPT WILL CALL SENDTOFLASH WHICH THEN INVOKES THE INIT FUNCTION
ExternalInterface.addCallback("sendToFlash", init);
function init():void
{
var txt:TextField = txtField();
txt.appendText("LOOK AT ME!!!");
addChild(txt);
}
function txtField():TextField
{
var txt:TextField = new TextField();
txt.x = 25;
txt.y = 25;
txt.width = 200;
txt.height = 150;
txt.border = true;
txt.text = "INIT ";
return txt;
}
After hours and hours, I have managed to resolved the issue. There was nothing wrong with my code, the culprit was flash player security settings on my local machine. Instead of just adding the swf to my trusted sites with the flash play settings, I included the entire folder, and now it works like a charm.
This is how I changed the settings:
You can go about two ways of changing the settings:
1. when you open the html file, flash player global security box pops open
2. Open the html file, right click and select the 'Global Settings...' option from your context menu.
Once the setting panel is open, you will see four tabs:
Storage | Camer and Mic | Playback | Advanced
Go to 'Advanced' tab
Click on "Trusted Local Settings..."
Click on "Add..."
Click on "Add Folder..."
Locate the folder where you files such as the html and swf are.
Click on "Confirm"
Click on "Close"
And then close the Flash Player Global Settings panel
Now open your html file, if it is already opened then refresh your browser. It all should work now