Load \ unload external movie
Hi!
While a parent movie plays, I want to replace a movie with
others.
The movie to be replaced was attached with the following
instruction (attachMovie):
_root.attachMovie("ButtonsTest", "buttonsTest_mc", 6,
{_x:400, _y:300});
I am looking for a way to unload the above movie and load at
the same coordinates the new external movie.
Please help
TIA
Nanu
use loadMovie into another MC ....
u have a MC with 2 frames ... control
1st frame - an empty mc, clip1
stop();
clip1.loadMovie("the_clip1.swf")
2nd frame - same empty, clip2
stop();
clip2.loadMovie("the_clip2.swf")
the button
on(release) {
control.gotoAndStop(2);
}
Similar Messages
-
Loading an external movie clip
Hi team,
Last time I wanted to load an external clip I could do it like this
on (release) {
unloadMovieNum(1);
loadMovieNum("whatever.swf",1);
So now I want to achieve exactly the same thing in AS3,
I have been looking at examples on the web but am getting all sorts of errors and basically don't know what I am doing. I also want to know how to navigate to .swf files in a file structure, as I have to build an old school fscommand file structure for a cd-rom.
Any and all help greatly appreciated.
Cheers,
SubHey worked it out guys!
var myLoader:Loader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("whatever.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
addChild(myLoader); // add that instance to the display list, adding it to the Stage at 0,0
But now I need to know.. How do I unload it?
Cheers
sub -
hi all
I have a problem loading in movies from a movie with a
scrolling menu. the problem is the movie(load.swf, the movie trying
to load into)is also loaded into main movie, so because of this
needs the code;
_global.loadNewMovie():
at the end of the maintimeline to load in and out of the main
movie.
thus my problem, I have the movie load.swf loading in and out
of my main.swf but know I can't get the little external movies to
load into load.swf......does this make any sense...sorry bit of a
newbie : (
so movie trying to load into is
load.fla
small external movies to load
movie1_02.fla
movie1_03.fla
I've put a link to a zipped folder with the fla's in would
anyone beable to help me get the movies movie1_02.fla and
movie1_03.fla loading into load.fla whilst still keeping the
_global.loadNewMovie():
on the main timeline??
heres the ln link
http://www.pmrltd.co.uk/help.html
cheers for your helpif you want the movies to simply load into your load.swf like
this and when one finishes the next loads in, you'd be better off
creating a container movie clip at (0,0) that you load your
load.swf movie into. tell this movie to play through its timeline.
at the end of that timeline, have it do a
this.loadMovie("movie1_02.swf") and then add a line of AS on the
end of movie1_02.swf that would
this.loadMovie("movie1_03.swf"). not the best approach but it
should work. -
Load/ Unload external .swf
----------------------------------------
vita | web | design | illustration
"main" here
I try to have external .swf on this "main" part of my flash
design automatically using load actionscript.
I have 3 different sets of actionscripts for load/unload.
But, the problem is when I click vita or other menu on the
top after loading "main" external .swf, they are overlapped.
How can I unload the external .swf from the automatically
loaded .swf?
(As I know, there are mostly buttons to click on loading
external .swf. But for my design, I want it loads automatically.)
Thanks in advance for suggestions. Please let me know if my
description/question is not clear to answer.Are you using AS2 or AS3. The approach is completely
different for both. -
How to Load/Unload external SWF
Hey all, I'm in a desperate struggle to meet a deadline for college coursework. I am unable to UNLOAD an external SWF file that I have put inside another SWF file. The problem that is occurring is, although it loads successfully, when I attempt to navigate to another page after viewing the external SWF, I expect it to close as it goes on to another page however, it remains in place. If i then go back on to the page that it is loading from, it will start to keep adding more and more SWF's. The print screens should explain it easier... Below i'll post the code that I'm using currently. The external SWF I am trying to load/unload is an interactive hangman game (whether it being interactive has an effect I do not know), but any and all help with this would be seriously appreciated!
The code currently being used is:
var _swfLoader:Loader;
var _swfContent:MovieClip;
loadSWF("Real Hangman.swf");
function loadSWF(path:String):void {
var _req:URLRequest = new URLRequest();
_req.url = path;
_swfLoader = new Loader();
setupListeners(_swfLoader.contentLoaderInfo);
_swfLoader.load(_req);
function setupListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, addSWF);
dispatcher.addEventListener(ProgressEvent.PROGRESS, preloadSWF);
function preloadSWF(event:ProgressEvent):void {
var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
// swfPreloader.percentTF.text = _perc + "%";
function addSWF(event:Event):void {
event.target.removeEventListener(Event.COMPLETE, addSWF);
event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF);
_swfContent = event.target.content;
_swfContent.addEventListener("close", unloadSWF);
addChild(_swfContent);
function unloadSWF(event:Event):void {
_swfLoader.unloadAndStop();
removeChild(_swfContent);
_swfContent = null;
This printscreen is showing what it looks like in the Flash view (plain background and external SWF loads when this SWF is published)
What it looks like when loaded as published swf
Picture of the external SWF working inside the other SWF
Picture of it not being able to unload when i navigate to another page!
Finally, a picture of it doubling up when i proceed to go on the 'game' page again, it just keeps loading the SWF's rather than unloading them!for example, file1 consits of two buttons, and also considered as main page. As i click on these two buttons , it will lead me go to open the external file2.swf, and file3.swf respectively. (file2.swf and file3.swf could have other navigation buttons, however, i am just simplify here).
the code you provided is working fine. but i want to totally remove/unlink the orginal file (file1.swf) when i click on either buttons which could lead me to other page (file1.swf or file2.swf).
Besides that, in file2.swf and file3.swf could have another "back" button to turn it back to the main page (file1.swf). When the user click on that back button, the file2.swf will unloaded...and file1.swf will be called back again...
can it be done?
so sorry if my poor explanation makes you confuse..
thank you. -
Loading An External Movie...
I'm new to Flash and this may seem like a silly question but I need help with using an external .swf file in my main timeline for my site. Basically, I've figured out how to load the movie and that works great, but the problem is when I click off of that page the movie stays up there. What is the best way for me to exit out of that movie once the user clicks on anything outside of that movie? Your help is greatly appreciated!
BFMOne way would likely be to have an empty movieclip in the timeline that you load that swf into. When you load something dynamically, if it isn't targeted to load into something that lives on the timeline, it doesn't have a home relative to the timeline, so moving along the timeline doesn't make it go away.
Another way is to remove the swf, and doing that depends on how you loaded it (which version of AS). -
Load an external .mov (quicktime movie hinted) file
Hi guys!
Sorry for the bad bad bad english ^_^'
I have some .mov files that they are dynamic realizations
(movie hinted). This movie files have the possibility to explore
itself through mouse and keyboard.
If the .mov file were a normal movie I would have resolved
the problem. Problems are:
- Flash doesn't recognize the "special" format (movie hinted)
if I try to import it.
- If I convert the .mov in a .flv it produces a static image
and not an interactive movie as I want.
- The mediaplayback component is limited to the use of the
.flv, right?
- The "loadMovie" string doesn't load the .mov.
I'd try, maybe, all possibility. I don't know if exist a
tutorial that explain how load .mov files in flash simply
specifying a link.
Can you help me? I use Flash MX 2004 Pro
Thanks, byeHello.
This post was a very long time ago but I am having this
problem now and I was wondering if you had any solutions?
I have a 3D phone that my client wants to spin around so the
consumer can see it from all sides. The .mov file works fine as it
is but, apparently, you cannot use anything but .flv in Flash. Any
help would be like gold and thank you in advance. -
I've created (with help) a series of buttons that scroll a
movieClip's x-position according to an arrayIndex. With variables,
these buttons also cycle through their up and down state as the
user clicks from one to the next. I'd like for them to also load an
external flash movie into a "loader" movie clip. More precisely, a
different external swf for each button.
I don't know how to include the loadMovie script into the
(beyond my skills) action script that controls my x-postion
buttons. I've tried to write the bellow code for each button, but
it stops my x-position scroll.
I tried to use this code... but it stops my movieClip from
scrolling.
controller_mc.but1.onRelease = function() {
loadMovie("chapterTest.swf", "_root.loader");
Here is my complete code. I'd be happy to answer any question
and I'll also attach my file for review. Thank you.
click here for
my filesHi,
Ok, you mentioned that you had an issue when clicking on a
button to load an external movie it would stop your x-position
scroller. I downloaded your files and you have a button in the
library that's found in the timeline called btnLink_01. You have an
button event called:
//thumb links
timeline1.link01.onRelease = function() {
When I opened your file and ran the movie, I click on the
btnLink_01 at it did not load the external movie called test.swf,
which I created, and didn't seem to affect your x-scroll
functionality. I did some troubleshooting and set the color
properties from Alpha to None on movieclip "loader" movie and it
loaded the external movie just fine. Seemed like you had the alpha
set to 0, so when the movieclip was loaded, it didn't show up. Not
sure if this is the issue you had. Let me know if that helps or if
I wasn't resolving your issue correctly.
Thanks,
Jaime -
Control external swf file that is loaded into main movie
I've loaded an external movie into Scene2 of the main movie,
I want a button in the main movie, in scene two, which shows
up right now under the external loaded movie, to be able to
onRelease gotoAndStop at the first frame of the external movie
which is loaded into that scene. Do I just write that as:
AssociateSelected_btn.onRelease = function() {
gotoAndStop("RGSassociate.swf","frame1")
? I thought I tried this, but since the ext.movie is loaded
automatically on entering the scene it is not put into a level
(which would be easier to navigate)....
Any help/thoughts would be much appreciated, thanks!Just a thought- can i refer to the external movie through the
loading component instance name?
Still wondering if I can control the time line inside the
external movie from the main movie... -
Loading an external MC with Tween
I am getting this error when I load an external movie (which has Tween Animations):
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-46()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.transitions::Tween/set time()
at fl.transitions::Tween/nextFrame()
at fl.transitions::Tween/onEnterFrame()
The MC loads but once I unload the main movie locks and does not allow interaction.
Any ideas why?
Thank youHello Kglad:
I followed
I still get this:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-46()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.transitions::Tween/set time()
at fl.transitions::Tween/nextFrame()
at fl.transitions::Tween/onEnterFrame() -
Print only the external movie with its current applied settings?
Hi,
I'm making a flash application for a paint company to test various paints on different objects. But I got a little problem.
Which is here...
Here is my code....
/* Print Button Function Here.....*/
print_btn.addEventListener(MouseEvent.CLICK,printPage);
function printPage(evt:MouseEvent) {
var printJob:PrintJob = new PrintJob();
if (printJob.start()) {
if (uiLoader.source.width>printJob.pageWidth) {
uiLoader.source.width=printJob.pageWidth;
uiLoader.source.scaleY=uiLoader.source.scaleX;
printJob.addPage(Sprite(uiLoader.source));
printJob.send();
Actually I have a movie clip which contains a Print Button and a uiloader.
uiloader loads differnt external movies.
I applied a code to Print button to print those movies.
This code is working good but problem is, it print the both (main_movie & external_movie) with its actual colors not with the current applied colors.
I want to print only External movie with its current color settings (applied by user) not actual default colors.
So can any one tell me how can i do this?
Thank for help....use:
print_btn.addEventListener(MouseEvent.CLICK,printPage);
function printPage(evt:MouseEvent) {
var printJob:PrintJob = new PrintJob();
if (printJob.start()) {
if (uiLoader.width>printJob.pageWidth) {
uiLoader.width=printJob.pageWidth;
uiLoader.scaleY=uiLoader.scaleX;
printJob.addPage(uiLoader);
printJob.send(); -
Interaction + external movie
Hi guys,
It's my first post in here, I spent most of the day looking
for my answer but i still couldn't find it.
So my problem is,
page1 = index
page2 = aboutme
page3 = portfolio
On my Index, lets call page1, I have a menu, the same menu
that i have on my page3, this menu contain around 10 links, so the
basic idea is to open differents externals movieclips in each link,
it works fine when I use this links on page3, i just used the
action to each link;
- on (release) {
this._parent.gallery_mc.loadMovie("animal_gallery.swf");
ok, the thing is, when i use the menu on page1, it has to
open page3 and then, inside page3, load my external movie in my
gallery_mc; so lets see the action;
on (release) {
if (_root.link<>page && _root.G<>1
&& _root.SP ==0) {
_root.scroller.gotoAndStop("s0");
_parent["item"+_root.link].gotoAndPlay("s2");
_root.link = page;
_root.ch_cont.gotoAndPlay("s1");
if (_root.link<>page && _root.SP ==1){
_root.scroller.gotoAndStop("s0");
_root.link = page;
_root.play();
This works fine, its just to call my page3. So now is missing
to load my external MC into a MC called gallery_mc into my page3,
so I tried all the ways and still didn't work;
Just for u to understand the structure;
root + ch_cont + all_pages + page3
Its a bit difficult to explaim, but hope u will understand
it!!!
thanks for your time!!!
Danieltry
_level0.gotoAndStop("mainswfframe"); -
How to unload externally loaded swf which contains 3D Carousel?
Hello to all
I am learning AS3 and have been taking on various tutorials found on the net. While learning about AS3 I came across a lesson on http://tutorials.flashmymind.com/2009/05/vertical-3d-carousel-with-actionscript-3-and-xml/ titled "Vertical 3D Carousel with AS3 and XML".
I completed the tutorial and all worked fine so I then wanted to load the swf into a existing project. The loading of the swf goes fine and when I unload my loader it is removed but only visually as in my output panel in flash CS5 I get an error as follows
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at carousel_c_fla::MainTimeline/moveCarousel()
this error repeats over and over again slowing my swf movie.
So does this mean my main flash movie trying to still play / find my unloaded 3D Carousel?
If so how do I unload remove all the AS3 that is trying to run from the 3D Carousel?
I have included the AS3 below from the tutorial page and I understand that this is what I have to remove to "break free" from the 3D Carousel swf when it is unloaded. This is where I am stuck as my knowledge of AS3 is limited - Can you guys / girls help?
//Import TweenMax
import com.greensock.*;
//The path to the XML file (use your own here)
// old var from tutorial - var xmlPath:String = "http://tutorials.flashmymind.com/XML/carousel-menu.xml";
var xmlPath:String = "carousel-menu.xml";
//We'll store the loaded XML to this variable
var xml:XML;
//Create a loader and load the XML. Call the function "xmlLoaded" when done.
var loader = new URLLoader();
loader.load(new URLRequest(xmlPath));
loader.addEventListener(Event.COMPLETE, xmlLoaded);
//This function is called when the XML file is loaded
function xmlLoaded(e:Event):void {
//Make sure that we are not working with a null variable
if ((e.target as URLLoader) != null ) {
//Create a new XML object with the loaded XML data
xml = new XML(loader.data);
//Call the function that creates the menu
createMenu();
//We need to know how many items we have on the stage
var numberOfItems:uint = 0;
//This array will contain all the menu items
var menuItems:Array = new Array();
//Set the focal length
var focalLength:Number = 350;
//Set the vanishing point
var vanishingPointX:Number = stage.stageWidth / 2;
var vanishingPointY:Number = stage.stageHeight / 2;
//We calculate the angleSpeed in the ENTER_FRAME listener
var angleSpeed:Number = 0;
//Radius of the circle
var radius:Number = 128;
//This function creates the menu
function createMenu():void {
//Get the number of menu items we will have
numberOfItems = xml.items.item.length();
//Calculate the angle difference between the menu items (in radians)
var angleDifference:Number = Math.PI * (360 / numberOfItems) / 180;
//We use a counter so we know how many menu items have been created
var count:uint = 0;
//Loop through all the <button></button> nodes in the XML
for each (var item:XML in xml.items.item) {
//Create a new menu item
var menuItem:MenuItem = new MenuItem();
//Calculate the starting angle for the menu item
var startingAngle:Number = angleDifference * count;
//Set a "currentAngle" attribute for the menu item
menuItem.currentAngle = startingAngle;
//Position the menu item
menuItem.xpos3D = 0;
menuItem.ypos3D = radius * Math.sin(startingAngle);
menuItem.zpos3D = radius * Math.cos(startingAngle);
//Calculate the scale ratio for the menu item (the further the item -> the smaller the scale ratio)
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
//Scale the menu item according to the scale ratio
menuItem.scaleX = menuItem.scaleY = scaleRatio;
//Position the menu item to the stage (from 3D to 2D coordinates)
menuItem.x = vanishingPointX + menuItem.xpos3D * scaleRatio;
menuItem.y = vanishingPointY + menuItem.ypos3D * scaleRatio;
//Add a text to the menu item
menuItem.menuText.text = item.label;
//Add a "linkTo" variable for the URL
menuItem.linkTo = item.linkTo;
//We don't want the text field to catch mouse events
menuItem.mouseChildren = false;
//Assign MOUSE_OVER, MOUSE_OUT and CLICK listeners for the menu item
menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
//Add the menu item to the menu items array
menuItems.push(menuItem);
//Add the menu item to the stage
addChild(menuItem);
//Assign an initial alpha
menuItem.alpha = 0.3;
//Add some blur to the item
TweenMax.to(menuItem,0, {blurFilter:{blurX:1, blurY:1}});
//Update the count
count++;
//Add an ENTER_FRAME listener for the animation
addEventListener(Event.ENTER_FRAME, moveCarousel);
//This function is called in each frame
function moveCarousel(e:Event):void {
//Calculate the angle speed according to mouseY position
angleSpeed = (mouseY - stage.stageHeight / 2) * 0.0002;
//Loop through the menu items
for (var i:uint = 0; i < menuItems.length; i++) {
//Store the menu item to a local variable
var menuItem:MenuItem = menuItems[i] as MenuItem;
//Update the current angle of the item
menuItem.currentAngle += angleSpeed;
//Calculate a scale ratio
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
//Scale the item according to the scale ratio
menuItem.scaleX=menuItem.scaleY=scaleRatio;
//Set new 3D coordinates
menuItem.xpos3D=0;
menuItem.ypos3D=radius*Math.sin(menuItem.currentAngle);
menuItem.zpos3D=radius*Math.cos(menuItem.currentAngle);
//Update the item's coordinates.
menuItem.x=vanishingPointX+menuItem.xpos3D*scaleRatio;
menuItem.y=vanishingPointY+menuItem.ypos3D*scaleRatio;
//Call the function that sorts the items so they overlap each other correctly
sortZ();
//This function sorts the items so they overlap each other correctly
function sortZ():void {
//Sort the array so that the item which has the highest
//z position (= furthest away) is first in the array
menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
//Set new child indexes for the item
for (var i:uint = 0; i < menuItems.length; i++) {
setChildIndex(menuItems[i], i);
//This function is called when a mouse is over an item
function mouseOverItem(e:Event):void {
//Tween the item's properties
TweenMax.to(e.target, 0.1, {alpha: 1, glowFilter:{color:0xffffff, alpha:1, blurX:60, blurY:60},blurFilter:{blurX:0, blurY:0}});
//This function is called when a mouse is out of an item
function mouseOutItem(e:Event):void {
//Tween the item's properties
TweenMax.to(e.target, 1, {alpha: 0.3, glowFilter:{color:0xffffff, alpha:1, blurX:0, blurY:0},blurFilter:{blurX:1, blurY:1}});
//This function is called when an item is clicked
function itemClicked(e:Event):void {
//Navigate to the URL that's assigned to the menu item
var urlRequest:URLRequest=new URLRequest(e.target.linkTo);
navigateToURL(urlRequest);Hi Ned thanks for the reply,
Ok so I have a button in my main movie that loads the external swf
stop();
var my_loader:Loader = new Loader();
var my_btn:Button = new Button();
var my_pb:ProgressBar = new ProgressBar();
my_pb.source = my_loader.contentLoaderInfo;
my_btn.addEventListener(MouseEvent.CLICK,startLoading);
function startLoading(e:MouseEvent):void{
my_loader.load(new URLRequest("carousel.swf"));
addChild(my_pb);
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishloading);
function finishloading(e:Event):void{
addChild(my_loader);
my_loader.addEventListener("killMe",
killLoadedClip);
removeChild(my_pb);
function killLoadedClip(e:Event):void {
my_loader.removeEventListener("killMe",
killLoadedClip);
my_loader.unloadAndStop();
removeChild(my_loader);
Then I have a button in my loaded swf that closes the loader
This is spread over 2 frames
Frame1
function closeIt(e:MouseEvent):void {
parent.dispatchEvent(newEvent("killMe"));
Frame 2
back_btn.addEventListener(MouseEvent.CLICK, closeIt);
Frame 2 also holds all the code for the carousel
Thanks for your time and help in advance people ; ) -
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(); -
Loading external movies differently
I am making a web site with several pages that the content
will load as an external movie. Right now I have all loading with
the nav buttons "on release". The first page loads through one
blank clip and the rest in another. What I would like to do is have
the first external page/clip content load with the main page and
also reload with the nav button if someone wishes to return and
leave the other buttons to remain loading each pages external
content like they are now. So is there a way to get the first pages
content to load both ways? This is what the code for the first
button looks like now :
on (release) {
//load Movie Behavior
if(this.aboutext == Number(this.aboutext)){
loadMovieNum("aboutus.swf",this.aboutext);
} else {
this.aboutext.loadMovie("aboutus.swf");
//End Behavior
//unload Movie Behavior
if(this.blk == Number(this.blk)){
unloadMovieNum(this.blk);
} else {
this.blk.unloadMovie();
//End Behavior
Right now everything works I just don't have any content
until a button is clicked.Hi,
Take a look at this simple tutorial and you will find what
you are looking for.
Here
Hope this helps
Cheers
Alan
Maybe you are looking for
-
Error in query running.
when i am running a query i am getting this error in WAD: "Value 'SPEED STICK DEO REG (1dz)' (hex. '0053005000450045004400200053005400490043004B002000') of characteristic 0CP_TEXT contains invalid characters", I tried to run the same query in RSRT,
-
IPod touch has speaker symbol permanently showing and volume will not turn up
After having earphones in the iPod following a workout, the speaker symbol is permanently showing and the volume slide bar keeps sliding down to silent, I have tried a total dis-charge of the battery and also a restore to original settings but these
-
I am using Illustrator CS4 on a Vista OS and don't see the red, yellow and green circles on the Application Bar. Can anyone help?
-
Problem installing realplayer for radio listening
Hi everyone. I'm trying to help my mum to listen to bbc radio programmes on her mac. I'm not an expert by any means, but have downloaded the realplayer system onto her computer. The download goes okay, and the logo appears on the computer menu, but o
-
Copy GL Master from one company code to another company code
Kindly provide the details how to copy the GL Master A/c from One company code to another company code. T .Code-OBY2 can used or is there any other method. Pl do the needful. regds amarnath