Controlling Externally Loaded Swfs
Hello-
I am using AS 2.0 and MX 2004. I have a movie that loads in external swfs and images using the MovieClipLoader to load the element in to a clip called "container".
Now I've been testing within flash with test movie and it works great. as soon as I export my commands that toggle within different frames of the external swf fail.
what I have is:
container.gotoAndStop(frameLabel);
is there an obvious reason why this would stop working on export? or things I could try to figure this out.
I tried loading on to levels instead so I would have:
_level25.gotoAndStop(frameLabel);
and I still have the problem.
I am exporting as Flash 8 and testing in Flash Player 8.
ideas?
FlashKit > Flash Help > Flash ActionScript
Posted on: 01-17-2006, 12:48 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Controlling MCs Inside Externally Loaded SWFs
I am loading a SWF file on layer1 of my project, and I'm attempting to position it from my _level0 "root" timeline with:
_level1.pledge._x = 256;
_level1.pledge._y = 144;
Alas, I can't make it work. The only MC inside the loaded SWF file has the instance name "pledge", so I figure this should work. What am I doing wrong?
Loading External Swfs Into Externally Loaded Swfs.
ive got some buttons on my main timeline that im using to load external swfs into an empty mc. the buttons are coded with the following:
on(release){
if(_root.currMovie == undefined){
_root.currMovie = "1";
emptyMC1.loadMovie("1.swf);
} else if (_root.currMovie != "1") {
if (emptyMC1._currentframe >=
emptyMC1.midframe) {
_root.currMovie = "1";
emptyMC1.play();
}
}
}
1.swf also has some buttons that load external swfs into a second empty mc. those buttons are coded with the following:
on(release){
if(this.currMovie == undefined){
this.currMovie = "2";
emptyMC2.loadMovie("2.swf");
} else if (this.currMovie != "2") {
if (emptyMC2._currentframe >=
emptyMC2.midframe) {
this.currMovie = "2";
emptyMC2.play();
}
}
}
1.swf loads into emptyMC1 ok, and 2.swf loads into emptyMC2 ok.
when i press any of the buttons on the main timeline, the outro animation of 1.swf plays correctly, but the outro animation of 2.swf does not. is there a way to the buttons so that the emptyMC's unload sequentially?
Externally Loaded SWFs #2
Is it possible to send instructions from a swf which is loaded in another one, to the one its been loaded into?
I'm using a scrollpane to import SWFs.
Externally Loaded SWFs
I'm trying to load swf1 in swf2, which works, using a scrollpane and this little bit of actionscript:
_root.main1.loadScrollContent("../test/swf_main/swf1.swf");
But, swf1 contains a dynamic text box in a movie which should load an external txt file, using this code:
loadVariables("welcome.txt", this);
Now, when I open swf1, it displays the text from welcome.txt, but when I open swf2, welcome.txt isn't displayed.
Is this even possible? Or what am I doing wrong?
Controlling Loaded Swf's Externally
i posted this in scripting - backend, and didn't receive any replies. probably because it seemed to be the wrong forum. here it is again, verbatim. also, i'm using flash mx.
---
ok, this is the deal. i'm designing a site and basically what i want to happen is when a section is clicked, i want the previous section to animate out, and the other to animate in. also, i'm loading the sections into a movie clip, using loadmovie.
what i want to happen, ideally, is when a section is clicked, it changes the value of a variable, and then proceeds to play the swf that has been loaded into the movieclip. when it reaches the end of the timeline, i have an function checking the value of the variable (which is located in the main swf), and loading the appropriate swf file.
so, basically, what i'm having trouble with, is controlling the timeline of the loaded movie clip with a button located in a clip in the main swf. i was wondering if this is possible, and also if the function i created to check the value of the variable (for the sections) and also the variable can be passed into the loaded swf file also.
help would be very appreciated, and keep in mind, i'm fairly new to flash. thanks.
Controlling An Externally Loaded Swf
Can anyone help? I have a swf file that I have brought into my main movie using the loadMovie action (it is targeted to a blank movieClip called 'placeholder')
Does anyone know how I can control this loaded movie clip from a button on the main timeline?
When the button is pressed I want the loaded swf to begin playing at Frame X, and when it reaches frame Y, it tells the main movie to goto Scene2. (I think I know how to do the last bit! I'm just struggling with the first bit!!)
Any help/ideas would be much appreciated!!
Ta! :O)
Controlling Externally Loaded Swf's
Can anyone help? I have a swf file that I have brought into my main movie using the loadMovie action (it is targeted to a blank movieClip called 'placeholder')
Does anyone know how I can control this loaded movie clip from a button on the main timeline?
When the button is pressed I want the loaded swf to begin playing at Frame X, and when it reaches frame Y, it tells the main movie to goto Scene2. (I think I know how to do the last bit! I'm just struggling with the first bit!!)
Any help/ideas would be much appreciated!!
Ta! :O)
Controlling SWF That Were Loaded Externally...
I have posted a similiar question and looked all over the place but it just doesn't seem to work. I am trying to have a play and stop button that controls a externally loaded swf and I just can get it to work... I am using the following AS...
ActionScript Code:
on (release) { _root.container.transition.stop();}
My container is obviously called "container" and my swf that is loaded is called "transition" and it just won't work. Does anyone have any suggestions? Thanks
Mike
Controlling Externally Loaded Swf's
hey.
i'm having a bit of a problem that hope someone might be able to help me with.
i had made a image gallery using xml in flash MX 2004. some of the images are jpgs and some are swfs. i'm trying to get it so that once the external file, be it jpg or swf, is loaded, it would recenter itself in the middle of the page.
so i attached the following code to the container clip that the files were loaded into:
onClipEvent(load){
this._x = ((304 - this._width)/2);
this._y = ((304 - this._height)/2);
}
this coding works fine for the loaded jpgs, but not the swfs. then just for laughs, i put a button on the page that had basicly the same code attached to it:
on(press){
this._x = ((304 - this._width)/2);
this._y = ((304 - this._height)/2);
}
and that works on the swfs as well as the jpgs.
so basicly i would like to get this to work without having to press a button to center the image. any thoughts?
Controlling SWF That Were Loaded Externally...
I have posted a similiar question and looked all over the place but it just doesn't seem to work. I am trying to have a play and stop button that controls a externally loaded swf and I just can get it to work... I am using the following AS...
ActionScript Code:
on (release) { _root.container.transition.stop();}
My container is obviously called "container" and my swf that is loaded is called "transition" and it just won't work. Does anyone have any suggestions? Thanks
Mike
Controlling An Externally Loaded FLV
Hi actionscripters,
I'm trying to control an externally loaded FLV. I'm pretty noobish with AS, but here's my code:
Actionscript Code:
vid.setMedia("Welcome.flv", "FLV");movieLength = vid.totalTime;currentPos = vid.playheadTime;pct = currentPos/movieLength;if (pct == 10) { vid.pause();}
I'm trying to make the video stop a little early, but I put 10 in as my percent just so I didn't have to sit through the whole thing to make sure it worked. It doesn't, obviously, so any help or pointers would be greatly appreciated.
Thanks!
Cant Unload Externally Loaded Swfs Please Help
Hi guys...I have searched the board and read everything to do with loading and unloading external swfs yet I am still having problems unloading some swf's.
My main stage starts by loading an intro.swf and a menu.swf into level1 and level100 respectivly. The menu.swf then has a slideup menu system with buttons that load other external swf's which all work fine. However when I try to unload some of the swf's they dont work.
If I click on a button within the menu I then load a movie into level1 replacing the intro.swf and another set of buttons appears next to the main menu which are loaded into level3.
If I then click the home button to return to the start it should unload the content on level1 and load the intro.swf again whilst unloading the swf on level3 to appear like it is back to the start...the main content unloads fine but the buttons in level3 do not.
on (press) {
unloadMovie("_level3.bottommenu1.swf");
unloadMovie("_level1.op01.swf");
unloadMovie("_level1.patientsleftbox.swf");
unloadMovie("_level4.video1.swf");
loadMovieNum("intro.swf", 1);
}
this is the code to return to the start basically the home button...to see this working please goto http://www.gallstone-surgery.com/site/index.html you can also download the fla's
Sizing Externally Loaded .swfs?
kind of a newb to scripting. how do you size a movie clip that you want to load into a movie? also, how can i control the location of the loaded .swf? this is the script i've been trying to use:
loadMovieNum("http://www.blabla.com/bla.swf",1);
^not the real url.
i tried putting the code in a movie clip, then scaling the MC on the stage, to no avail.
any help greatly appreciated!
_totalFrames And Externally Loaded Swfs.
Im working on a cd-rom application in Flash for my portfolio which will feature heavy video (enhanced music cd)
Using Sorenson Squeeze I have exported mpeg video directly to a swf.
I have about 10 swfs and each are circa 30mb.
As such they are brought in using loadMovie when requested and attached to movie_mc (a placeholder).
Because I used sorenson I have no ability to add functions (preloader to pass back a totalFrames variable to the main timeline)to these external swfs.
I need to determine the totalFrames in a loaded swf in order to determine when it has finished playing so that it can be replaced with a standard mc.
using a combination of this code:
Quote:
enteredTrack = audioFields_mc.songInput;
loadMovie("musicVids/"+enteredTrack+".swf", moviePlayer_mc.movie_mc);
dynamicTitle = enteredTrack+".swf";
dynamicTitleFrames = moviePlayer_mc.movie_mc.dynamicTitle._totalframes;
Im having no luck.
I know for a fact that this line is wrong
moviePlayer_mc.movie_mc.dynamicTitle._totalframes;
and it is infact reading "dynamicTitle" as part of the path instead of adding its value to the path. How to fix this, I dont know.
Im also concerned that requesting the _totalframes immediately after loading the video in wont work because it will not be fullyloaded from the CD when the function is called.
Help!
Targeting Externally Loaded Swfs
Ok guys here is my problem
I have an empty Movie which i named main.swf. on the first frame of main.swf i load another movie called shell.swf into _level100 of the main.swf this has stop and play buttons located in it....now on this timeline i load another movie into _level2 which is the animation to be controlled by those stop and play buttons. However i cant seem to target the animation correctly whne the stop button is clicked the animation continues to play...
any ideas guys?
SWF Object And Externally Loaded .swfs
Anyone know of any difficulties using the SWF Object method (http://blog.deconcept.com/swfobject/) to place a .SWF which loads external .SWFs into itself into an .html document?
The project is a Flash only site that in which the .SWF file displayed on the .html page is a shell for various externally loaded .SWFs. All .SWF files reside in the same folder and the file structure was not changed when the main .SWF was placed in the .html file using SWF object.
Thanks
HTML And Externally Loaded Swfs
I have a Flash movie where I'm loading in external swfs. When I preview in Flash, it works fine. When I publish in HTML (from Flash), it works fine. When I try to embed my Flash movie into a different HTML page using Dreamweaver, the external files don't load. I've done this a hundred times in the past, but I'm having this problem with a few different Flash Movies -- Only the ones that load external content -- any ideas??
Communication Between Externally Loaded SWFs
Hi
I have a problem with working with loading different SWFs into a main SWF file. I have one main SWf file (menu.swf) and then several external files (Game1.swf, Game2.swf, Game3.swf etc).
The main SWF starts off and loads Game1.swf into the main SWF. After a user finishes Game 1 he clicks on a button inside the Game1.swf and thats supposed to unload Game1 and loads Game2 into the menu swf.
The trouble is I have no idea how to reference methods in the main SWF with the loaded SWF. Anyone have any ideas?
I tried root.parent but that wouldn't compile.
Maybe there's a better way of doing it?
Any help would be greatly appreciated.
Controlling Externally Loaded Jpegs
Hi all. I've loaded a jpg through a function which is called at the end of a mc. The function (on the main timeline) is as follows:
function startjpg(jpg) {
counter = 1;
container_mc.loader_mc._alpha=0; //makes mc jpg is loaded into invisible
container_mc.loader_mc.loadMovie(jpg); //loads jpg into a blank mc
}
I want to fade it in and eventually do other stuff to it like make it move and such. On frame 2 on the main timeline I have:
container_mc.loader_mc._alpha = counter;
And on frame 3:
counter = counter+1;
if (counter>99){
stop();
}
else{
prevFrame();
play();
}
Seems like it should work, but I know I must be doing something wrong. Wish I could post to a url. Hope it's all clear. Thanks!
Controlling Externally Loaded Clips
I am trying to tell an externally loaded clip to go to another frame in the movie. I have loade the clip into an empty movie clip on my main stage, and then I want to put an action on my main timeline that tells the externally loade clip to go to a certain frame in the clip.. Does anyone know the code for this? I tried giving the emptyclip an instance name, and then referencing the instance to go to a certain frame, but it does not work, It ignores it completely.
Mike
Controlling Externally Loaded Clips
I am trying to tell an externally loaded clip to go to another frame in the movie. I have loaded the clip into an empty movie clip on my main stage, and then I want to put an action on my main timeline that tells the externally loaded clip to go to a certain frame in the clip.. Does anyone know the code for this? I tried giving the emptyclip an instance name, and then referencing the instance to go to a certain frame, but it does not work, It ignores it completely.
Mike
Controlling Externally Loaded Movie
Hi there, well I found out a way to make my image 'canline-alpha' loader to work perfectly smooth .. now I have one more question (haha always more .. what a newb!)
I have my site setup to load, and unload external movies into a "contback" layer that I have ... while that works, I need to be able to control the loaded movies timeline and can't seem to figure how.
im using the command :
b1.onRelease = function() {
if (_root.whatscene != "main1.swf" ){
_root.whatscene = "main1.swf";
_root.contb.gotoAndPlay("open");
}
}
which then in a movie on the main timeline (contb) goes and "opens" the named "scene" via. "loadMovie(_root.whatscene, _root.contback);" which obviously, loads the external movie called main1.swf into the layer contback on the main timeline.
My question now .. is if I wanted to go to a certain frame in the external movie (main1.swf) ; how would I go about doing so?
Controlling Externally Loaded SWF File
Hello to all!
I apologize if this question has already been asked.
I'm trying to figure out how to control a SWF that I'm loading into my main timeline. The SWF has been created in Captivate and already has controls, I just don't want the movie to play as soon as I preload it.
I'm loading the SWF into a blank_mc. How do I get this SWF to not play, or put an action within the blank_mc that will start the playback of the SWF when the end user desires.
Is this possible?
Thank you any and all who can help me out.
Chris
Controlling An Externally Loaded .swf's Actionscript
Here is my problem, I am loading a .swf that a previous developer made (don't have the .fla) but the actionscript at the end of the movie is resolving to home.html. Instead of it resolving to home.html I would like for it to instead have gotoandPlay. Is this possible to do?
Thanks for any tips or advice.
Controlling Sound From An Externally Loaded Swf
hello,
here's my problem.
i have a file called main.swf that has background music.
(below is how the music is loaded)
Code:
mySound = new Sound();
mySound.attachSound("Music");
mySound.start(0, 100);
and an external.swf that loads into main.swf
external.swf gets loaded on a button click and at the same time it's loaded the background sound of main.swf is stopped.
all of this works fine.
but when i try to start the sound again with a button in external.swf the sound doesn't start playing.
(below is how i call on the sound to start playing again)
HTML Code:
_root.mySound.start(0, 100);
this seems so excruciatingly simple but i haven't been able to get it to work for 2 full days.
i've tried mySound = new Sound(this); and that doesn't seem to help.
thanks,
jenny
Controlling Externally Loaded Swf Question
i had a scene in a fls that had a clip that acted like a timer, at the end of the clip it told the maintimeline to play
_root.play();
now i made thew scene a separate swf that i am loading externally via the load
component. instamce name is newbiz_clip
as an external swf i cant get the timer to make it play anymore, i tried all these below:
_root.play();
_parent.play();
newbiz_clip.play();
what am i doing wrong here?
Masking Problems With Externally Loaded Swfs
I'm loading external swfs into a target movieclip ("clip a"). That target is nested inside another movieclip ("clip b"). I have an animated mask applied to "clip b" (the animated mask is contained within a graphic symbol). When I do this the mask layer doesn't seem to work properly (sometimes it doesn't use the animation, other times the externally loaded swf doesn't show up at all). I have tested to see if it would work without loading the movie from an external swf and it works fine. Its only when I use loadMovie() that it seems to fail. I've also noticed that if I publish as flash player 6 it works fine (I can't use 6, though, due to client restrictions). Has anyone had this problem before and created a work around for version 5? Any help or a simple explanation of why this happens would be greatly appreciated.
(Simple?) Problems With Externally-loaded .swfs...
I've got a jukebox thingy that allows the user to choose a track (an external swf) into a target mc (using loadMovie). Only one target is used. It all works, but...
...5% of the time they just don't load.
Could this possibly be because the button has a fair chunk of code on it (if track == 1 if quality == "high" loadMovie "track1url", _root.swfholder etc.) and Flash occasionally fails? Does this happen? Do I need to repeatedly ask for the swf until I'm sure it is loading? Or is the server simply not processing the request?
...if I change track too quickly (as some users presumably will...) the connection slows to a crawl.
This is the bigger of the two problems. If I load a swf into a target and then unload it before it is fully loaded will it continue loading regardless? If I quickly select track-one-then-three-then-seven is my connection receiving three swfs simultaneously? Shouldn't they replace each other?
Help please!
Using SendAndLoad And OnLoad() From Externally Loaded SWFs?
My site basically uses movieclips to load things in a similar method to HTML frames...I have set up a simple forum using php and mySQL, and everything works fine...provided that the forum's swf is loaded as _root...however when i have the index.swf up and load in the forum's swf as a movieclip, nothing works properly...what it is supposed to do is through a sendAndLoad kick out the forum name that should be retrieved to a php script, then return the text and display it in a dynamic text field...simple...and working when layers are not in the way...it still sends the data properly...but the text does not return, or at least does not display...
on (release) {
sendout.forum=topic.getValue();
sendout.sendAndLoad("HIDDEN FOR POSTING", read, "POST");
}
is the button's code and
read = new LoadVars();
sendout = new LoadVars();
read.onLoad = function(success) {
if (success) {
forumtext.text = read.displaycomment;
}
};
is on frame 1...the variable returned by php is 'displaycomment' and on the stage the dynamic text box is 'forumtext'....
as i say, when this swf is loaded in the browser all is well...but when it is loaded into the main swf, it all falls appart...
any help would be greatly apperciated...
index: www.ancalagon.net/index.swf
standalone: www.ancalagon.net/whatwassaid.swf
[MX] Pause/play Externally Loaded Swfs?
Hi,
I've found a few threads about doing this for audio, but they don't seem to work with a full swf? Basically I have a selection of swfs that load into targets and what I want to be able to do is have a button that either says 'stop this specific swf' then next time you click says 'play this specific swf', or, as they all play on their own frames one that says 'stop any external swfs' and then 'start any external swfs'. It sounds pretty simple, but for some reason nothing I've tried seems to work and the threads I've found asking the same thing have no responses?
Any help with this would realy be appreciated as I've spent all day messing about with it and still no luck..
Tom
How To Access Vars From Externally Loaded SWFs
Hey all,
Pretty much as stated. I have an FLA I'm working on, and I want to load several SWFs into it, with the paths being generated by a PHP page query, which spits out an XML file.
I got all this working just fine, but I can't quite get to the next step. There are some variables that reside in each of the SWFs that I need to get access to (reason being, I would like to have specific events happen based on which clip they are, but be controlled by the "MotherSWF"). So as I said, I have this all working, up until the point that I try to get the vars from the children (Imported SWFs). Tracing the var itself results in the whole "undefined property" mumbo jumbo, and trying to trace the var via the Loader simply returns "undefined". Here's the code (Note, I'm NOT classing this out at this point, as I'd rather learn the methods of how to do everything prior to trying to hotwire a bunch of classes right now. I think that's just opening up another can of worms, which I don't need to do at this point. More worms == more problems):
ActionScript Code:
stop();
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.xml.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.net.URLRequest;
var avatarBuilder_stage:Stage = this.stage;
var avatarBuilder = this;
var myResult:XML;
var testingNum:Number = 0;
var loadArray:Array = new Array();
var buildHolder:MovieClip = new MovieClip();
buildHolder.x = 410;
buildHolder.y = 150;
buildHolder.scaleX = 1.40;
buildHolder.scaleY = 1.40;
avatarBuilder_stage.addChild(buildHolder);
function LoadingXML() {
this.loadXML();
}
function loadXML():void {
var loader:URLLoader=new URLLoader();
loader.addEventListener(Event.COMPLETE,completeHandler);
var myRequest:URLRequest=new URLRequest("test/stephen/avatarBuilder/swfParser.php");
try {
loader.load(myRequest);
}
catch(error:Error) {
trace("unable to load requested URL");
}
}
function completeHandler(event:Event) {
var loader:URLLoader=URLLoader(event.target);
myResult=new XML(loader.data);
avatarBuilder.gotoAndStop("loaded");
}
function initMovie() {
var headHolder_mc:MovieClip = new MovieClip();
buildHolder.addChild(headHolder_mc);
headHolder_mc.x = 97;
headHolder_mc.y = 100;
var headLoader_mc:MovieClip = new MovieClip();
headHolder_mc.addChild(headLoader_mc);
var mouthHolder_mc:MovieClip = new MovieClip();
buildHolder.addChild(mouthHolder_mc);
mouthHolder_mc.x = 98;
mouthHolder_mc.y = 134;
var mouthLoader_mc:MovieClip = new MovieClip();
mouthHolder_mc.addChild(mouthLoader_mc);
var noseHolder_mc:MovieClip = new MovieClip();
buildHolder.addChild(noseHolder_mc);
noseHolder_mc.x = 96;
noseHolder_mc.y = 104.1;
var noseLoader_mc:MovieClip = new MovieClip();
noseHolder_mc.addChild(noseLoader_mc);
var eyesHolder_mc:MovieClip = new MovieClip();
buildHolder.addChild(eyesHolder_mc);
eyesHolder_mc.x = 97;
eyesHolder_mc.y = 67.5;
var eyesLoader_mc:MovieClip = new MovieClip();
eyesHolder_mc.addChild(eyesLoader_mc);
var hairHolder_mc:MovieClip = new MovieClip();
buildHolder.addChild(hairHolder_mc);
hairHolder_mc.x = 97.5;
hairHolder_mc.y = 80;
var hairLoader_mc:MovieClip = new MovieClip();
hairHolder_mc.addChild(hairLoader_mc);
loadArray.push(noseLoader_mc);
loadArray.push(headLoader_mc);
loadArray.push(hairLoader_mc);
loadArray.push(mouthLoader_mc);
loadArray.push(eyesLoader_mc);
for (var i:Number=0;i<loadArray.length;i++) {
loadPiece(i);
}
//avatarBuilder.gotoAndStop("allContentLoaded");
}
function loadPiece(i) {
var mcl:Loader = new Loader();
var tempClip:MovieClip = loadArray[i];
var loadURL:String = myResult.swfPath.(@id==i).piece.(@id=="0").path;
var loadURLReq:URLRequest = new URLRequest(loadURL);
mcl.load(loadURLReq);
mcl.contentLoaderInfo.addEventListener(Event.COMPLETE,initImage);
function initImage(event:Event) {
trace(mcl.content); //returns [object MainTimeline]
var loadedClip:MovieClip = new MovieClip();
tempClip.addChild(mcl);
switch (i) {
case 0 :
tempClip.x = -25;
tempClip.y = -25;
break;
case 1 :
tempClip.x = -100;
tempClip.y = -100;
break;
case 2 :
tempClip.x = -140;
tempClip.y = -115;
break;
case 3 :
tempClip.x = -60;
tempClip.y = -37.5;
break;
case 4 :
tempClip.x = -60;
tempClip.y = -37.5;
trace(mcl.eyeNum); // This is where I have been trying to grab the var values...
//blinkInterval = setInterval(blink, 333);
break;
}
}
}
/////////////////////////////////////////////Load the XML file in the first frame////////////////////////////////////////////
LoadingXML();
So that's for the parent. This is for the child. They live in frame 1 of the SWF:
ActionScript Code:
var eyes1 = this; /*not sure if this will work, but I used to get around
complicated timeline pathing and having to load vars in from external SWFs
with an "_global.myTimeLine = this;" in the first frame. Then I could simply
access anything in that SWF by accessing the _global... But those are
gone... :( However, I want to see if something similar will work. If you have
a better/cleaner solution, I'm all ears on that too!! :D*/
var eyeNum:Number = 1;
Thanks in advance!
S
Properly Closing Externally Loaded SWFs
Hey,
Leading on from my previous post, how is the correct way to go about completely removing an externally loaded swfs?
I ran a test by having a simple SWF with a timer that runs every second, then another SWF that loads it up...
Code:
var thisRequest:URLRequest = new URLRequest("flash_1.swf");
var thisLoader:Loader = new Loader();
thisLoader.load(thisRequest);
stage.addChild(thisLoader);
So then once it loads up flash_1.swf and you see the traced messages popping up every second you then click a button in the main SWF and it runs the following code:
Code:
thisLoader.unload();
stage.removeChild(thisLoader);
thisLoader = null;
I thought that would remove the SWF from the scene, as the SWF vanishes from the stage, however the timer keeps ticking, so it is still using up resources behind the scenes... Do i have to wait for the GC to clean it up or is there a "correct" way to clean up after yourself?
Button Addressing In Externally Loaded Swfs
I have a swf loaded into a container swf that has buttons and various other interactive elements. I'm seem to be having issues with addressing. I can't get the buttons within these loaded swfs to work the way I want them to. How would addressing be handled in these situations? Any help in this regard is greatly appreciated.
AS3 - Stopping Sound In Externally Loaded SWFs
Hi folks...I've spent hours trying to solve this; to no avail.
I've built a Flash movie that demos a new website. The Flash movie loads 14 external SWF files, each of which contains a single narration sound clip.
I can get the external SWFs to load just fine, but when I load the next clip, the sound from the first clip keeps playing. I can use SoundMixer.stopAll();, but that has the unfortunate effect of also stopping my soundtrack, which plays in the main timeline of the container file.
I've heard there is a way to stop sounds contained in external SWFs, something about NetStream, but haven't been able to get it to work.
Complicating the matter: I can't edit the set of 14 external SWF files. Whatever solution I use must be implemented from the main container Flash file.
Can anyone help me with this? Here's a sample of the code I use to load in each SWF:
one_mc.addEventListener(MouseEvent.CLICK, go1);
function go1(myevent:MouseEvent):void {
myLoader.load(myRequest);
myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showContent);
}
And here is the preloader code I use:
function showPreloader(event:Event):void {
addChild(myPreloader);
myPreloader.x = stage.stageWidth/2;
myPreloader.y = stage.stageHeight/2;
}
function showProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
myPreloader.loading_txt.text = "Loading - " + Math.round(percentLoaded * 100) + "%";
myPreloader.bar_mc.width = 198 * percentLoaded;
}
function showContent(event:Event):void {
removeChild(myPreloader);
addChild(myLoader);
myLoader.x = 20;
myLoader.y = 155;
}
Thanks!!
Access Properties Of Externally Loaded Swfs?
Once an external swf is loaded onto my currently running swf using the Loader class:
1) Can the loaded swf access properties of the swf that loaded it?
2) Can the swf that perform the loading access properties of the loaded swf?
If any or both of the above is true, I would also appreciate a word or two about the process of access the other swf's properties/methods.
Thanks.
Externally Loaded .SWFs - Button 1 -> Movie 1
New question.
I understand the concept of the loadMovie() function. My issue now is that I've created several segments to the interface - The two I'll name here is A. the navigation movie which incorporates all my buttons and is loaded externally to the main movie and aligned accordingly with AS, B. the first movie I've created in a series of movies which has no other function than to look pretty and transition from photograph to photograph - also which is currently being loaded/positioned into the mainmovie directly under the navigation bars.
So my conundrum is now, how can I make button 1 call movie 1 when both are externally loaded and button 2 call movie 2, etc.? I became lost on a few AS tutorials that seemed to hint on how to make this happen, uncluding the Random Movies one I read on kirupa.com that doesn't seem to apply so much.
(please understand, the external loading effect will go hand in hand with a number of preloaders I plan to put into the site to direct the eye to each frame and basically individualize each piece of content as it appears)
Killing Processes In Externally Loaded SWFs
Hi,
I'm working on a page and I have found a little problem.
The splash page loads an external SWF containing a timed slideshow. When I unload that SWF and load a new one, the timer still loads images in the background.
Is there a way to kill all processes of an external SWF on unload??
Thanks
KD
Cross Fading Externally Loaded Swfs
Hey All,
I know this sounds similar to other posts. But, this is alittle different. I have used transitions between swfs where the first swf plays the intro, when the user clicks a button the first swf plays the 'outro' and loads the second swf intro. This not what I am looking for. I want the swfs to cross fade. I was thinking of using different layers. I have found a tutorial that seems to work but the action is on a button that loads the next swf in the array. I want to be able to pick any swf and have it cross fade with the one loaded in the holder.
Any Ideas? I will have at least 5 swfs to load.
//tutorial by Rich Shupe, FMA. http://www.fmaonline.com
/*
array of possible content to pick from. This article answered a question about swapping loaded SWF files with a transition, but this technique will also work with jpgs, without having to make swf files from them.
*/
swfArray = new Array("red_bird.swf", "chinatown_dragon.swf", "working_beast.swf");
//create two MovieClips that will hold the loaded files
this.createEmptyMovieClip("target1", 1);
this.createEmptyMovieClip("target2", 2);
//load first movie into clip 1 to start with the first image
target1.loadMovie(swfArray[0]);
//set clip2 alpha to zero so it can fade in
target2._alpha = 0;
//variables that store current clip and current content index
activeTarget = target1;
currentIndex = 0;
/*
movie-level enterFrame event handler that will fade down object 1 (if it's alpha is higher than zero), and fade up object 2 (if it's alpha is less than 100)
*/
this.onEnterFrame = function() {
if (obj1._alpha>0) {
obj1._alpha -= 10;
}
if (obj2._alpha<100) {
obj2._alpha += 10;
}
//enable trace to watch memory used by each loaded movie. this will illustrate the
// benefits of unloading the faded movie.
//trace("clip1: " + clip1.getBytesTotal() + " clip2: " + clip2.getBytesTotal())
};
//button script that swaps load target focus and loads the next movie
nextButton.onRelease = function() { // I want to put the action on individual buttons
//toggles values of object 1 and 2 between clip 1 and clip 2
if (activeTarget == target1) {
obj1 = target1;
obj2 = activeTarget=target2;
} else {
obj1 = target2;
obj2 = activeTarget=target1;
}
//assigns content of object 2 as next item in the content array, unless the
// end of the array has been reached. in this case start over at first item
if (currentIndex<swfArray.length-1) {
currentIndex++;
} else {
currentIndex = 0;
}
//load content into second clip
obj2.loadMovie(swfArray[currentIndex]);
//to reduce possible RAM and performance overhead, add an onEnterFrame
// event handler to object 1 to unload it once it has faded out.
//once the movie has unloaded, delete the onEnterFrame event handler
// to prevent future loads from unloading.
obj1.onEnterFrame = function() {
if (this._alpha<=0) {
this.unloadMovie();
delete this.onEnterFrame;
}
};
};
Controlling Intances Through Externally Loaded Variables
Hello,
I would like to put a number of "lights" into a movie. The lights have to positions (on/off), and are converted to movieclip symbol. Various instances of this symbol are put on to the stage.#
I would like to control those lights (whether they are on or off) through an external txt file. The textfile has one boolean variable for each instance (e.g. vlight1=true).
On the each instance is following script:
onClipEvent (load) {
if (_root.vlight1 == true) {
tellTarget (this) {
gotoAndStop(5);
}
} else {
tellTarget (this) {
gotoAndStop(1);
}
}
}
...but it doesn't work!
I also tried with instead of tellTarget, but that did not work either.
I tested the variable in a textfield and it seemed to have read the variable alright (the txt file is loaded through loadVariablesNum("variables.txt", 0).
Anyone got an idea how to do this?
Thank you for your help!
Controlling Main Timeline Through Externally Loaded Swf
I'm missing something...here's the setup:
navbar.swf (a navigation window) loads into the main timeline, placed into a container called navguide. There are buttons in navbar.swf that I want to control the main timeline, moving it from section to section of the main site (button called "newsbutton" should move the playhead to a News section this time, which is placed on frame 5). The code I have in the main timeline so far is this (on frame 1, _root timeline):
Code:
stop();
loadMovie("scoreboard.swf", scoreboard);
loadMovie("navbar.swf", navguide);
navguide.newsbutton.onPress = function(){
_root.gotoAndStop(5);
}
No blatant typos, as far as I can find, because the effects on the newsbutton (loaded from navbar.swf) work fine. But when I click the newsbutton, nothing happens. What am I missing?
Controlling An Externally Loaded Components Properties
Hi all...
I am having some difficulty figuring out how to control a component's properties in actionscript in an external swf.
Is this possible (ie. in movie A could i load a movie B with a scrollpane, say named "component_mc" , and in Movie A use actionscript to specify setSize or setScrollContent) ????
Specifically i am using the MultiOutlet component (a component that allows you to store multiple resources such as graphics etc. like a shared library, but also with components so you don;t have to reload them each time but share them)
The multioutlet component works fine (get it at http://www.flashcomponents.net)
loading the scrollpane, but i cannot figure out the syntax or where i should put the actionscript in the movie containing the multioutlet component (not the scrollbar movie/library which the component loads) to dynamically change the component's properties...
Please help! Thanks
-aleks
Controlling An Externally Loaded Components Properties
Hi all...
I am having some difficulty figuring out how to control a component's properties in actionscript in an external swf.
Is this possible (ie. in movie A could i load a movie B with a scrollpane, say named "component_mc" , and in Movie A use actionscript to specify setSize or setScrollContent) ????
Specifically i am using the MultiOutlet component (a component that allows you to store multiple resources such as graphics etc. like a shared library, but also with components so you don;t have to reload them each time but share them)
The multioutlet component works fine (get it at http://www.flashcomponents.net)
loading the scrollpane, but i cannot figure out the syntax or where i should put the actionscript in the movie containing the multioutlet component (not the scrollbar movie/library which the component loads) to dynamically change the component's properties...
Please help! Thanks
-aleks
Controlling An Externally Loaded Components Properties
Hi all...
I am having some difficulty figuring out how to control a component's properties in actionscript in an external swf.
Is this possible (ie. in movie A could i load a movie B with a scrollpane, say named "component_mc" , and in Movie A use actionscript to specify setSize or setScrollContent) ????
Specifically i am using the MultiOutlet component (a component that allows you to store multiple resources such as graphics etc. like a shared library, but also with components so you don;t have to reload them each time but share them)
The multioutlet component works fine (get it at http://www.flashcomponents.net)
loading the scrollpane, but i cannot figure out the syntax or where i should put the actionscript in the movie containing the multioutlet component (not the scrollbar movie/library which the component loads) to dynamically change the component's properties...
Please help! Thanks
-aleks
Externally Loaded SWFs Display Objects Outside Their Border
I have a MC on my master SWF that's say, 500x300 pixels. I'm loading other SWFs into this MC, and I noticed that, if the loaded SWF has objects that move off the stage during the course of its animation, then those objects are visible outside the boundary of my placeholder MC on the master SWF. Why in the world would that happen? How do I prevent it?
Syncing Sound In Multiple Externally-loaded Swfs
hey ho peeps,
i need your advice.....
i'm making a sound toy at the mo, and i've got three blocks in a horizontal line, that each load in a choice mini swf from 33.
Each of the 33 plays a different audio-visual loop when clicked. on clicking on one of the blocks to load in a swf from the 33, i need it to wait for the others (if they've already been clicked on and something's subsequently been loaded in and started playing), to come to the start of the loop before it starts to play. each mini swf will prelaod on click, so after this it then needs to queue up to wait for the next point to start playing. this will be every 2000ms or so. Imagine the swf waiting for the next bus to come along, to hop on to join his/her other two swf friends, if you would (if they're on the bus at this point).
I know setInterval is notoriously bad at accurately calculating loop lengths on different pcs/macs of different processor power, so onSoundComplete seems like the best bet, though the code for each sound is set in each mini swf, where each's library mp3 loop is stored and attached from.i think this might be an issue?
here's the structure:
blockHolder.swf
blockA.swf
mini1.swf...
mini33.swf
blockB.swf
mini1.swf...
mini33.swf
blockC.swf
mini1.swf...
mini33.swf
i've checked Franky B's bits which, though they're very informative, i'm not sure of how specific they are to this issue..
any help would be much appreciated.
thanks boys and girls
khav
Externally Loaded SWFs Make Movie Slower
I'm having a weird problem with some externally loaded SWFs that contain only audio. They were created with Squeeze 4.3.
When I load them into my movie they drastically slow down the animation of the entire movie. As soon as I stop the audio in the external SWF the rest of the movie's animation goes back to normal. But if I start the SWF again it slows down again.
My questions are:
- Is anyone else encountering the same problem with audio only SWFs?
- Does anybody have any advice on publishing settings for the audio SWFs that may fix the "slow down"? Or any other methods for publishing audio only SWFs?
|