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"));;
Related
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
I am trying to load multiple swf files. But the problem is that whenever I load them (back and forth; vice-versa), my file keeps on slowing down. I looked a solution from the internet, such as using "unload" and "removeChild" but I can't get a clear solution and I don't know where to put it. Any help is very much appreciated..Here's my code on how I load my swfs:
MainMenu.swf:
//***************CLICK GALLERY*********************//
Gallery_btn.addEventListener(MouseEvent.CLICK, Gallery);
function Gallery(event:MouseEvent):void{
var ldr1:Loader=new Loader();
ldr1.load(new URLRequest("Gallery.swf"));
addChild(ldr1);
}
Gallery.swf:
//***************CLICK QUIT******************//
Quit_btn.addEventListener(MouseEvent.CLICK, Quit);
function Quit(event:MouseEvent):void{
var ldr1:Loader=new Loader();
ldr1.load(new URLRequest("MainMenu.swf"));
addChild(ldr1);
}
You need to use removeChild and remove every listener. You can unload swf by calling unload on your loader or unloadAndStop.
You can read this article for more information.
UnloadAndStop from Adobe
Unload SWF
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);
hai i want play two swf files in my action script project.In this two files one swf file works on the detection face in front of the system.Other swf plays the flv file.when face is detected player must be stooped if not player must be plays the flv file.
I know how to load the swf file but i cant handle the functionality regarding starting and stoping player.
the snippet of code shows how can i load external swf file .and i will explain each line of code in comments
public function videos(view:Sprite)
{
this.box = view;//IT GETS Sprite object from other class because of need to display the player also.
request = new URLRequest("Untitled-1.swf");
currentSWF=new MovieClip();
loader= new Loader();
loader.load(request);
box.addChild(loader);
currentSWF = MovieClip(loader.content);
loader.addEventListener(Event.COMPLETE,loadComplete);
//addChild(loader);
currentSWF.gotoAndPlay(1);//when i put this line of code in comments it plays the external swf also.
}
I hope u understand my doubt .can any one explain how to handle my things .i am new to this action script.please help me
Loaded files automatically play, unless you tell them explicitely not to. You’ll have to listen to the Event.INIT event, and stop the movie there:
loader.AddEventListener(Event.INIT, initLoader);
function initLoader (event:Event)
{
MovieClip(event.currentTarget.content).stop();
}
This will stop the movie before it is attached to the stage, and before it starts playing—so it won’t do that unless you start it again.
Note that you shouldn’t access loader.content in any way before the INIT or COMPLETE events, as it’s very likely that the content isn’t loaded then. As such you should put all your manipulating actions into the COMPLETE event:
box.addChild(loader);
loader.addEventListener(Event.COMPLETE, loadComplete);
function loadComplete (event:Event)
{
// Now it’s safe to access the `content` member:
currentSWF = MovieClip(loader.content);
// Of course this one would play the movie again, so you probably want
// to call that later on a button click or something.
currentSWF.gotoAndPlay(1);
}
I'm making a website for a client where they purchased a flash template that was written in "AS 1.0 & AS 2.0" and then asked me to add a googlemap to the contact us page. However, the googlemap API only works in AS3. My options were to translate the entire website to AS3 OR to make an AS3 file that imported the AS2 website and then added the googlemap bit.
I decided to go with option 2 since it seemed easier...
Anyway, I'm using the Loader class in the AS3 file.
var myLoader:Loader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("main_v8.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
addChild(myLoader);
The problem is the AS2 swf file uses XML to load the background images. It works on its own but when loaded into the AS3 file the background images do not appear. All the buttons and external links work, its just the loading of the XML.
I've been looking all over for help on this and while there are lots of people with issues playing AS2 swf in AS3 I couldn't find anything to help with this.
Any advise or solutions would be appreciated!
Thanks!
Havent face such a problem but, if you find out the problem you ca solve it. You can check some conditions:
check network for , does xml loaded. (might be crossdomain problem)
check if images loaded. ( as3 security problem)
check as2 file really inits. ( you can use as3 bridge to as2)