Linking to an external swf file problem
I have one flash presentation which contains a movie clip
button with all three events (onRelease, onRollOut and onRollOver)
which links to a video which is contained in another swf. The
button appears to be temperamental with the onRelease event. It
will work sometimes and only when the browser is opened before
hand. If its not the browser just opens with a blank screen. Both
swfs are in the same directory and the onRelease event.
I have tried IE and firefox.
Any ideas are appreciated.
p.s The AS uses a getURL syntax
Hi,
I'm the author of the article you pointed out. I'm sincerely
sorry that you found the solution code difficult to understand.
As kglad suggests, the problem is based on how Firefox
handles the url that Flash Player gives to it. (Although you're
using a relative url, behind the scenes Flash Player turns it into
an absolute url, one that starts with "file:///c|/..." or something
like that. (Firefox chokes on the pipe "|" character, even though
it shouldn't.) The workaround code in my article just constructs an
absolute url for you (using a colon ":" in place of the pipe
character, as in "file:///c:/..."). When you pass the absolute url
to the getURL() function, Flash Player passes it along to the
browser unmodified, so Firefox gets it with a colon and doesn't
choke.
I hope that helps make things clearer.
-Paul
H. Paul Robertson
ActionScript Developer/Writer
Platform Developer Documentation
Adobe Systems, Inc.
http://probertson.com/
Similar Messages
-
External SWF file load problem
I'm loading external SWF file which has motion tween.After
the loading progress bar finished to load than calls SWF file.If I
test the movie locally works fine but when simulate the download it
seems it jumps end of the timeline.Is anyone could tell me why is
this??
Thanksk, never mind..... finally figured it all out.
-
Loading external swf files in a swf - Error#1009
I have been having trouble using a swf file within a swf file. The external swf files all work as expected. However when used within another swf file I get the standard TypeError #1009 for some of my swfs. The external swf files are mainly actionscript 3 files. A typical swf file will have an object (or objects) in the library which has an export for ActionScipt property enabled and an addEventListener(Event.ENTERFRAME, somefunction). About four years ago when I had to do some work with AS2 I seemed to get around a similar issue with the _lockroot method but this is no longer part of AS3. I have searched various forums and note that I am not the only one with this issue but did not find any relevant solutions. If anyone could give me any ideas on how to get around this it would be appreciated.
Regards
NormanHi,
I have added a download to rapidshare and its link is:
Download link: http://rapidshare.com/files/380202712/ExtSwfs.zip
The main file Training01.fla has been set up with links to download several swf's. The links that do not work properly are those labelled : Module6 and Module 8. The first Module 6 connects to a function that is a variation of how I was trying to load external swfs using Application Domain, while Module 8 is a link to a swf that uses and external class. Module 8 is supposed to load with rotating stars, while Module 6 loads the same file as the link called Module 1. As soon as I use the two links Module 6 or Module 8 the whole lot ceases to work properly. I did also follow through the examples on the Adobe site. The examples for Module 6 and Module 8 are tutorials I have used from the Internet as part of my training from the site FlashMyMind.com but they replicate the type of work we have been doing with respect to using ActionScript3.
Re my background, at this stage I am self-taught using tutorials on the web and whatever books I can lay my hands on here. There is no structured training available where I live as there is insufficient demand and no books available on Flash or ActionScript at the local book stores or libraries so the books are ones I have ordered via the Internet. The one I am currently using apart from Adobe Classroom in a Book Flash CS4 is O'Reilly's Learning ActionScript 3.0 a Beginners Guide.
The other problem I have been trying to solve and still researching is why one loses sound in the flash player when playing flv files, if the user has selected or restarted a video (or videos) many times eg 25 to 30 times as we create video training files and serve them to the user within the flash environment using Flash Player 9 and IE6.
Regards
Norman -
Loading external swf file in a new window
Hi,
I've got a few .swf files with video tutorials I've created using Captivate 4.
I wanted to link them so I've created a main screen with menu with buttons in Flash.
I've added AS to load the external swf files but they load in the same window. How can I load these .swf files in seperate window so that you could get back to the main window after you've finished watching?
Here's my code:
stop();
var myLoader:Loader = new Loader();
button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
function movie1_1(e:MouseEvent):void
var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
myLoader.load(myURL);
addChild(myLoader);
I'm also attaching screenshot with menu in flashI've deleted the line and now the code lookes like that:
stop();
var myLoader:Loader = new Loader();
button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
function movie1_1(e:MouseEvent):void
var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
addChild(myLoader);
Unfortunately, it doesn't load the .swf file when you click on the button... -
Unloading external swf file keeps memory usage growing up
Hello everybody,
The idea is very simple: I have a submain.swf with 5 buttons. Each button loads an external .swf file.
com_loader.load(URLRequest);
After playing first external swf, before I go to next one, I try to unload it:
1. remove all its associated listeners:
com_loader.contentLoaderInfo.removeEventListener(Event.INIT-PROGRESS-COMPLETE, idFunction);
2. unload it:
com_loader.unload();
3. set to null:
com_loader = null;
and load next external swf file and so on.
The problem is that the FireFox/IE8.0 Memory Usage in Task Manager is going up and I see no sign of GC activity even after 5 mins of playing. Can anyone light me up pls? This is the second week working around and no good news until now.
Thanks in advance.
P.S.
If I try com_loader.unloadAndStop(); it gives me the error: Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.
Vince.Hi Ice,
The loaded swf file contains only a small photo, just for testing, with no listeners or other stuff in it.
Vic. -
Hi,
Does somebody knows what is happening?
I'm using the mcLoader class to load all my external swf
files, everything worket perfectly until I decided to use
flvPlayBack on one of those external files. If the player is on my
main stage it works great and if I run directly the loaded swf it
also works, but now when i run the external swf through the
mcLoader the player doesn't appears.
my mcLoader code:
var mcLoader01:MovieClipLoader = new MovieClipLoader();
mcLoader01.loadClip("clientes/targetTrade.swf",mcConatiner);
The flvPlayer should be on the second frame of this
targetTrade.swf ("click to watch the video")
thanks,
PeterHi,
You said swfs are Flash 8. Did you also set them to
Actionscript 2? If it's
Actionscript 3, that may be the problem. You may be
interested in looking at the
Flash Video templates I have at:
http://www.deansdirectortutorials.com/FlashVideo/
regards
Dean
Director Next Roadmap Survey
http://www.deansdirectortutorials.com/survey/DirectorRoadmap/
Director Lecturer / Consultant / Director Enthusiast
http://www.deansdirectortutorials.com/
http://www.multimediacreative.com.au
email: [email protected] -
I have loaded an external swf file which plays a flv file by default as swf is loaded. Now the problem is how do i remove the swf file from memory. my code :
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("ExternalSWF.swf");
myLoader.load(url);
detailMovieClip.movieHolder.addChild(myLoader);
I have tried many combinations of removeChild, unload and unloadAndStop but none works. I figure its all about not referencing correctly.Hi Jah,
i understood your problem,i faced this problem many time but couldn't find correct solution.
I'm using now Event.REMOVED_FROM_STAGE. this method dispatch to parent swf for when the External swf removed from stage.
The sample example code below for the way of remove externalswf events:
parent swf actionscript code:
import flash.events.MouseEvent;
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("ExternalSWF.swf");
myLoader.load(url);
b_mc.addChild(myLoader);
a_mc.addEventListener(MouseEvent.CLICK,onClick);
function onClick(event:MouseEvent):void
a_mc.removeEventListener(MouseEvent.CLICK,onClick);
myLoader.unload();
b_mc.removeChild(myLoader);
myLoader=null;
ExternalSWF.swf actionscript code:
import flash.events.Event;
var num:Number=0;
addEventListener(Event.ENTER_FRAME,onRun);
addEventListener(Event.REMOVED_FROM_STAGE,onRemoveFromParent);
// remove all local events here//
function onRemoveFromParent(event:Event):void
trace("remove");
removeEventListener(Event.ENTER_FRAME,onRun);
function onRun(event:Event):void
num++;
trace(num);
Thanks/ -
External swf file not using URLRequest
Good morning guys.
You can load an external swf file not using URLRequest? Since embed html code is setted as <param value="never" name="allowscriptaccess"/>
I have this problem and I need to load a swf skin
thank youare you loading a swf (done during runtime) or importing one (done during authortime)?
in either case, the allowscriptaccess parameter of the external swf (that your loading or importing) is irrelevant. allowscriptaccess is assigned in the main (loading or importing) swf's embedding html page and is used to control html/js access of the main and loaded swfs.
if you trust the swf you're loading, you can change allowscriptacess to always. if you're importing a swf, none of its actionscript will execute anyway so it doesn't matter whether its trusted or not. -
Hi all,
I am trying to load an external SWF file into my website.. but it is not working. Here is my code
public var CD:Loader=new Loader();
protected function application1_creationCompleteHandler(event:FlexEvent):void
CD.load(new URLRequest("http://localhost/assets/slide.swf"));
addChild(this.CD);
CD.x=2;
CD.y=170;
// TODO Auto-generated method stub
Can anyone tell me what is going wrong..
The url is correct and its working in my browser when i type 'http://localhost/assets/slide.swf' in the browser... So problem is with flex..I am pretty sure that Flash's security measures prevents the coder from loading swfs that are not local to the swf that is trying to load them. So the swf that is trying to load another swf would have to be on the same system or same networked server. From what I have experienced its best to reference the location of the files from the swf that is doing the loading. I am not sure if you are still referencing your swf as "http://localhost/assets/slide.swf" but that might be a problem as well.
so
mainfolder
movie.swf
assets
slide.swf
so in movie.swf
//Start: Put in desired function
var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
swfLoader.load(new URLRequest("assets/slide.swf"));
//End
Also add this function
public function loadComplete(e:Event):void
stage.addChild(e.target.content);
This might help explain it
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html
the first set of bullet points highlight the security options
ps. I got this working on my end, copy and pasted the code, of course i had to recreate the file system structure and slide.swf -
How can I stop timeline sounds in external swf files from playing during loading?
I am having a problem with timeline sounds in external swf files playing during loading in a main swf. Can anyone help me?
Here is some of the code from the main swf. I hope I have included enough.
Thanks.
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.net.URLRequest;
import fl.events.SliderEvent;
import flash.media.SoundTransform;
preloader_mc.fill_mc.scaleX = 0;
var swfA:Array = ["part1.swf","part2.swf"];
var frameA:Array = [];
var currentLoader:Loader;
var swfTotalFrames:int;
var tl:MovieClip = this;
var st:SoundTransform = new SoundTransform()
var index:int = 0;
loadNextF();
play_slider.enabled = false;
function loadNextF():void{
tl["loader_"+index] = new Loader();
tl["loader_"+index].name = index.toString();
tl["loader_"+index].contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressF);
tl["loader_"+index].contentLoaderInfo.addEventListener(Event.COMPLETE,completeF);
tl["loader_"+index].load(new URLRequest(swfA[index]));
function progressF(e:ProgressEvent):void{
var fractionLoaded:Number = index/swfA.length+e.bytesLoaded/(e.bytesTotal*swfA.length);
preloader_mc.fill_mc.scaleX = fractionLoaded;
preloader_mc.tf.text = (100*fractionLoaded)+"% Loaded";
function completeF(e:Event):void{
tl["loader_"+index].contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,progress F);
tl["loader_"+index].contentLoaderInfo.removeEventListener(Event.COMPLETE,completeF);
SoundMixer.stopAll();
var mc:MovieClip = MovieClip(tl["loader_"+index].content);
mc.gotoAndStop(1);
frameA.push(mc.totalFrames);
index++;
if(index<swfA.length){
loadNextF();
} else {
// all loads complete. start play.
restart_mc.buttonMode = true;
restart_mc.alpha = 1;
tl.addEventListener(Event.ENTER_FRAME,playUpdateF);
tl.removeChild(preloader_mc);
preloader_mc = null;
play_slider.enabled = true;
playpause_mc.alpha = 1;
currentLoader = tl["loader_0"];
tl.addChild(currentLoader);
MovieClip(currentLoader.content).play();
sliderParamsF();import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.net.URLRequest;
import fl.events.SliderEvent;
import flash.media.SoundTransform;
preloader_mc.fill_mc.scaleX = 0;
var swfA:Array = ["part1.swf","part2.swf"];
var frameA:Array = [];
var currentLoader:Loader;
var swfTotalFrames:int;
var tl:MovieClip = this;
var st:SoundTransform = new SoundTransform()
var index:int = 0;
loadNextF();
play_slider.enabled = false;
function loadNextF():void{
tl["loader_"+index] = new Loader();
tl["loader_"+index].name = index.toString();
tl["loader_"+index].contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressF);
tl["loader_"+index].contentLoaderInfo.addEventListener(Event.COMPLETE,completeF);
tl["loader_"+index].load(new URLRequest(swfA[index]));
function progressF(e:ProgressEvent):void{
var fractionLoaded:Number = index/swfA.length+e.bytesLoaded/(e.bytesTotal*swfA.length);
preloader_mc.fill_mc.scaleX = fractionLoaded;
preloader_mc.tf.text = (100*fractionLoaded)+"% Loaded";
function completeF(e:Event):void{
tl["loader_"+index].contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,progress F);
tl["loader_"+index].contentLoaderInfo.removeEventListener(Event.COMPLETE,completeF);
SoundMixer.stopAll();
var mc:MovieClip = MovieClip(tl["loader_"+index].content);
mc.gotoAndStop(1);
frameA.push(mc.totalFrames);
index++;
if(index<swfA.length){
loadNextF();
} else {
// all loads complete. start play.
restart_mc.buttonMode = true;
restart_mc.alpha = 1;
tl.addEventListener(Event.ENTER_FRAME,playUpdateF);
tl.removeChild(preloader_mc);
preloader_mc = null;
play_slider.enabled = true;
playpause_mc.alpha = 1;
currentLoader = tl["loader_0"];
tl.addChild(currentLoader);
MovieClip(currentLoader.content).play();
sliderParamsF();
///////////////// start sliders /////////////////////////////////
sound_slider.addEventListener(SliderEvent.CHANGE,soundSliderF);
function soundSliderF(e:SliderEvent):void{
st.volume = e.value/100;
tl.soundTransform = st;
play_slider.addEventListener(SliderEvent.CHANGE,playSliderF);
play_slider.addEventListener(MouseEvent.MOUSE_DOWN,playSliderDownF);
//play_slider.addEventListener(MouseEvent.MOUSE_UP,playSliderUpF);
function playSliderDownF(e:MouseEvent):void{
tl.removeEventListener(Event.ENTER_FRAME,playUpdateF);
stage.addEventListener(MouseEvent.MOUSE_UP,playSliderUpF);
function playSliderUpF(e:MouseEvent):void{
tl.addEventListener(Event.ENTER_FRAME,playUpdateF);
function playSliderF(e:SliderEvent):void{
SoundMixer.stopAll();
var frameNum:int = Math.ceil(swfTotalFrames*e.value/100);
var partialTotalFrames:int = 0;
for(var i:int=0;i<frameA.length;i++){
partialTotalFrames += frameA[i];
if(partialTotalFrames>=frameNum){
break;
partialTotalFrames -= frameA[i];
//trace(i,frameNum,frameNum-partialTotalFrames);
if(currentLoader!=tl["loader_"+(i)]){
tl.removeChild(currentLoader);
MovieClip(currentLoader.content).stop();
currentLoader = tl["loader_"+(i)];
tl.addChild(currentLoader);
if(playpause_mc.currentFrame==1){
MovieClip(currentLoader.content).gotoAndPlay(frameNum-partialTotalFrames);
} else {
MovieClip(currentLoader.content).gotoAndStop(frameNum-partialTotalFrames);
function sliderUpdateF(e:Event):void{
var playedFrames:int = 0;
for(var i:int=0;i<Number(currentLoader.name);i++){
playedFrames += frameA[i];
playedFrames += MovieClip(currentLoader.content).currentFrame;
play_slider.value = Math.round(100*playedFrames/swfTotalFrames);
function sliderParamsF():void{
swfTotalFrames = 0;
for(var i:int=0;i<swfA.length;i++){
swfTotalFrames += MovieClip(tl["loader_"+i].content).totalFrames;
///////////////// end sliders //////////////////////////////////
///////////////// start playpause restart ///////////////////////
playpause_mc.addEventListener(MouseEvent.CLICK,playpauseF);
playpause_mc.alpha = .2;
restart_mc.addEventListener(MouseEvent.CLICK,restartF);
restart_mc.buttonMode = false;
restart_mc.alpha = .2;
function playpauseF(e:MouseEvent):void{
if(!e.currentTarget.toggle){
MovieClip(currentLoader.content).stop();
tl.removeEventListener(Event.ENTER_FRAME,playUpdateF);
e.currentTarget.gotoAndStop(2);
} else {
MovieClip(currentLoader.content).play();
tl.addEventListener(Event.ENTER_FRAME,playUpdateF);
e.currentTarget.gotoAndStop(1);
e.currentTarget.toggle = !e.currentTarget.toggle;
///////////////// end playpause //////////////////////////////
function playUpdateF(e:Event):void{
sliderUpdateF(e);
var playingFrame:int = MovieClip(currentLoader.content).currentFrame;
if(playingFrame==frameA[Number(currentLoader.name)]){
// next loader
MovieClip(currentLoader.content).stop();
SoundMixer.stopAll();
MovieClip(currentLoader.content).mute();
var nextIndex:int = Number(currentLoader.name)+1;
if(nextIndex<swfA.length){
tl.removeChild(currentLoader);
currentLoader = tl["loader_"+nextIndex];
tl.addChild(currentLoader);
MovieClip(currentLoader.content).gotoAndPlay(1);
} else {
tl.removeEventListener(Event.ENTER_FRAME,playUpdateF);
playpause_mc.gotoAndStop(2);
playpause_mc.toggle = !playpause_mc.toggle;
//playpause_mc.alpha = .2;
// all swfs have completed play
function restartF(e:MouseEvent):void{
MovieClip(currentLoader.content).stop();
tl.removeChild(currentLoader);
SoundMixer.stopAll();
MovieClip(currentLoader.content).mute();
currentLoader = tl["loader_"+0];
tl.addChild(currentLoader);
if(playpause_mc.currentFrame==1){
MovieClip(currentLoader.content).gotoAndPlay(1);
} else {
MovieClip(currentLoader.content).gotoAndStop(1); -
How to load and unload more than one external swf files in different frames?
I do not have much experience on Adobe Flash or Action Script 3, but I know the basics.
I am Arabic language teacher, and I design an application to teach Arabic, I just would like to learn how to load and unload more than one external swf files in different frames.
ThanksLook into using the Loader class to load the swf files. If you want to have it happen in different frames then you can put the code into the different frames.
-
FAQ: How do I load an external SWF file into a parent SWF file?
A ton of Flash users visit Adobe’s we site every month wondering about how to load an external SWF file from within another SWF.
Adobe's own TechNote on the subject attempts to answer the basic question, along with some common follow-up questions, including:
How do I load more than one SWF?
How do I load a SWF into a specific location in the display list?
How do I resize the loaded SWF?
How do I set its X and Y location?
Here are some additional resources that elaborate on loading content and on working with the display list:
Sample files for the above TechNote. A set of 3 FLA and 3 corresponding SWF files, including a parent SWF and 2 SWFs that the parent loads.
Help > AS3 Developer’s Guide > Loading an external SWF file
Help > AS3 Developer’s Guide > Loading display content dynamically
Loading multiple external SWFs within a main SWF – CreativeCow.net forums
Video tutorial: ActionScript 101 – Episode 6: Adding named objects to the Stage. By Doug Winnie. An example of how to add the loaded external asset to the Stage and modify its location or other properties.
Video tutorial: Preloading in ActionScript 3.0. By Lee Brimelow. A slightly more complicated example, showing how to make the parent SWF display information about the progress of loading the external SWF.
Tutorial: Loading and unloading SWFs - FlashAndMath.com
This article provides several examples of how to communicate between a parent SWF file and the loaded SWF:
SWF to SWF Communcation via ActionScript 3.0 (by kglad)quote:
Originally posted by:
NedWebs
You now seem to want to get rid of the swf once it has loaded
and played itself thru. To do that you would need to have something
in the swf itself that triggers its removal in its last frame. The
following might work...
MovieClip(this.parent).removeChild(this);
Unfortunately I couldn't get this to work. I placed it on the
last frame of the SWF to be called - is that right?
I am not sure I am doing it correctly... -
How do I find the width of an external swf file that I am loading in
I have loaded in an external swf file and it works fine.
However, when I get the width dimensions of the movieclip that is housing the external swf file it gives me a '0' for the width.
Thanks for your time.you must wait until loading is complete before trying to access the loaded objects width. at that point you can determine the width,height of the onstage/backstage objects in frame 1 of the loaded swf.
-
I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the main flash file and load a new swf file, while at the same time removing garbage collection from memory?
This is the error message(s) I am receiving: "TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at index_fla::MainTimeline/Down3()"
import nl.demonsters.debugger.MonsterDebugger;
var d:MonsterDebugger=new MonsterDebugger(this);
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);
// loader is the loader for portfolio page swf
var loader:Loader;
var loader2:Loader;
var loader3:Loader;
var loader1:Loader;
// resize content
function resizeHandler(event:Event):void {
// resizes portfolio page to center
loader.x = (stage.stageWidth - loader.width) * .5;
loader.y = (stage.stageHeight - loader.height) * .5;
// resizes about page to center
loader3.x = (stage.stageWidth - 482) * .5 - 260;
loader3.y = (stage.stageHeight - 492) * .5 - 140;
/*loader2.x = (stage.stageWidth - 658.65) * .5;
loader2.y = (stage.stageHeight - 551.45) * .5;*/
addEventListener(Event.ENTER_FRAME, onEnterFrame,false, 0, true);
function onEnterFrame(ev:Event):void {
var requesterb:URLRequest=new URLRequest("carouselLoader.swf");
loader = null;
loader = new Loader();
loader.name ="carousel1"
//adds gallery.swf to stage at begining of movie
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader.load(requesterb);
} catch (error:SecurityError) {
trace(error);
addChild(loader);
loader.x = (stage.stageWidth - 739) * .5;
loader.y = (stage.stageHeight - 500) * .5;
// stop gallery.swf from duplication over and over again on enter frame
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
//PORTFOLIO BUTTON
//adds eventlistner so that gallery.swf can be loaded
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
function Down(event:MouseEvent):void {
// re adds listener for contact.swf and about.swf
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
//unloads gallery.swf from enter frame if users presses portfolio button in nav
var requester:URLRequest=new URLRequest("carouselLoader.swf");
loader = null;
loader = new Loader();
loader.name ="carousel"
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader);
loader.x = (stage.stageWidth - 739) * .5;
loader.y = (stage.stageHeight - 500) * .5;
removeChild( getChildByName("about") );
removeChild( getChildByName("carousel1") );
// remove eventlistner and prevents duplication of gallery.swf
MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
//INFORMATION BUTTON
//adds eventlistner so that info.swf can be loaded
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
function Down1(event:MouseEvent):void {
//this re-adds the EventListener for portfolio so that end user can view again if they wish.
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
var requester:URLRequest=new URLRequest("contactLoader.swf");
loader2 = null;
loader2 = new Loader();
loader2.name ="contact"
loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader2.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader2);
loader2.x = (stage.stageWidth - 658.65) * .5;
loader2.y = (stage.stageHeight - 551.45) * .5;
// remove eventlistner and prevents duplication of info.swf
MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
//ABOUT BUTTON
//adds eventlistner so that info.swf can be loaded
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
function Down3(event:MouseEvent):void {
//this re-adds the EventListener for portfolio so that end user can view again if they wish.
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
var requester:URLRequest=new URLRequest("aboutLoader.swf");
loader3 = null;
loader3 = new Loader();
loader3.name ="about"
loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader3.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader3);
loader3.x = (stage.stageWidth - 482) * .5 - 260;
loader3.y = (stage.stageHeight - 492) * .5 - 140;
removeChild( getChildByName("carousel") );
removeChild( getChildByName("carousel1") );
// remove eventlistner and prevents duplication of info.swf
MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
stop();Andrei1,
Thank you for the helpful advice. I made the changes as you suggested but I am receiving a #1009 error message even though my site is working the way I wan it to work. I would still like to fix the errors so that my site runs and error free. This is the error I am receiving:
"TypeError: Error #1009: Cannot access a property or method of a null object reference."
I'm sure this is not the best method to unload loaders and I am guessing this is why I am receiving the following error message.
loader.unload();
loader2.unload();
loader3.unload();
I also tried creating a function to unload the loader but received the same error message and my portfolio swf was not showing at all.
function killLoad():void{
try { loader.close(); loader2.close; loader3.close;} catch (e:*) {}
loader.unload(); loader2.unload(); loader3.unload();
I have a question regarding suggestion you made to set Mouse Event to "null". What does this do setting the MouseEvent do exactly? Also, since I've set the MouseEvent to null do I also have to set the loader to null? e.g.
---- Here is my updated code ----
// variable for external loaders
var loader:Loader;
var loader1:Loader;
var loader2:Loader;
var loader3:Loader;
// makes borders resize with browser size
function resizeHandler(event:Event):void {
// resizes portfolio page to center
loader.x = (stage.stageWidth - loader.width) * .5;
loader.y = (stage.stageHeight - loader.height) * .5;
// resizes about page to center
loader3.x = (stage.stageWidth - 482) * .5 - 260;
loader3.y = (stage.stageHeight - 492) * .5 - 140;
//adds gallery.swf to stage at begining of moviie
Down();
//PORTFOLIO BUTTON
//adds eventlistner so that gallery.swf can be loaded
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
function Down(event:MouseEvent = null):void {
// re adds listener for contact.swf and about.swf
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
//unloads gallery.swf from enter frame if users presses portfolio button in nav
var requester:URLRequest=new URLRequest("carouselLoader.swf");
loader = new Loader();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader.load(requester);
} catch (error:SecurityError) {
trace(error);
this.addChild(loader);
loader.x = (stage.stageWidth - 739) * .5;
loader.y = (stage.stageHeight - 500) * .5;
// sure this is not the best way to do this - but it is unload external swfs
loader.unload();
loader2.unload();
loader3.unload();
// remove eventlistner and prevents duplication of gallery.swf
MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
//INFORMATION BUTTON
//adds eventlistner so that info.swf can be loaded
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
function Down1(event:MouseEvent = null):void {
//this re-adds the EventListener for portfolio so that end user can view again if they wish.
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
var requester:URLRequest=new URLRequest("contactLoader.swf");
loader2 = null;
loader2 = new Loader();
loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader2.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader2);
loader2.x = (stage.stageWidth - 658.65) * .5;
loader2.y = (stage.stageHeight - 551.45) * .5;
loader.unload();
loader2.unload();
loader3.unload();
// remove eventlistner and prevents duplication of info.swf
MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
//ABOUT BUTTON
//adds eventlistner so that info.swf can be loaded
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
function Down3(event:MouseEvent = null):void {
//this re-adds the EventListener for portfolio so that end user can view again if they wish.
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
var requester:URLRequest=new URLRequest("aboutLoader.swf");
loader3 = null;
loader3 = new Loader();
loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader3.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader3);
loader3.x = (stage.stageWidth - 482) * .5 - 260;
loader3.y = (stage.stageHeight - 492) * .5 - 140;
loader.unload();
loader2.unload();
loader3.unload();
// remove eventlistner and prevents duplication of info.swf
MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
stop(); -
How to load External swf file in AIR
I try this code its working in computer but when I publish this file in .apk or .ipa , my external swf file is not opening
(I include my external file as well)
places_btn.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
function newvid(event:MouseEvent) {
trace("you clicked me");
var loadit = new Loader();
addChild(loadit);
loadit.load(new URLRequest("scene02.swf"));thx boss its working great
I have 3 scenes; load scene code is working great
1. How can I unload the scene?
2. Can I unload all scenes or one by one?
can I unload some think like this
Load scene 2 , unload scene 1 and scene 3
Load scene 3, unload other all scene
i try this
load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
function newvid(event:MouseEvent) {
trace("you clicked me");
var loadit = new Loader();
addChild(loadit);
var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
loadit.load(new URLRequest("scene02.swf"), _lc);
loadit.unload();
load3.addEventListener(MouseEvent.MOUSE_DOWN, newvid1);
function newvid1(event:MouseEvent) {
trace("you clicked me");
var loadit = new Loader();
addChild(loadit);
var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
loadit.load(new URLRequest("scene03.swf"), _lc);
loadit.unload("scene01.swf scene02.swf");
Maybe you are looking for
-
Portal eventing: hiding iView?
Hi all, I've made 2 portal components: a search iView and a result iView. When I enter searchcriteria in the search iView and click the search button, the result iView shows me the results (via EPCM event). Now, I'm wondering if it's possible to hide
-
Can i create a file in Mobile Device?
Hello Guyz, I need a small help over here..I need to know wheather i can create or is there any provision to create a file or a folder using J2ME tool kit in a mobile device... The file is of small capacity only.. Thank You Regds, Gokul
-
Get Product Type from Product Category
Hello, I need to get Product Type (Material or Service) from Product Category. Does anyone knows the Function Module which can be used. Warm regards, Girish
-
When I tried to import a video on Iphoto (Which I've done many times) It is saying: iPhoto cannot import your photos because there was a problem downloading an image. And I emptied the trash on my dock, and in Iphoto. Any Help?
-
Hi, I have the following problem. I have to create a new BOM with some positions. If the BOM already exists the function module should check if in the itab is a new position and add this, all other positions that allready exist in the BOM should be i