Actionscript - How to import swf with an html wrapper to timeline? - actionscript-3

Afternoon,
I have a multiple choice quiz generated by a third party software which can export the quiz as an swf file.
The swf file comes with an html wrapper.(index.html)
It also creates a data folder that has a javascript file. No fla file is given.
My problem is...I'm working with flash cc to create a navigation menu so you click a button a video plays..then at the end of video you click and you take the quiz.
I am able to have the video stop and assign a click to it...What do i need to do to have the button call the swf file(when imported by itself comes up blank) or the index.html so the quiz will show up inside the timeline of the fla that i am working with?
I'm making a free training DVD for my students.

You can use the class Loader:
var loader:Loader = new Loader();
var url:URLRequest = new URLRequest("file.swf");
var loaderContext:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain, null);
loader.load(url, loaderContext);
When it's finished load, you can use it in you own actionscript file

Related

AddChild to use external SWF has disabled my buttons I had on original Flash file

I have a Flash file (a website header with 5 buttons for 5 links to webpages).
On my actions layer, I added an external SWF file using the addChild object.
Note that I have very basic knowledge of ActionScript and I had to take some help from Google to setup above script.
The external SWF I have brought in using adChild code is working as an overlay on top of my original flash animation but all the buttons I have on original Flash file as website links have now become disabled. Even the mouseOver effects I applied to those 5 buttons are not responding. Below is my AS3 code:
import flash.net.navigateToURL;
import flash.net.URLRequest;
stop();
var swfRequest:URLRequest = new URLRequest("movie/txtOverlay.swf");
var swfLoader:Loader = new Loader();
swfLoader.load(swfRequest);
addChild(swfLoader);
button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.example.com/link1.asp"), "_self");
}
For the sake of brevity, I have placed just one button's code but you get the idea. Any solution to avoid this?
Thanks ... Syed

AS3 my external swf file is overlapping with main swf file

i am new to AS3, i have been trying to setup a simple simulation in AS3 for 2 months.
i have pafanbalance1.swf file which just navigate from one scene to other and at the last scene loads a swf file named fescue.swf . it gets loadded easily but pafanbalance1.swf keep on overlapping with the fescue.swf which obviously i want to avoid. please help.
here is link to my .fla file on data hosting site.
http://www.datafilehost.com/d/3396ad6f
please help
In Scene 5 add stop in the Actions frame.
stop();
// CREATE A NEW LOADER OBJECT TO HOLD THE LOADED CONTENT
var holder:Loader = new Loader();
addChild(holder);
holder.load(new URLRequest("fescue.swf"));;

Flash AS3 unload loaded SWF completely

how do i absolutely and completely unload a loaded SWF.
Here's the case. I have two different SWF, both have the same movieClips in the library with the same name and instance...but...both have different shape. So basically both are different but the names.
So i loaded the first.swf into the main.swf, in the first.swf contains button that order the loaded in the main.swf to unloadAndStop() and load the second.swf. But somehow the objects in the second.swf take the shape in the first.swf.
I hit the wall with this. How do i completely unload the first.swf
Thx guys
Try to load child swfs (first.swf and second.swf) into child application domains of the current application domain (Usage C in this Article Working with application domains, you can also find code sample from this article below). With this technique you'll get:
separate classes (all classes) of first.swf and second.swf from each other
unload all the class definitions for garbage collection after unloading swf
AS3 from the article:
var appDomainC:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
var contextC:LoaderContext = new LoaderContext(false, appDomainC);
var loaderC:Loader = new Loader();
loaderC.load(new URLRequest("module3.swf"), contextC);

How do I add a preloader to my game using flashDevelop?

Hi I have made a tile based game using a tutorial from this site http://www.wildbunny.co.uk/blog/2011...m-game-part-1/ My game is complete but I want to add a preloader to it.
A little background for a hopefully better understanding.
FlashDevelop is where all of my as3 files and classes are and I can also test my game here and I works fine.
Flash CS6 is where I have only one scene "scene 1" with one frame on it, this frame has all of my tile based images ( movieClips ) and animations in squares, if I double click a movieClip ( for example "player" ) it will go inside and I have got lots of frames ( jumping, running etc ).
I can't test my game from here, It shows errors (scenes are NAN). I think that's normal not sure - maybe off topic anyway.
I have looked on the internet for a tutorial on preloaders suiting my situation but can't find any using flash with flashDevelop and AS3.
You create a brand new project "Actionscript 3 with preloader", FD will generate you a preloader class *.as file, and a main class file with a [frame] directive in it. Copy the preloader *.as file into your current project, copy the directive from new project's Main.as into your project's Main.as, change the package name if needed in both places (in preloader's getDefinitionByName() call and in the directive - fully qualified class names required), add whatever visuals you want to your preloader class, and you're set.
The directive in my case looked like this:
[Frame(factoryClass="Geologist.Preloader")]
The package is Geologist, and the startup() function of the preloader was like this:
private function startup():void
{
var mainClass:Class = getDefinitionByName("Geologist.Main") as Class;
var theStage:Stage = this.stage;
theStage.addChild(new mainClass() as DisplayObject);
theStage.removeChild(this);
}

loading new external swf to stage and definitely removing previous one

I have three movies:
1) main movie
2) external #1
3) external #2
When the main movie is opened it loads into new container "MovieClip" one of the external swf (depends on variable). in the main movie I have also a button that switch the external SWF to another. Each external have some sounds located on their keyframes. When I want to change the external with the "button" in main movie it loaded new external correctly but the old one is still below the new one and the old one still plays their sounds. How can I delete the previous SWF when I loading new one. remove or clear or mute the sounds of this external? Below is the code I'm creating all.
var ladujFilm:String = "external#x.swf"; // the name comes with amfPHP so it's dynamic
var movieLoad:URLRequest = new URLRequest(ladujFilm);
movieLoader.load(movieLoad);
movieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded_fn);
function movieLoaded_fn(event:Event):void {
addChildAt(movieLoader, 1);
movieLoader.x = 0;
movieLoader.y = 0;
}
the Loader class has the unloadAndStop method, you need to use it on the "old" loader.
docs
example
best regards