Help with load and unload swf file.
hello, just now i try, to load my file using the code snippet 'load and unload' i manage to load the next file succesfully but why my recent file still appear in the background? how do i make it gone?
When you load another SWF you're loading it 'inside' the current SWF but it appears that you want to replace the current SWF entirely with the new SWF, is that correct?
If so you should make what's usually known as a 'stub' or a loader. Make an empty project that merely acts as a loader. It should load your first SWF and when you press a button on that first SWF to load a second SWF, it should signal the 'stub' it's loaded inside to unload the first SWF and then load the second.
e.g. a stub.swf (just coding out of memory, not error checked, just to give a general idea):
// make a new loader to do all the loading of SWFs
var loader:Loader = new Loader();
// and display
addChild(loader);
// a function to load a SWF into the loader (replacing any existing SWF)
function loadSWF(path:String):void
// assure path is defined or do nothing
if (!path) return;
// load requested SWF
loader.load(new URLRequest(path));
// load initial SWF
loadSWF('/path/to/1.swf');
For your 1.swf to use the function, you're currently inside the .content property of a Loader so I believe you can just run a command like: Object(this.parent.parent).loadSWF('/path/to/2.swf');
This example obviously lacks any error checking or transitions but you can add those and season to taste.
Similar Messages
-
I am currently using AS2.
I create a button instance named "myBtn" and i want it to load external swf file call "test2.swf" while unload current swf file named "test1.swf" when pressed/release.
what done is i put following code under mybtn :
on(press)
unloadMovie("test1.swf");
loadMovie("test2.swf" , 1);
the outcome was that , the "test2.swf" was loaded successfully but the "test1.swf" fail to unload.
Any help is welcomeAS2.. Scope is your issue. When you are inside the function for onPress you are telling the button you pressed to unload test1.swf from inside that button (which it's not located in).
You're probably using the root timeline so I'll take a wager this will work:
on (press)
_root.loadMovie("test2.swf");
If you want to monitor progress in loading between them, that's a little more complex. -
Need to load and unload swf from single htm file
I need to load or unload swf file or we can say that i need load 3 project one by one in current window
mit,
So are you saying you need to have one swf file call a second file to play, then call a third to play...
Which Captivate version are you using?
Are the swf files all captivate published swf's?
Do you have access to Flash Professional and if so what version?
how are you running your file, is it scorm packaged or just html based?
I may be able to help with your issue, but need these details. -
Can we load and unload the files in the run time?
Can we load and unload the files in the run time?
For example there are four files named "test1.h & test1.c" and another set "test2.h & test2.c" (I attached them as attachment to this post).
test1.h contains code:
int variable; //variable declared as integer
test1.c contains code:
variable = 1; //variable assigned a value
test1.h contains code:
char *variable; //variable declared as string
test1.c contains code:
variable = "EXAMPLE"; //variable assigned a string
So here, in this case can I dynamically load / unload the first & second group of files so that the same variable name "variable" can be used both as integer and string? And if yes, how is that to be done?
Solved!
Go to Solution.
Attachments:
test.zip 1 KBWhat do you mean by "dynamically"?
If you want to have a variable that either is an int or a char in the same program run, I'm afraid your only option is to define it as a variant and assign from time to time the proper data type in the variant according to some condition. Next, every time you access the variable you must firstly check which data type is stored in it, next access it in the proper way.
If on the other hand your option or to have a run in which the variable is an int, next you stop the program and in a following run it is a char, you may have it by using some appropriade preprocessor clause:
#ifdef CHAR_TYPE
#include "test1.h"; // variable defined as a char
#else
#include "test2.h"; // variable defined as int
#endif
Next, every time you want to access the variable you must proceed in the same vay:
#ifdef CHAR_TYPE
variable = "string";
#else
variable = 1;
#endif
Does it worth the effort?
Additionally, keep in mind that this "dynamical" approach can work only in the IDE, where you can properly #define your CHAR_TYPE or not depending on your wishes: when you compile the program, it will have only one #include depending on the definition of the macro.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
Problem : Load PDF or similiar files( stored at operating system) into an oracle table using SQl*Loader .
and than Unload the files back from oracle tables to prevoius format.
I 've used SQL*LOADER .... " sqlldr " command as :
" sqlldr scott/[email protected] control=c:\sqlldr\control.ctl log=c:\any.txt "
Control file is written as :
LOAD DATA
INFILE 'c:\sqlldr\r_sqlldr.txt'
REPLACE
INTO table r_sqlldr
Fields terminated by ','
id sequence (max,1) ,
fname char(20),
data LOBFILE(fname) terminated by EOF )
It loads files ( Pdf, Image and more...) that are mentioned in file r_sqlldr.txt into oracle table r_sqlldr
Text file ( used as source ) is written as :
c:\kalam.pdf,
c:\CTSlogo1.bmp
c:\any1.txt
after this load ....i used UTL_FILE to unload data and write procedure like ...
CREATE OR REPLACE PROCEDURE R_UTL AS
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW(32767);
l_amount BINARY_INTEGER ;
l_pos INTEGER := 1;
l_blob BLOB;
l_blob_len INTEGER;
BEGIN
SELECT data
INTO l_blob
FROM r_sqlldr
where id= 1;
l_blob_len := DBMS_LOB.GETLENGTH(l_blob);
DBMS_OUTPUT.PUT_LINE('blob length : ' || l_blob_len);
IF (l_blob_len < 32767) THEN
l_amount :=l_blob_len;
ELSE
l_amount := 32767;
END IF;
DBMS_LOB.OPEN(l_blob, DBMS_LOB.LOB_READONLY);
l_file := UTL_FILE.FOPEN('DBDIR1','Kalam_out.pdf','w', 32767);
DBMS_OUTPUT.PUT_LINE('File opened');
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.READ (l_blob, l_amount, l_pos, l_buffer);
DBMS_OUTPUT.PUT_LINE('Blob read');
l_pos := l_pos + l_amount;
UTL_FILE.PUT_RAW(l_file, l_buffer, TRUE);
DBMS_OUTPUT.PUT_LINE('writing to file');
UTL_FILE.FFLUSH(l_file);
UTL_FILE.NEW_LINE(l_file);
END LOOP;
UTL_FILE.FFLUSH(l_file);
UTL_FILE.FCLOSE(l_file);
DBMS_OUTPUT.PUT_LINE('File closed');
DBMS_LOB.CLOSE(l_blob);
EXCEPTION
WHEN OTHERS THEN
IF UTL_FILE.IS_OPEN(l_file) THEN
UTL_FILE.FCLOSE(l_file);
END IF;
DBMS_OUTPUT.PUT_LINE('Its working at last');
END R_UTL;
This loads data from r_sqlldr table (BOLBS) to files on operating system ,,,
-> Same procedure with minor changes is used to unload other similar files like Images and text files.
In above example : Loading : 3 files 1) Kalam.pdf 2) CTSlogo1.bmp 3) any1.txt are loaded into oracle table r_sqlldr 's 3 rows respectively.
file names into fname column and corresponding data into data ( BLOB) column.
Unload : And than these files are loaded back into their previous format to operating system using UTL_FILE feature of oracle.
so PROBLEM IS : Actual capacity (size ) of these files is getting unloaded back but with quality decreased. And PDF file doesnt even view its data. means size is almot equal to source file but data are lost when i open it.....
and for images .... imgaes are getting loaded an unloaded but with colors changed ....
Also features ( like FFLUSH ) of Oracle 've been used but it never worked
ANY SUGGESTIONS OR aLTERNATE SOLUTION TO LOAD AND UNLOAD PDFs through Oracle ARE REQUESTED.
------------------------------------------------------------------------------------------------------------------------Thanks Justin ...for a quick response ...
well ... i am loading data into BLOB only and using SQL*Loader ...
I've never used dbms_lob.loadFromFile to do the loads ...
i 've opend a file on network and than used dbms_lob.read and
UTL_FILE.PUT_RAW to read and write data into target file.
actually ...my process is working fine with text files but not with PDF and IMAGES ...
and your doubt of ..."Is the data the proper length after reading it in?" ..m not getting wat r you asking ...but ... i think regarding data length ..there is no problem... except ... source PDF length is 90.4 kb ..and Target is 90.8 kb..
thats it...
So Request u to add some more help ......or should i provide some more details ?? -
Display/load and Unload SWF in flex
hi friends
i wnat to disply external SWF file into flex but without using SWFLOader(it's make lot's of problem) nad i also Embed that SWF
this is code
[Embed(source="1.swf")]
private var loadswf:Class;
private function load():void{
var symb:MovieClip = new loadswf() as MovieClip;
this.addChild(symb);
it's give me error....
TypeError: Error #1034: Type Coercion failed: cannot convert demos_loadswf@39ab3c1 to mx.core.IUIComponent.
please help to resolve this error or give me suggestion to simple Disply/Load and Unload Embed SWF file in flexthnx Flex harUI
i added UI componentes now my full code is like..
import mx.controls.Image;
import mx.controls.Alert;
[Embed(source = "1.swf")]
public var SWF:Class;
[Embed(source = "2.swf")]
public var SWF2:Class;
private var mc:MovieClip;
private var img:Image;
protected function checkBtn_clickHandler(event:MouseEvent):void
clear();
img = new Image();
img.width=Number("700");
img.height=Number("700");
mc = new MovieClip();
mc = MovieClip(new SWF());
img.source = mc;
vBox0.addChild(img);
protected function critcalBtn_clickHandler(event:MouseEvent):void
clear();
img = new Image();
img.width=Number("700");
img.height=Number("700");
mc = new MovieClip();
mc = MovieClip(new SWF2());
img.source = mc;
vBox0.addChild(img);
protected function clear():void
try{
if(mc!=null){
flash.media.SoundMixer.stopAll();
img.source="";
img.source=null;
mc=null;
vBox0.removeChild(DisplayObject(img));
vBox0.removeAllElements();
vBox0.removeAllChildren();
}catch(e:Error){
Alert.show(e + " ----::---- ");
<mx:Canvas id="vBox0" width="700" height="700" ></mx:Canvas>
<mx:HBox >
<mx:Button id="checkBtn" label="first" click="checkBtn_clickHandler(event)"/>
<mx:Button id="critcalBtn" label="second" click="critcalBtn_clickHandler(event)"/>
</mx:HBox>
now my error gone!!! but one problem is there when i unload my first SWF and load second SWF(on button click), my first SWF sound are still play in Background, i cn't unstand Y this will happen coz i already remove all object and child from my Canvas.
any help on this.... -
Help with load xml driven swf in another swf
Hello people ... (sorry for my Google transalte English)
... I am desperate, tapping in place last week.
In fact, i make flash CD presentation in Adobe Flash CS5 AS2 (with minimal use of ActionScript). It occurs to me the next problem ... need to load flash image gallery that i already have created, in new presentation file. Gallery was created in Flash Slideshow maker and as products I have. Swf,. Xml and folders with thumbnails and picture (no. Fla file).
The concept of the presentation (as root is concerned) should look like in uploaded picture "izgled otvorenog cd-a". In each of the folder on cd presentation (as on picture) is a Flash presentation controlled by their xml file whose name I must not change. Exe file "Prezentacija 2011" is a presentation (Flash Projector) that i try to make. In the same presentation i create frames and for each of the frames added action:
loadMovie ("02_Kapije/kapije.swf", "kapije_ucitavanje");
kapije_ucitavanje._x = 23;
kapije_ucitavanje._y = 167;
stop ();
(Of course, for each item varies loadMovie root and instance name).
The problem is that presentations can't find xml file, apparently because they do not have the appropriate root. When all the files of the one gallery set in the same folder with the "Presentation 2011.exe" file, everything works normally ( however, as i said, i cannot change the name of Xml file and that disturb the concept of my CD presentation).
How can I drive loaded swf file from the above script to use Xml file in its folder?
HELP PLEASE!!!
P.S. ...and it looks so easyyou're welcome.
p.s. please mark helpful/correct responses. -
I am making a site and I want each button to load an swf,
which would be the content of each page. When I click on each
button the swf will load, however, the old swf will not go away.
how does one do this. Thanks.It looks like you are adding the newly loaded swf, but not
removing the old one. So, maybe this change would help:
function about_CLICK(myevent:MouseEvent):void{
var loadMain:Loader = new Loader();
loadMain.load(new URLRequest("clip0.swf"));
// if there is a child on the display list remove it
if (getChildAt(0) !=null) removeChildAt(0);
stage.addChild(loadMain);
I should mention, however, that there is a bug in Flash 9
related to unloading swfs:
http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html
However, I don't think this is affecting your visible
behavior. -
Help with embedding fonts in swf file
Hi, I am haviing a problem with my fonts displaying in my swf file. I created the flash site using CS4 on a mac. I thought the fonts were embedded but when I tested the swf in safari and firefox the fonts disappeared are all scrunched up in 1/2" on top of each other in several lines. Its a mess. It is displaying in times or some other font when viewed in on a pc browser.
What I did so far that did not work:
Made fonts static with animation
made fonts dynamic with animation
How can I fix this?
I am still a beginner using flash so the simpler the option the better.
Thanks!!!there are quite a few ways you could mess this up but no one way that's typical.
create a new fla. click on the text tool, select static in the combobox and add a textfield to the stage. animate it. test it. any problems?
any other way (or ordering of steps) you use to create static text is prone to problems. -
Problem with loading and unloading external swfs
Hello Forum,
I'm pretty new to as3, and it's giving me a great challenge. I have a large number of captivate files that I want to play inside a simple container built in CS5.5... but switching back and forth between all the movies hogs the memory like crazy, so I need something to clean it up. All code is in a single frame on the main timeline. First, I create the loader:
var FlashLoader:Loader = new Loader();
var flashUrl:URLRequest = new URLRequest("placeholder.swf");
FlashLoader.load(flashUrl);
addChild(FlashLoader);
The actual movies are located via an XML... but as I said the memory problem is huge, so I tried to build something to get rid of that. Ideally, I want the loader to clean up everything and start life anew with a single mouse click, like so:
function _mouseClickHandler2(event:MouseEvent):void {
FlashLoader.unloadAndStop();
FlashLoader.parent.removeChild(FlashLoader);
FlashLoader = null;
var flashUrl:URLRequest = new URLRequest(event.target.href);
var FlashLoader:Loader = new Loader();
addChild(FlashLoader);
FlashLoader.load(flashUrl);
FlashLoader.x = 120;
setChildIndex(FlashLoader,0);
trace(FlashLoader.parent.numChildren);
// System.gc();
// System.gc();
// try {
// new LocalConnection .connect('gc');
// new LocalConnection .connect('gc');
// } catch (e: * ) {
// trace(getMemory ());
//trace(event.target.href);
//trace(event.target.text);
Upon clicking on the menu (and thus switching movies), I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Treeview_working_fla::MainTimeline/_mouseClickHandler2()
And this doesn't make sense to me. The FlashLoader is given a placeholder swf at the beginning, so why would the FlashLoader inside the function be recognized as having a null object reference?
Thanks in advanceIn my quest to tackle this problem, I've decided to try and isolate the problem, and have made a simple "click to load, click to unload" when I stumbled upon a curious problem. The movie loads fine, and the UNLOAD function upon mouseclick also works perfectly. However, upon clicking again to activate RELOAD, it gives the error "No active security context" and refuses to load the same exact swf with the same exact path that successfully loaded the first time!
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.net.URLRequest;
var FlashLoader:Loader = new Loader();
var flashUrl:URLRequest = new URLRequest("folder/subfolder/movie.swf");
FlashLoader.x = 120;
FlashLoader.load(flashUrl);
stage.addChild(FlashLoader);
stage.addEventListener(MouseEvent.CLICK, UNLOAD);
function UNLOAD(event:MouseEvent) {
flashUrl = null;
stage.removeChild(FlashLoader);
FlashLoader.unloadAndStop();
stage.removeEventListener(MouseEvent.CLICK, UNLOAD);
stage.addEventListener(MouseEvent.CLICK, RELOAD);
function RELOAD(event:MouseEvent) {
var FlashLoader:Loader = new Loader();
var flashUrl:URLRequest = new URLRequest("folder/subfolder/movie.swf");
FlashLoader.x = 120;
FlashLoader.load(flashUrl);
stage.addChild(FlashLoader);
stage.removeEventListener(MouseEvent.CLICK, RELOAD);
stage.addEventListener(MouseEvent.CLICK, UNLOAD); -
Help with loading infocube from flat file
Hi:
I am using SCM 5.1 and the BI 7.0 component that comes with it. I am trying to create an infocube and load it with flat file data but getting errors.
1. First I created the infoobjects and the infocube.
2.a I first tried to create only the data source and activate the datasource. This was not successful.
2.b I then tried to create the application component, infosource etc. (like one does in BW 3.0) but was still not successful.
If you have any pointers, could you please let me know? Thanks.
SatishYou can go through the following Blog for flat file loads.
https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/60debae1-84dd-2b10-e7bf-bdedf1eabdf9
If you are getting any specific error, then you can post it here.
Regards,
Gaurav -
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... -
Please Can someone point me to some god examplkes on loading and unloading swfs in AS3. I manage to load but unloading is a headache.
Thanks
Att.,
Edwinthere's nothing to study if you're using fp 10:
var yourloader:Loader=new Loader();
yourloader.load(new URLRequest("whatever.swf"));
function unloadF(){
yourloader.unloadAndStop(); -
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 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.
Maybe you are looking for
-
BPM : Files are not appended in the container operation step
Hi Guys, I am using the BPM pattern, "BpmPatternCollectTime" provided by the SAP under SAP BASIS 6.4 for the N:1 transformation. In the the Message mapping and Interface mapping source structure has "0 to unbounded" occurance and Target has 1 coo
-
Automator script for remote shutdown
hello everyone i use a mac mini as a media server and i use ssh from the terminal to turn it off remotely, i know you can run terminal commands in automator, but i cant get it to work can someone show me how the script should look like, im not even s
-
Hi, I have a table with some data. I want to allow the user to click on a row, and when they click on it show more rows beneath the "clicked" row. These newly shown rows would contain more specific data, etc. Any suggestions or references on how to d
-
Unable to start RAC Instance - error: PRKP-1001
Hello, I'm getting stucked about starting instance on the first node of my RAC. [oracle@itsm-cldb1a admin]$ srvctl start database -d TDW PRKP-1001 : Error starting instance TDW1 on node itsm-cldb1a CRS-1028: Dependency analysis failed because of: CRS
-
CS6 Pantone libraries are not in numerical order
In fact, they are random. For example, when creating a duotone, I click in the color area and I'm given a list of the Pantone colors in that library. If I click on the up arrow it gives me seven colors at a time. A reasonable person woud assume that