Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Unloading A Variable Help Needed



Hi,

I need some help unloading a variable when you click on a button and I need to know what to add to the button (on press) to unload the variable. heres my script:


myVar = "home.swf";
function loadFunction(movie) {
loaderClip.loadMovie(movie);
trace(movie+" is loaded");
}
// names of clips loaded
myClips = ["section1.swf", "section2.swf", "section3.swf", "section4.swf"];
for (var n = 0; n<4; n++) {
var fakeName = this["but"+n];
fakeName.myNum = n;
fakeName.onPress = function() {
_root.animationClip.play();
myVar = myClips[this.myNum];
};
}


and here is the script that loads the variable:
stop();
_root.loadFunction(_root.myVar);



FlashKit > Flash Help > Flash MX
Posted on: 01-09-2004, 03:35 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Unloading A Variable, Help Desperately Needed.
Hi,

I need some help unloading a variable when you click on a button and I need to know what to add to the button (on press) to unload the variable. heres my script:


myVar = "home.swf";

function loadFunction(movie) {

loaderClip.loadMovie(movie);

trace(movie+" is loaded");

}

// names of clips loaded

myClips = ["section1.swf", "section2.swf", "section3.swf", "section4.swf"];

for (var n = 0; n<4; n++) {

var fakeName = this["but"+n];

fakeName.myNum = n;

fakeName.onPress = function() {

_root.animationClip.play();

myVar = myClips[this.myNum];

};

}


and here is the script that loads the variable:
stop();

_root.loadFunction(_root.myVar);

Unloading XML / Clearing Array / Scope? - Help Needed
Hey Everyone.

I'm modifying an xml/mp3 player i built to load different song libraries.
Basically it's for a personal site, and I want it to be able to load different projects I've worked on.

My problem is: I can load a different xml easily, but no matter how I go about it, it always appends the new songs instead of clearing the xml being played and loading the new one.
IE the new songs show up AFTER the ones currently loaded.

I've searched this forum and found a lot of useful stuff, but nothing seems to work in this particular example. I know graylensman sorted it out with populated buttons and so forth, but nothing seems to work for me.

I've tried clearing my nodes array ( nodes.splice(0); ), declaring it again ( var nodes:Array = new Array(); ) and declaring my xml object again to wipe it clean, so to speak.
But nothing works.

Here's the code:


Code:
// load XML
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{
sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.artist, nodes[i].attributes.title, nodes[i].attributes.album));
}
playSong();
}
xml.load("songs.xml");

// playSong function
function playSong():Void {
s = new Sound();
s.onSoundComplete = playSong;
if (cps == sa.length - 1) {
cps = 0;
s.loadSound(sa[cps].earl, true);
} else {
s.loadSound(sa[++cps].earl, true);
}
new Tween(title_text, "_alpha", Strong.easeOut, 0, 100, 80, false);
new Tween(album_text, "_alpha", Strong.easeOut, 0, 100, 80, false);
title_text.text = sa[cps].title;
album_text.text = sa[cps].album;
}
The main xml being loaded and the "playSong" function.

Then I have a button to load the new library:


Code:
this.pris_btn.onRelease = function() {
nodes.splice(0);
pris_xml();
new Tween(sc_btn, "_y", Strong.easeOut, -73, 77, 40, false);
new Tween(pris_btn, "_y", Strong.easeOut, 20, 77, 40, false);
new Tween(bel_btn, "_y", Strong.easeOut, -31, 77, 40, false);
new Tween(misc_btn, "_y", Strong.easeOut, -10, 77, 40, false);
new Tween(sc_btn, "_alpha", easeOut, 80, 0, 40, false);
new Tween(pris_btn, "_alpha", easeOut, 80, 0, 40, false);
new Tween(bel_btn, "_alpha", easeOut, 80, 0, 40, false);
new Tween(misc_btn, "_alpha", easeOut, 80, 0, 40, false);
}

function pris_xml() {
var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{ sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.artist, nodes[i].attributes.title, nodes[i].attributes.album));
}
playSong();
}
xml.load("priscilla_songs.xml");
}
I'm thinking it could be a scope problem. I've tried clearing the nodes array in various places, but nothing works.
Or in a worst case scenario - it's the 'push' method that's pushing the new attributes into the array.

If anyone can help me, or point me in the right direction, I will be most grateful.

I really don't know where to go from here.

Problem With A Variable And Unloading Movies
Hi people,

I have a problem which I am sure is very basic, but it is complex to explain. I will try my best to explain what I am doing:

I have 6 buttons in a movieclip in my main timeline. Each button loads a different movie clip into a different container movie clip located in the main timeline. Each container is named cont1, cont2, cont3, etc...
The reason why I use one container for each movie I load, is because, I need the movies I load to overlap, for a few seconds, from the moment I click on the button and the movie starts loading, until it has finished loading (this might not seem clear but is very basic) .

So what I am doing is the following. When I press on a button, it sets a variable called "pancho" to either value 1 through 6. this is the script on a button:

on (release) {
_parent.seccion = "contact";
_parent.pancho = 6;
loadMovie("mkd_contact.swf", "_parent.cont6");
_parent.gotoAndPlay("prepare");
}

ok.....now in the main timeline, i have a preloader for this which works fine.... my movies load perfectly ok...... my problem is that when I have already loaded 1 movie into its container mc, and when i click to load another one, after a while, I need to reset the mc i previously loaded, and somehow i cannot do this. When I debug the movie and check the value for pancho, after the mc has loaded, it changes to 5, don;t understand why???? since the value for pancho is messed up, i have trouble telling the mcs i have loaded to stop or to go to blank frames. I need a solution to this, since i end up having many mcs loaded, so this takes up too much memory.

I do have a script in the main timeline after the mc loads, that tells the mc i am loading to start, and the only connection I see is that I mess with the if statement with the pancho variable = 5 at the end, i this script:

if (pancho=3) {
cont3.gotoAndPlay(2);
cont1.gotoAndPlay("nada");
cont2.gotoAndPlay("nada");
cont4.gotoAndPlay("nada");
cont5.gotoAndPlay("nada");
cont6.gotoAndPlay("nada");

}
if (pancho=2) {
cont2.gotoAndPlay(2);
cont1.gotoAndPlay("nada");
cont3.gotoAndPlay("nada");
cont4.gotoAndPlay("nada");
cont5.gotoAndPlay("nada");
cont6.gotoAndPlay("nada");
}
if (pancho=1) {
cont1.gotoAndPlay(2);
}
if (pancho=6) {
cont6.gotoAndPlay(2);
}
if (pancho=4) {
cont4.gotoAndPlay(2);
}
if (pancho=5) {
cont5.gotoAndPlay(2);
}
home.gotoAndPlay("nada");


(i left out all the other actions telling the mcs to move to "nada" to not take up space)


anyone have any suggestions or answers to this?? I hope it is clear, it somehow seems to complex to explain why and what I am doing. Is there any way I can eliminate the movies I loaded before > I've tried unloading them but it didn't work.

Thanx a lot to anyone who can helP!!!!!!!!!!!!!!!!!!!!!!!

gRACIAS!!!!

Unloading Variable In Flash To Mp3 Player
Hi All,

Thank you so much for a community forum like this one. Ok this is the deal. I'm not program saavy so please be tender.

What I'm tyring to accomplish is having multiple drop down menus on a .htm pg which passes a song (the variable) to my embedded flash player which in turn plays the selected song. Ok so far I think I have a grip on the passing the variable thing (the code is below).

I've gotten confused because I know you have to unload the variable in FLASH but I'm lost in how you pass this variable to the player. I've been using this code to pass the variable:

loadMovie(_root.&sound);

but I keep getting this error in flash:
Scene=Scene 1, Layer=actions, Frame=1: Line 1: Expected a field name after '.' operator.
     loadMovie(_root.&sound);  

Please help.

So far this is my .htm

<html>
<head>
<script type="text/javascript">
function getVar(variable)
{
    document.getElementById('flash').innerHTML = '<object type="application/x-shockwave-flash" data="audioplayer.swf" width="200" height="200">
'
    +'<param name="movie" value="audioplayer.swf">
'
    +'<param name="FlashVars" value="&sound='+variable+'">
'
    +'</object>';
}
</script>
</head>
<body>
<form action="#" method="post">
    <select name="menu" onChange="getVar(this.options[this.selectedIndex].value)">
        <option value="#">Play Demo</option>
        <option value="B01.wma">Bumper 1Demo</option>
        <option value="/music/bumpers/B02.wma">Bumper 2Demo</option>
    </select>
</form>
<div id="flash">
    <object type="application/x-shockwave-flash" data="audioplayer.swf" width="200" height="200">
        <param name="movie" value="audioplayer.swf">
        <param name="FlashVars" value="&sound=#">
    </object>
</div>
</body>
</html>

FLASH:
loadMovie(_root.&sound);

Problem With A Variable And Unloading Movies
Hi people,

I have a problem which I am sure is very basic, but it is complex to explain. I will try my best to explain what I am doing:

I have 6 buttons in a movieclip in my main timeline. Each button loads a different movie clip into a different container movie clip located in the main timeline. Each container is named cont1, cont2, cont3, etc...
The reason why I use one container for each movie I load, is because, I need the movies I load to overlap, for a few seconds, from the moment I click on the button and the movie starts loading, until it has finished loading (this might not seem clear but is very basic) .

So what I am doing is the following. When I press on a button, it sets a variable called "pancho" to either value 1 through 6. this is the script on a button:

on (release) {
_parent.seccion = "contact";
_parent.pancho = 6;
loadMovie("mkd_contact.swf", "_parent.cont6");
_parent.gotoAndPlay("prepare");
}

ok.....now in the main timeline, i have a preloader for this which works fine.... my movies load perfectly ok...... my problem is that when I have already loaded 1 movie into its container mc, and when i click to load another one, after a while, I need to reset the mc i previously loaded, and somehow i cannot do this. When I debug the movie and check the value for pancho, after the mc has loaded, it changes to 5, don;t understand why???? since the value for pancho is messed up, i have trouble telling the mcs i have loaded to stop or to go to blank frames. I need a solution to this, since i end up having many mcs loaded, so this takes up too much memory.

I do have a script in the main timeline after the mc loads, that tells the mc i am loading to start, and the only connection I see is that I mess with the if statement with the pancho variable = 5 at the end, i this script:

if (pancho=3) {
cont3.gotoAndPlay(2);
cont1.gotoAndPlay("nada");
cont2.gotoAndPlay("nada");
cont4.gotoAndPlay("nada");
cont5.gotoAndPlay("nada");
cont6.gotoAndPlay("nada");

}
if (pancho=2) {
cont2.gotoAndPlay(2);
cont1.gotoAndPlay("nada");
cont3.gotoAndPlay("nada");
cont4.gotoAndPlay("nada");
cont5.gotoAndPlay("nada");
cont6.gotoAndPlay("nada");
}
if (pancho=1) {
cont1.gotoAndPlay(2);
}
if (pancho=6) {
cont6.gotoAndPlay(2);
}
if (pancho=4) {
cont4.gotoAndPlay(2);
}
if (pancho=5) {
cont5.gotoAndPlay(2);
}
home.gotoAndPlay("nada");


(i left out all the other actions telling the mcs to move to "nada" to not take up space)


anyone have any suggestions or answers to this?? I hope it is clear, it somehow seems to complex to explain why and what I am doing. Is there any way I can eliminate the movies I loaded before > I've tried unloading them but it didn't work.

Thanx a lot to anyone who can helP!!!!!!!!!!!!!!!!!!!!!!!

gRACIAS!!!!

Variable Help Needed
I am trying to get one movieclip to set and change another movie clip's variable. How do I do this? I've tried tellTarget, set variable, but it doesn't seem to work.

VARIABLE HELP NEEDED
Is there a way to make a button change the name of a variable. like if the variable was named "page_1" and I wanted it to be "page_2" when the button is clicked.

Variable Help Needed
Okay so im making variables in a scene and they are being displayed in a text box.

i.e. var cash = 0;

I have like a "status" panel with such things as life, cash, etc. The variables are displayed and work fine within the scene they are declared. However when I go to a different scene the variables display different in the text box when the movie plays.

i.e. _level0.cash

I know this is probably easy to fix so does anyone have any guidance? Thanks a ton!

VARIABLE HELP NEEDED
hi am am tryin to make a button set a variable. the other button sets the variable to "release2"

on (release) {
set (releasechoice, "release1");
_root.sections.gotoAndStop(85);
_root.logomovie.gotoAndStop(12);
}

this variable "releasechoice" is used to determine which movie clip should load.

stop();

if ($_GET['releasechoice'] == release2) {
_root.sections.contents.loadMovie("flashbin/CSI_release2.swf");
}

else if ($_GET['releasechoice'] == release1) {
_root.sections.contents.loadMovie("flashbin/CSI_release1.swf");
}

else {
_root.sections.contents.loadMovie("flashbin/CSI_news1.swf");
}


for some reason this isnt working.. its like it remembers what the value of the variable is.. or it doenst even use the if statement. it just loads only one movie clip no matter what the variable is. i have tried to delete the variable before i set it again but it doesnt work.

i have had a huge hard time tryin to get this to work. it seems so simple. i have tried the "switch" method instead and no luck.

please help

thanks.

jon

VARIABLE HELP NEEDED
hi am am tryin to make a button set a variable. the other button sets the variable to "release2"

on (release) {
set (releasechoice, "release1");
_root.sections.gotoAndStop(85);
_root.logomovie.gotoAndStop(12);
}

this variable "releasechoice" is used to determine which movie clip should load.

stop();

if ($_GET['releasechoice'] == release2) {
_root.sections.contents.loadMovie("flashbin/CSI_release2.swf");
}

else if ($_GET['releasechoice'] == release1) {
_root.sections.contents.loadMovie("flashbin/CSI_release1.swf");
}

else {
_root.sections.contents.loadMovie("flashbin/CSI_news1.swf");
}


for some reason this isnt working.. its like it remembers what the value of the variable is.. or it doenst even use the if statement. it just loads only one movie clip no matter what the variable is. i have tried to delete the variable before i set it again but it doesnt work.

i have had a huge hard time tryin to get this to work. it seems so simple. i have tried the "switch" method instead and no luck.

please help

thanks.

jon

Variable Guru Needed
Hey Flasherz...Happy New Yeahz 2 yall.

OK. 1000 points goes to the person who can answer this action script question.

I have a site I built in scenes. It takes too long to preload. So I advised to brake up all the scenes, and Pages within those scenes into individual swf files.

//To easly understand the problem my site is up at www.forsite.co.nz

My problem is...:

Each section of my site eg "about us", "work", "services" ect has a unique animation.swf

for eg..."about us" has three buttons "what, where or who"

If the "what" button is hit I want "animation.swf" and "what.swf" to play.
"animation.swf" should play only ONCE and stop on the last frame so if one of the other two buttons is hit "animaion.swf" will stay on the last frame... Until another button in another section is activated.

pretty sure I should be using an "if" action...
but have had no joy so far.
Big ups for any help.

Variable Advice Needed
You'd think i'd know this by now... anyway, i'm making a game whose game variables change depending on the round (let's say during round 2, var timer2 = 100, during round 3, var timer3 = 140) i have numerous variables that will change like this.

So ok, i have an MC that at the beginning of the round finds out what round we're in (let's say var theRound = 3; for the example) I want to set the generic variable "timeRemaining" to the value of "timer3" using "theRound"

so how do i do this? I'm imagining something like:

timeRemaining = "timer" + (theRound)

am i close? thanks.... ku (C8;

Variable Question, Quick Help Needed
Alright, I am making a space shooter and I want to script the paths the enemies travel in. I have 3 formations set up, path1, path2, path3. They are all array with coordinates inside of them. I have a function in the root that creates a ship and gives it a formation, then I have code inside the ship:


Code:
path1 = [[130, -_height], [130, 160], [Stage.width-130, 160], [Stage.width-130, Stage.height+halfHeight]];
path2 = [[Stage.width-130, -halfHeight], [Stage.width-130, 160], [Stage.width/2, 160], [Stage.width/2, Stage.height+halfHeight]];
path3 = [[Stage.width-130, -halfHeight], [Stage.width-130, 160], [130, 160], [130, Stage.height+halfHeight]];
// this code doesn't work ----
_x = ["path"+formation][0][0];
_y = ["path"+formation][0][1];
// ---------------------------

Basic Help Needed With Setting Variable
Firstly, i'm very basic in my AS knowledge so be gently with me

I have a few mc's in my movie, that i want track with AS.

I'm attempting to set a variable on the 1st frame of my movie, and then have my MC's change this state as they are running.

example of the 1st frame set-up where 'think_text' is my variable, and 'closed' is it's starting condition.

think_text = "closed";

when my mc's run, i have another script in thier timelines that go like this

think_text = "open";


I want to track and evaluate the state of my mc's, so that buttons in my movie know if they are open or closed. So i have this script on my button

button.onPress = function() {
if (think_text == open) {
_root.think_text_mc.gotoAndPlay("think_close");
} else {
_root.think_text_mc.gotoAndPlay("think_start");
}
}



now, all this may well be rubbish, and i'm barking up the wrong tree. If so, could one of you kind people let me know where the right tree may be.

cheers
chunk

Little Help Needed (detecting Word In A Variable)
I need to know if there is a way to detect a particular word in a variable.
For eg.

sentence= "grass is green"
2ndsentence="grass makes me high"

Now from the 2 variables i need to detect if the word "green" is present. Is there anyway of doing this with if/else statements?

I was thinking of trying "if(sentence<>grass)" but im not sure if that will work.
Anyone who can help me?
Thanks

Simple Variable Load Explanation Needed
Okay I'm having troubles loading variables.

Now I understand how to load variables from a text file, and all that.

Here is what I'm making - a birthday page where someone arrives at the following url

index.php?email=some@email.com&id=5&fname=joe&pick up=1

Okay so in PHP im working with the following variables

$email, $id, $fname, $pickup

They work in the php page, also in that page I have a flash file that says HAPPY BIRTHDAY, and then has a dynamic text field called fname (with variable set to fname) - how the hell do I get my $fname variable into the flash file so it will display in the dynamic field?

Do I have to make the flash file load the variable from a separate page ? And if so how can I make the page send the right $fname back to flash !

Is a good solution to register $fname as a session variable in PHP, will that force flash to recognise it !

An easy step by step on loading variables without text files would be great - there MUST be some way of doing it!

I am using Flash MX

[FlashCS3]Help Needed - Loading Variable Text
Hi all,

Im doing a uni project - building my website in flash!
Im using actionscript 2.0, I'm not too experienced in this so excuse me if I use incorrect terminology.

Basically - my website has 5 links. Each time you click a link, the webpage is supposed to do an animation, and then load the information (txt file).

I've managed to code it, so that the txt file loads as soon the animation starts but I want it to load AFTER it finishes. Can anybody help?

I've used this

Code:
on (release) {
loadText = new LoadVars();
loadText.load("TEXT1.txt");
loadText.onLoad = function(success) {
if (success) {
// trace(success);
newsBox.html = true;
newsBox.htmlText = this.myNews;
}
};
}
I'm not sure if I've explained it thoroughly enough but if you are willing to help and I need to provide more information please let me know.
thanks in advance.

Complicated Variable Issue - Flash Jedi Needed
OK, I'm really hoping someone can help me figure out a way to do this.

It might help if you know PHP/MySQL but not necessary!

It's kinda complicated, so please bear with me. I'm hoping some flash jedi can help figure it out.

I'm loading in some variables from an external PHP file.

However, I don't know how many values will be coming in.

How can I reference these values? How can I use a value?

For instance, I'd like to store the values in an array or something of that nature, but to do so I'd like to do something like this:

Assuming that I know the number of values "count"

if (count >0) {

myValues[count] = "incoming variable name";
count = count - 1;

}

So if I know the name of the incoming variable, I'm set, that should do it.

Now I can format the variable so the come out like this:

value1 = whatever
value2 = whatever
etc.

But how do update the name of the variable where it says "incoming variable name"?

If I set up something where you had:
incoming = "value" add count;

then I'd guess that I'd get a series of "incoming" values like this:
value1
value2
etc.

but I'm assuming that then if I did:

myValues[count] = incoming;

instead of saving the value of "value1" I'd save the actual string "value1" instead of the variable's value.

Does this make sense?

How in the world do I reference a value, if I don't know how many are coming in?

In PHP you can get a buffer of values and then just loop through where each value in turn is $key, $value.

Can you do that in flash?

HELP NEEDED With Sorting Query String Into Variable Array?
Hi,
I need to sort a query string with a number of variables into an array of variables..

Here is the query string being sent to the swf file:

order.swf&LOCT0=bedroom&LOCT1=dwelling&LOCT2=kitch en&LOCT3=landing

Below is the script im using:

Location = new Array;
for (i=0; i<"LOCT"; i++) {
Location[i] = eval("LOCT"+i);

It doesnt work! what is wrong in my script??? Please help!

thanks,
Shahid

How To Change Color Of Dynamic Text Depending On Variable? Help Needed
I want to change the color of a dynamic text box depending on the variable's value.

For example, I have a dynamic text variable named "status1" which has a value that is loaded from a text file. If the value is "Yes" of status1, then I want to the color of status to be GREEN, if the value is "No", then I want to color to be RED.

Here is what I have right now (though it doesn't seem to work):

loadVariablesNum("data.txt", 0);
//THIS IS THE DATA INPUT FILE
if (status1 == "no") {
_root.status1.color = green;
}

Thanks.

[Flash8]Help Needed Variable Pass From Rollover Buttons To AS On Frame
Hi
I am creating a weather forecast in which i have to create many rollover buttons by which i can pass different value like "sanjose" which goes to path("http://61.16.10.25/_flash/sanjose.aspx") on layer 1 frame 1 which have the action script. below is working fine if i pass the whole path in feedURL, but dont know how to pass city name while rollover to AS


feedURL = "http://61.16.10.25/_flash/sanjose.aspx";

#include "scripts/content.as"
// fire event to display current weather conditions
dispatchEvent({type:"containerInit", target:this});
// when button is pressed, shift it's position
function btnPressed(btn) {
btn._x += 1;
btn._y += 1;
}
// when button is released, put it back
function btnReleased(btn) {
btn._x -= 1;
btn._y -= 1;
}

Unloading MCs
I can't figure out how to get the unload to work. The script is below for my button 'Info'. It loads the movie, but will not unload the one that is on the stage. These are MCs within MCs within MCs. There are piecs and placements within each MC, so as far as I can tell, they are all necessary.
The scripting below that (the setProperty() ) is what actually works (and I have obviously tried it without the setProp). So I can load the MC, and set the visibility to 0 when I want another MC on the stage, but cannot actually unload it. Am I doing something wrong? Or is this the only way to do it?

You can see this on my homepage: http://www.emotion7.com
Try clicking the 'Info' button, letting it load, then the
'Services' button to see what I mean.
Thanks.


on (release) {
loadMovie ("Information.swf", "_root.Text.TextInfo");
unloadMovie ("_root.Text.TextServices.Services.swf");
}
on (release) {
setProperty ("_root.Text.TextServices", _visible, FALSE);
setProperty ("_root.Abstract.Abstractcopy", _visible, FALSE);
}

Unloading Various
I've got about 11 different movies that are all loaded into different "emptyMovies" with variable names of container1, container2, container3, etc...

Is there a way that I can unload all these at the same time using the UnloadMovie action?

Thanks
ghjr

[][][][][][ <-- Unloading
is there any way of telling to unload whatever external swf is loaded into lets say, level 1?

Thanks in advance

Unloading Mc's
ok so I have got my images loaded up dynamically on my site, but they overlap each other. They are all being loaded into a container, but how do I tell them to replace one another, rather than layer?

http://www.markertphoto.com/flash.htm

Help Unloading A Swf Please
Hello everyone, im having problems closing/unloading a swf file loaded into an empty movie clip.
This script sets up the main movie components;
stop();
_root.createEmptyMovieClip("empty_scroll_mc", 10);
_root.empty_mc._x = 0;
_root.empty_mc._y = 0;
_root.empty_scroll_mc.loadMovie("scrolling_menu.sw f");
_root.createEmptyMovieClip("empty_mc", 1);
_root.empty_mc._x = 0;
_root.empty_mc._y = 0;
_root.empty_mc.loadMovie("pool_page.swf");
_root.createEmptyMovieClip("empty_popup_mc", 9);
_root.empty_popup_mc._x = 25;
_root.empty_popup_mc._y = 0;

The empty mc in question is the third one, empty_popup_mc.

The above script sets up the navigation and the stage.
'empty_mc' is the empty movie clip into which my main content pages (different swf's) are loaded into, depending on which button is clicked on the scrolling_menu.swf

ie; this is attatched to a button on the scrolling_menu.swf:
on (release) {
_root.empty_mc.loadMovie("gym_page.swf");
}

This loads the gym_page.swf, into the empty_mc i then have a button on the gym_page which loads the brochure_request.swf in the emty_popup_mc

on (release) {
_root.empty_popup_mc.loadMovie("brochure_request.s wf");
}

We now get to my main question, the button to unload the brochure_request.swf from the empty_popup_mc is on the brochure_request.swf

Hope that makes sense to you! I thought i had sussed paths but i im stumped on this one.
Can anyone help me write the script for the button that will unload the brochure_request.swf from the empty_popup_mc.

the site is here
The brochure request page can be found by clicking on the gym page, then the button on the right that says 'more details'
Thank you so much, this is the first time i have tried to unload something !

Unloading .flv
I have a main .swf file that loads another .swf file which contains a .flv video using the Media Playback component. Works great. Only problem is that, when I close the loaded .swf file containing the .flv, the audio still plays.... The entire screen goe's away, but the audio still remains. I've tried many differenct solutions on unloading certain things to no avail. any ideas? is there an unload .flv command? or maybe some kind of buffering issue? Thanks for any tips.

MX 2004 Pro.

Help With Unloading....
hey

i have a button in main.swf which loads a swf called 'morpher' into a target mc called 'morphLoad'. the code used is:


loadMovie("videos/morpher.swf", "morphLoad");


the movie plays fine but what i want it to do when it is over is to unload and then target a frame within main swf called 'goagain'

im guessin the code would go in the last frame of the loaded 'morpher' swf?

any help on how to achieve this would be very appreciated.

thanks alot,
james

SWF Unloading
Hi guys
i got a problem unloading a .swf, i have a long timeline with all the pages in it,at a certain frame i have loaded, a form.swf with loadmovienum and it works, but my prob is when i then go to other pages on the same time line the swf is still there in background i have tried unloadmovienum at the end of the page frame but then the movie does not load. i have no hair left please help,ooop 1 hair left sorry.

Unloading
Hi there

I was wondering if somebody would help me.I am trying to create a porfolio of my work to apply to uni.They need to see developmental work so i have created the "develpmental work" button as a movie clip.Once clicked on it will play and the rough sketches will be shown.I'm not to sure what the script woud be to unload the main timeline piece so that only the sketch is shown.

I will attach the file.It only works for the six piece along.
Thank you so much
Nadine

I don't know why it is not letting me upload the file

[F8] Help With Unloading
Ok I'll try and keep this simple I have a movieclip which randomly duplicates itself somewhere on the x value between 1 and 396, above the stage it then decends downwards using a separate movieclip that I have set up which runs though a series of frames moving the moviclip down 2px every frame, When it reaches the bottom of the screen I have a hit area covering the bottom of the stage, when it hits this I would like it to unload.

Plz Help.

[F8] Nut Unloading
Let me start by saying thank you in advance.

I have my main time line and on it I have an MC with an instance name of "skip_intro".

Inside that MC I have a button with the following AS:
on (release) {
_root.gotoAndStop("end");
_root.o_text.gotoAndStop("end");
_root.skip_intro.unloadMovie();
}

The problem is my "unloadMovie" isn't working.

Basically I want it so that when you click on the "button (MC "skip_intro"), it disappears off the stage. Why is my AS not working? I also tried:
this.unloadMovie();

Interestingly enough when you click it a second time it disappears... but I need it to work on the first click.

What am I doing wrong?

Again,

Thanks

Unloading
Basically I followed along with a tutorial about how to create a memory game in flash. The only issue I have is that I want to be able to unload the game once the user progresses past that part of my flash. I have tried fooling around with a couple unload functions and clear functions but I don't think I'm recognizing which variable/movie I need to have unloaded for the cards to actually go away!

A simple forceclear function to remove all actionscrpit would be very handy!

here's the code that is loaded into the frame...


Code:

Code:
// Gamefield settings

// EDIT HERE
card_w = 70;
card_h = 90;
card_wdistance = 17;
card_hdistance = 15;

// STOP EDIT
card_dw = card_w + card_wdistance;
card_dh = card_h + card_hdistance;
row_card = Math.floor((Stage.width - card_wdistance) / card_dw);
col_card = Math.floor((Stage.height - card_hdistance) / card_dh);
n_card = col_card * row_card % 2 == 0 ? col_card * row_card : (col_card - 1) * row_card;
imgs_n = n_card / 2;

// CENTER THE IMAGE IN THE CARD
centerImage = function(target){
target.front._visible = false
target.front.container._x -= target.front.container._width / 2
target.front.container._y -= target.front.container._height / 2
}
// ---------------------------------------------

empty = new Array();
function createCard(n, w, h) {
empty.push(n);
this.createEmptyMovieClip('card' + n, n);
with (this['card' + n]) {
lineStyle(0, 0x000000, 100);
beginFill(0x000099, 60);
moveTo(w / 2, 0);
lineTo(w / 2, h / 2);
lineTo(-w / 2, h / 2);
lineTo(-w / 2, -h / 2);
lineTo(w / 2, -h / 2);
lineTo(w / 2, 0);
endFill();
createEmptyMovieClip('front', 1);
front.createEmptyMovieClip('container', 2);
front.createEmptyMovieClip('backgr', 1);
with (front.backgr) {
moveTo(-w / 2, -h / 2);
lineStyle(0, 0x000000, 0);
beginFill(0x333333, 100);
lineTo(w / 2, -h / 2);
lineTo(w / 2, h / 2);
lineTo(-w / 2, h / 2);
lineTo(-w / 2, -h / 2);
endFill();
}
front.onEnterFrame = function() {
tot = this.container.getBytesTotal();
car = this.container.getBytesLoaded();
if (tot == car && tot > 200) {
this._parent._parent.centerImage(this._parent);
delete this.onEnterFrame;
}
};
}
}
selcards = [];
function placeImages() {
act_img = 0;
for (img = 0; img < imgs_n; img++) {
for (k = 0; k < 2; k++) {
act = Math.round(Math.random() * (empty.length - 1));
this['card' + empty[act]].img_id = act_img;
this['card' + empty[act]].front.container.loadMovie("imgs/img" + act_img + ".jpg");
this['card' + empty[act]].onRelease = function() {
this.rotateCard(0, 0);
this.enabled = false;
MovieClip.prototype.enabled = false;
};
empty.splice(act, 1);
}
act_img++;
}
}
MovieClip.prototype.rotateCard = function(v, i) {
this.operazione = v == 0 ? +0.1 : -0.1;
this.incremento = i == 0 ? 100 : 10;
selcards.push(this._name);
this.onEnterFrame = function() {
this.incremento += this.operazione;
this._xscale = (100 * Math.sin(this.incremento));
if (this._xscale > 0) {
this.front._visible = v == 1 ? false : true;
}
if (this._xscale >= 99) {
delete this.onEnterFrame;
selcards.length < 2 ? MovieClip.prototype.enabled = true : null;
v == 0 && selcards.length > 1 ? checkCards() : null;
}
};
};
function generateGameField(cards, distance, hdistance) {
Ypos = card_h / 2 + hdistance;
Xpos = card_w / 2 + distance;
for (c = 0; c < cards; c++) {
createCard(c, card_w, card_h);
if (c % row_card == 0 && c > 0) {
Ypos += this['card' + c]._height + hdistance;
Xpos = card_w / 2 + distance;
}
this['card' + c]._x = Xpos;
this['card' + c]._y = Ypos;
Xpos += this['card' + c]._width + distance;
}
placeImages();
}
generateGameField(n_card, card_wdistance, card_hdistance);

score = 0;
this.createTextField('punti', -1, 500, 380, 0, 0);
punti.autoSize = true;
punti.text = 0;
function checkCards() {
if (this[selcards[0]].img_id == this[selcards[1]].img_id) {
score++;
punti.text = score;
eval(selcards[0])._visible = eval(selcards[1])._visible = false;
} else {
eval(selcards[0]).rotateCard(1, 1);
eval(selcards[1]).rotateCard(1, 1);
eval(selcards[0]).enabled = eval(selcards[1]).enabled = true;
}
selcards = [];
MovieClip.prototype.enabled = true;
}

stop();
I don't really care how, but I need to find out any way to completely unload this game.... I'm pulling my hair out over this because it's probably so simple.

Maybe encapsulating all the code into an object and unloading the object? I don't understand much actionscript but I am an experienced coder..

SWF Unloading Bug.
Hey,

There's this unloading bug in as3 i've come upon. If i load a SWF i can't get the memory back in any way (that i've found atleast).

I've attached an example of the issue on the adobe bug list (here), but i was hoping anyone has come upon any workaround for it in any way.

So, if anyone've seen anything please give a shout out here!

Thanks!

/bob

Help Unloading .swf
I'd been running searches all over Google all day today, but to no avail.

So I've created a gallery for my portfolio. The main splash page is an swf, and from within, it calls my graphic design, illustration, sculpture and motion art portfolios(which are also .swf files). The graphic design and sculpture portfolios load fine, but in order to return to the main page I need to unload whichever video is presently on top or active. Here is an example of the Graphic design clip as it is loaded.



ActionScript Code:
stop();

var GDloaded_clip:Loader = new Loader();

stage.addChild(GDloaded_clip);
GDloaded_clip.contentLoaderInfo.addEventListener( Event.INIT, handleInitGD);
GDloaded_clip.load( new URLRequest( "GD_Gallery.swf" ) );


function handleInitGD(evt:Event):void
    {
    var extMovie:* = GDloaded_clip.content;
    extMovie.x = 13;
    extMovie.y = 92;
    }

Here is my logo button, which returns to the home page.


ActionScript Code:
Logo.addEventListener(MouseEvent.CLICK, clickLogo);
function clickLogo(event:Event):void
{
   
    GDloaded_clip.parent.removeChild(GDloaded_clip);
    SCloaded_clip.parent.removeChild(SCloaded_clip);
    gotoAndStop("Home");
}

I only have 2 galleries created at the moment(Sculpture-SCloaded_Clip and Graphic Design- GDloaded_clip) but I would like to iron out the current problem. Right now if i click the logo to return from a gallery, i get the following error because there is nothing loaded for it to unload (i think)

Error #1009: Cannot access a property or method of a null object reference.

I have no real useful knowledge of actionscript, and most of what I have done has been through tutorials and modifications of code. I think I need to write an if() statement to check and see what is currently loaded. Once I can figure this out I can modify it for the rest of the site. Any help would be very appreciated.

-Aelx

Help Unloading .swf
I can't figure this out, I think i'm trying to remove the child to early. anyways, heres my code without any attempt to remove the child. thank you very much people at actionscript!


ActionScript Code:
stop();
about.buttonMode = true;
contact.buttonMode = true;
portfolio.buttonMode = true;

var request:Loader = new Loader();

about.addEventListener(MouseEvent.ROLL_OVER, overAbout);
about.addEventListener(MouseEvent.ROLL_OUT, outAbout);
about.addEventListener(MouseEvent.MOUSE_DOWN, downAbout);
function overAbout(MouseEvent):void{
    about.gotoAndPlay(2);
}
function outAbout(MouseEvent):void{
    about.gotoAndStop(1);
}
function downAbout(MouseEvent):void{
   
var request:Loader = new Loader();
request.load(new URLRequest ("AboutMe.swf"));
request.x = 0;
request.y = 0;
addChild(request)
gotoAndStop(2);

}



portfolio.addEventListener(MouseEvent.ROLL_OVER, overPortfolio);
portfolio.addEventListener(MouseEvent.ROLL_OUT, outPortfolio);
portfolio.addEventListener(MouseEvent.MOUSE_DOWN, downPortfolio);

function downPortfolio(MouseEvent):void{

        var request:Loader = new Loader();
        request.load(new URLRequest ("Portfolio.swf"));
        request.x = 0;
        request.y = 0;
        addChild(request)
    gotoAndStop(2);
}

function overPortfolio(MouseEvent):void{
    portfolio.gotoAndPlay(2);
}
function outPortfolio(MouseEvent):void{
    portfolio.gotoAndStop(1);
}

contact.addEventListener(MouseEvent.ROLL_OVER, overContact);
contact.addEventListener(MouseEvent.ROLL_OUT, outContact);
contact.addEventListener(MouseEvent.MOUSE_DOWN, downContact);

function downContact(MouseEvent):void{
var request:Loader = new Loader();
request.load(new URLRequest ("Contact.swf"));
request.x = 0;
request.y = 40;
addChild(request)
gotoAndStop(2);
}

function overContact(MouseEvent):void{
    contact.gotoAndPlay(2);
}
function outContact(MouseEvent):void{
    contact.gotoAndStop(1);
}

Help With Unloading .swf
I'm close to the effect I want, but I can't get the some of the stuff to unload when clicking to different area's throughout the project, (.swf's). On the main page, it's going to be identical to the rest of the site except for a few different elements, how do I get the .swf's your currently on to disapear so it doesn't go into the rest of the .swf area's, ie: new's/annoucements, etc.

you can preview what I'm asking for at our site, http://www.edni.net/site/

The news/annoucements doesn't dispear when clicking to different sections. can someone help me out, I'd greatly appreciate it.

Unloading FLV's Help
hello. here is my situation:

please read on, i tried to make it and easy read...

i have a 2 buttons that have this code on them:

on (release) {
stopAllSounds();
unloadMovieNum("50.swf", 50)
unloadMovieNum("50.swf", 51)
loadMovieNum("

Should I Be Unloading Mcs?
Hello,

I have an online test in Flash. It is basically working ok, but it is not reliable 100% of the time. The movie has 6 sections, the first 4 use quite a few audio files. I preload all of the audio (external mcs) in the beginning of the movie, while the user is reading an instruction page. I have a preloader to do this. Some problems that are occurring:

Occasionally, the preloader stops at a percentage and will not load any more. Doesn't seem to happen very often.
Sometimes, when the user gets to section 5 of 6, for example, there are no images displayed. It has also frozen at the beginning of other sections. Yet it works fine for 90% of the other people. It's almost as if all of the data did not get preloaded correctly.

I am wondering why there is this inconsistent behavior with the same movie? One thing is I do not 'unload' any of the mc's I preload. As a general rule of thumb, should one be unloading mc's as soon as they are no longer needed in the movie?

I decided to preload all of the audio files at the beginning because once the test starts, I did not want the user to have to wait to load data. Is this a bad idea? Perhaps I should be loading at the start of each section? Would that make it play more reliably.

Any suggestions would be much appreciated!

Unloading AS3
I have loaded an external movieclip into another on the stage. I would like to have a button that is in the loaded movie clip that unloads that loaded swf. Problem is that I cant have Mouse event listener on that button to call a function on the main stage. My guess is having to use event Dispatcher but not sure how to implement it.

What would be the best way to do this?





























Edited: 11/15/2007 at 11:46:04 AM by arandlett

Unloading Flv's
Hello.

I have a home page that loads several flv's. I am also trying to give the user the ability to view the page without video. When the user clicks a button on the home page, it sets a cookie that reloads the page with a different swf file that does not contain any flv's. However, since it takes a second or two for the cookie to be read, the initial swf has started loading, and even though the entire swf is swapped out with the "video-less" swf, those original flv's continue to load in the background, slowing everything down even though the user wants no part of the video. Any ideas how to solve this?

fyi, another feature of the home page shares a similar problem. The user is to select one of 3 "personal assistants" who will be their guide through the rest of the site. Once they've selected, another cookie is set. Each time they return, the initial swf checks for a cookie, and then displays a static image of the character they have selected. At this point, I am also trying to "unload" all of the swfs, but they still load in the background. I have tried both "unloadMovie(movieName);" and "stream_ns.Clear();".

the site may be seen here:

First Entertainment Credit Union »

Thanks in advance!

Unloading Flv's
Hello.

I have a home page that loads several flv's. I am also trying to give the user the ability to view the page without video. When the user clicks a button on the home page, it sets a cookie that reloads the page with a different swf file that does not contain any flv's. However, since it takes a second or two for the cookie to be read, the initial swf has started loading, and even though the entire swf is swapped out with the "video-less" swf, those original flv's continue to load in the background, slowing everything down even though the user wants no part of the video. Any ideas how to solve this?

fyi, another feature of the home page shares a similar problem. The user is to select one of 3 "personal assistants" who will be their guide through the rest of the site. Once they've selected, another cookie is set. Each time they return, the initial swf checks for a cookie, and then displays a static image of the character they have selected. At this point, I am also trying to "unload" all of the swfs, but they still load in the background. I have tried both "unloadMovie(movieName);" and "stream_ns.Clear();".

the site may be seen here:

First Entertainment Credit Union »

Thanks in advance!

Unloading A SWF
I have a Menu swf file that I load another swf file with the following code stright from the help file:

var request:URLRequest = new URLRequest("riskTaking.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);

This works fine but now I need to remove this SWF file when the user clicks on a Main Menu button in the loaded SWF file. I can't see any linkage to the Main SWF in the debugger. Any suggestions?

Thanks ahead of time.

UNLOADING SWF
Can anyone offer any advice on how to unload swfs that have been loaded into a host SWF.


For eaxmple i have my main movie and am loading an external swf into it
this works fine however when i try to close it with another button in the main movie,
I get this error message

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@2cf8101 to flash.display.Loader.
at VirtualSynthPiano_fla::MainTimeline/unloadFunction()

This is my code

//button in the main movie that loads the external swf
keyboardDragMC.btBtnMC.addEventListener(MouseEvent .MOUSE_DOWN, loadPlayer);

function loadPlayer(myevent:MouseEvent):void {
var myrequest:URLRequest=new URLRequest("organBluesPlayer.swf");
var myloader:Loader=new Loader();
myloader.addEventListener("UnloadMe", unloadFunction);
myloader.load(myrequest);
stage.addChild(myloader);
}

//button in main movie that should unload the swf
keyboardDragMC.editBtnMC.addEventListener(MouseEve nt.MOUSE_DOWN, unloadFunction);
function unloadFunction(event:Event):void {

Loader(event.currentTarget).unload();
}


After looking around the net this seems to be quite a common problem. Would much appreciate any advice any one could offer?

thanks

Liam.

Unloading A SWF
I'm using a shell to load a series of swf files. I'm using a next and a back button to move from swf to swf. Some of my swf files contain video which continues to play. Is there a command to dump the current swf that can be invoked when I press the next or back buttons of the shell? Thanks

Unloading A Swf
hello all. this is probably a piece of cake, but i cant seem to get it right. i want to be able to close a swf from within another swf. iwant to be able to do this:

www.murderdolls.com

go to media... click on a photo thumbnail... the larger image contains a "close window" button.

how do i "close window"?

thanks in advance!

Unloading .flv
I have a main .swf file that loads another .swf file which contains a .flv video using the Media Playback component. Works great. Only problem is that, when I close the loaded .swf file containing the .flv, the audio still plays.... The entire screen goe's away, but the audio still remains. I've tried many differenct solutions on unloading certain things to no avail. any ideas? is there an unload .flv command? or maybe some kind of buffering issue? Thanks for any tips.

Unloading XML
I was hoping someone could tell me how to unload xml correctly. I need to unload an xml file on release of a button, then load new XML. Currently I am unLoading the initial xml by unLoading the target clip. However, when I do this not all of the assets (jpgs) that where loaded with the xml delete form the screen. The following is the code I am currently using. Any help would be great. Thanks.

interactivePortfolio_btn.onRelease = function() {
portfolioLabel_txt.text = "Interactive Portfolio";
currentThumb_mc.unloadMovie()
portfolio_xml.load("XML/interactive.xml");
_parent.description_txt.text = "";
_parent.info_txt.text = "";
play();
};

Help With UNLOADING
I can't seem to get the main.swf to unload when the next swf loads up...after clicking on the button...


Code:
on (release) {
_root.content.loadMovie("portfolio.swf",0);
unloadMovie("flashsite.swf")
}
I'll take any help...thanx!

Copyright © 2005-08 www.BigResource.com, All rights reserved