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




Set Vars In 1 SWF From Another SWF



Hi there,

I have 3 swfs on the smae html page. 1 of them has some buttons that change the colours of the interface. I want the buttons to also change the colours of the other swfs. I have used functions and they are all set up quite nicely. I only have to change 1 value to change everything that uses that colour.

But is the best/only way to do this to set the other swfs( without the colour change buttons) to get their colours from a javascript function (or maybe even perl/cgi script) in the html page. That way the colour change buttons would simply change the values in the html page and the other swfs would update themselves as they use those same values.

Am I making sense here?!

Thanks...



FlashKit > Flash Help > Flash MX
Posted on: 10-27-2002, 06:36 AM


View Complete Forum Thread with Replies

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

POLL: Best AS3 Send Vars And Load Vars Method
Hi Guys,

Can you help me decide which way to go with as3 to php and back again.

I generally use sqlite, xml or mysql for a database. I don't know if that matters. And sometimes (rarely) I don't use a database at all.

In the past (with as2) I always went custom. Im not sure If id be better off doing something else.

If you have another suggestion please let me know.

Converting ALL Vars Of A Clip To Global Vars -possible?
I wonder if it is possible to convert ALL variables set within a movie clip to global variables, using a self-defined prototype like movieclip.varsToGlobal or something like that. Here's the code I tried:


Code:
for (z in this) {
if (typeof (this[z]) != "movieclip") {
eval("_root."+z) = eval(z);
}
}


This seems to work, it copies ALL items found in the clip (excepted movie clips) to the root. But I am not sure WHAT things are duplicated to the root exactly. Just the variables? Or anything else I don't expect?

Mike
x-pressive.com

Local Vars Versus Class Vars
Hey guys, if a function gets call alot of times, such as a collision detection function in a game, will it be quicker to run if the variables for the function are declared and initialised outside the function as class variables? Or should they are declared and initialise inside the function as local variables everytime it is called, for good software engineering?

Load Vars Doesn't Want To Load It's Vars
I'm trying to initiate a sendAndLoad operation from a remote movie clip. When the visitor clicks the clip, it triggers a LoadVars object in a different movie clip, and asks it to sendAndLoad. This is the code on the trigger clip:

this.onRelease = function (){
_root.albumHolder.albumLoader.albumName = "album1";
_root.albumHolder.albumLoader.sendAndLoad("readAlbum.php",...);
}

where "albumLoader" is the LoadVars object (already created inside a movie clip called "albumHolder"), and "albumName" is it's only variable.

The LoadVars object is created when the movie loads:

albumLoader = new LoadVars();
albumLoader.albumName = "";
____

What I have done so far:

1. I've used a trace(albumLoader.toString()) to verify that albumLoader indeed has a variable called albumName, and that it's value is "album1";

2. I've used a text box to display that trace value. That was interesting. The output was something like: "%5BType%30Method%5&albumName=album1"

3. I've accounted for all possible variable problems by simply calling the sendAndLoad from the button, and fixing the intial value of albumName to "album1"

4. I've used loadVariables("readAlbum.php?albumName=album1,....); This works, so I know that the paths are right, MySQL daemon is working, etc.

It seems that sendAndLoad either will not send the albumName variable, or it is sending a value that is unrecognizeable.

I HAVENT tried the sendAndLoad operation from the clip where albumLoader resides, but this kind of defeats my purpose as I would like to have different clips in the movie talk to this object at different times. As well, there is another LoadVars object doing a load operation, and it's working fine - I'm pretty sure I'm doing something right.

Thanks for any help - my apologies if the answer is a no-brainer... I'm flying by the seat of my pants with this stuff. Loving it, but feeling like I'm riding Wonder Woman's invisible jet plane - the ground is just WAY to visible, and WAY too far away....

Vars
I'll first tell you what my flash movie is supposed to do.

I have an input texf field where the user types a number.
The action script checks the number that has been inserted by the user and:
if var = 1 go to and play next cene frame 1;
if var is different than 1 (number one) is jumps to the second FRAME of the same scene.
I already tried many and many times and it doens't work.
What am I doing wrong????

Vars In A Var
i have a var like so...(in a txt file)

&url=movieplayer.swf?movie=test.swf&height=240&wid th=320

and a button.... loadMovie(url,"target")

how can i get around the multiple "&" signs in a single var string problem??
can i escape them somehow?

S

Vars
What I need is the code to read in vars from the "flash
vars" field (on the client side, it's in the embed code in the HTML) into the sub movies. I also need to know where to put it, and how to call it. I appreciate anyone who can offer any help and thanks in advance.

Vars To Txt
How do you save some variables into a txt file?

Help With Php And Vars
hello,

i've a tiny problem... but for me i'm stucked.
now i get pissed of trien around and wanna some help ! PLZ

my codes are:

PHP

<?

include ('admin/include.inc');

mysql_connect($DBhost,$DBuser,$DBpass);
@mysql_select_db("$DBName");

$msg=mysql_escape_string($msg);
$name=mysql_escape_string($name);
$quote=mysql_escape_string($quote);

$query = "INSERT INTO guestbook (datum, name, email, webseite, kommentar) VALUES ('$push_datum', '$push_name', '$push_email', '$push_webseite', '$push_kommentar')";
$result = mysql_query($query);
$push_status = "Übertragen ...";

?>

FLASH BUTTON SEND

on (release) {
if (input_name eq "") {
push_status = "Namen Bitte";
} else if (input_email eq "") {
push_status = "eMail Bitte";
} else if (input_kommentar eq "") {
push_status = "Nachricht Bitte";
} else {
push_datum = Date();
push_name = input_name;
push_email = input_email;
push_webseite = input_webseite;
push_kommentar = input_kommentar;
push_status = "Sende ...";
loadVariablesNum("send.php", _root.mc_gb.schreiben.status, "POST");
clear_input.call();
}
}

__________________________________________________ __________

my problem is not the DB it runs fine.
my problem is that i would have the variable of my TEXTFIELD get changed by my PHP script.

so if someone goes onto send the status shows SEND...
after that the PHP Script have to change the VAR in RECEIVED...

but it doesn't work... however i've tried a lot of echo, print and vars. but no one reaches my goal...

could anyone HELP me PLZ "!!"

-----------------------EDIT-----------------
i'm trien the tut found here in forum...

Get Vars From Id
HY!

i'd like to get the var from http://www.mySite.html?var=value in the embedded swf. is that possible?

tia

Vars Within MC
I have 4 instances of the same MC on my stage (check1 - check4). In frame 1 of this MC i have the following:
stop();
check == 0;
and a button that (when clicked) goes to the "cmark" frame where check == 1;. Also in "cmark" there's a hotspot button to take the user back to frame 1.

So, on my stage, i have a Check Answer button that needs scripting. As mentioned, there's 4 MCs that the user can check/uncheck. Now, I need a script that says something like this:
on (press) {
if(check1.check == 1 && check2.check == 0 && check3.check == 0 && check4.check == 0){
gotoAndStop("correct");
} else {
gotoAndStop("incorrect");
}
}

I know this is wrong (because it doesn't work) so please advise me on how to get this right. I'm thinking I need a script inside the MC to customize the check variable? TIA my flash brethren.

Help With AS And Vars
Hello all, I don't know if you can read my thread before, because it was a reply of the yesterday one, so I'll try to post it new.

I have this dropdown menu with a scrollbar, the buttons of the menu are called from a .txt and looks like this:

&nItems=89&country1=aediva&&country2=anden&country 3=anclas&country4=andromeda&country5=anubis&countr y6=aula73&country7=babylon&country8=bagus&country9 =barba_roja&country10=barracuda&country11=black_ja ck&country12=bleiz&country13=blonde&country14=blue _cubi&country15=blue_moon ETC

then in my movie everything is working well, but now I want that each variable in the menu (I mean "aediva", "anden", "anclas", etc) link to a movieclip different for each one.

I want to know three things if you can help me:

- how should I write the variables in the.txt if the link is a moviclip and not "letters"???

- In my script I have:

code: bob["menu"+i].textItem.textbox = this["country"+i];

how can I correspond each new variable to the one I already have (country)???

-Do I have to create a new empty movieclip to call the different movieclips for each button, and what's the script for the button??

Sorry about tooo much questions, but is very important to me to solve this out...thanx in advance to all of you!!!!!

Same Swf But Different Vars
im preloading 2 or more (the same) swf's dynamicly but with different xml whitin it.

I want to store a position of the scrollbar whitin it but it will store the same in the other swf....

how can i store unique variables in a swf (which gets loaded 2 or more times)?

thxn already!

[F8] How To Add Several Vars? Help Please
Code:
lvSend.address = friend1.text;
Thats my script.. How do i add several vars here?

Like, i guess: friend1.text, friend2.text etc.

But that didnt work soo...
Help please..

Vars?
Hello im trying to make a hostable chat room Im not sure how to load vars into the flash a example is below

This is the send button

on (release, keyPress "<Enter>") {
loadVariablesNum("http://example.com/shout.php", 0, "POST");
message = "";
}

I want it load http://example.com/shout.swf?user=demo

and when it loads the send button will be like

on (release, keyPress "<Enter>") {
loadVariablesNum("http://example.com/shout.php?user=demo", 0, "POST");
message = "";
}

kinda like request code for php but i need it for flash thanks.
__________________
HMM...

http://hosted-scripts.com
and many more...

Vars Help...
I'm having a small problem loading variables that basically track users progression through an online flash application...

I'm a pseudo-newbie, at least to actionscript (hell, just plain coding as well) , so please be kind ...

current application:
Navigates through a myriad of plastic surgery animations (94 total), each of the animations has several 'steps' (3 - 7) in each, including english, spanish and male procedures...

problems:
I need to set variables on each 'on' action as well as each 'stop' action, along with setting the variables, I need to send them to track.asp so we can have an admin feature to view usage stats...

solution:
Ideally, we'd love to navigate through an XML doc, of which we can update the text/animation/titles/etc easily, but we only have a few days to complete version 1a... I love the idea of flash coding, I'd love to do this, I just need a little push in the right direction...

Thanks for the help,
Foops

Vars.
Hi.

I want to set a variable in a movieClip that will be valid in my entire timeline in every scene. How would I accomplish this?

Thanks.

Vars Between SWF's
I currently updated a project with some video using the VP6 codec in Flash 8 but now as Flash player version 8 file it doesn't work like the previous file in the following way.

The main menu file as well as the rest of the the externally loaded SWF's are published as version 6. The main menu file loads external SWF's into 2 other movie clips. The problem arises when one of the externally loaded files tries to communicate with the other externally loaded file using a _global variable.

I use,

Code:
_global.extMovieLoc = this; // in the external clip 2
In external clip number 1, I use,

Code:
_global.extMovieLoc.gotoAndPlay("cue01"); // to jump to parts of ext. clip 2
External clip #1 is published as Flash player 8 version. Does that have anything to do with the _global commands not working? I have read something about this in a search here. If so what's the fix? Or where can I find out how - tute, example?

I have 6 other external sections that can control the timeline of the second external clip just fine, but not the new version 8. I'd appreciate any feedback on this. Thanks.

Randy

The Sum Of 2 Vars
Hi scripters!!

I need to know why my variables, witch i set to number variables, are set behind eatchother.

I did it like this:

var a_score:Number; (123)
var totaal:Number; (423)
var totaal2:Number;

totaal2 = totaal + a_score; ( Than this is: 123423 )

But is has to be: 546

Anyone knows why?

Getting Vars From URL
Hi, in AS 2.0 I do this by FlashVars passing the var in the param of the embeded flash movie in the HTML, but I don't have idea about how to do this in AS 3.0.

Any suggestion's?

Vars Out Of Mc
Hi everybody!

Here is the problem:
I have string var in first frame on stage, and mc called from library in x frame.
How to call in string value from stage?

Vars From As To Js
looking for some ideas on whats going on here... seems like something i've seen before, but i can't think of it right now... maybe too much caffeine/sugar in my system now.

the problem:

i have a getURL action where i call a javascript function and pass it a string (01722)
the javascript function is recieving the string (978).
needless to say, this is screwing my code up.

any ideas?

its gotta be something obvious that i'm just missing.

thanks for any help.

Cant Get Vars From Self Php...
i cant get "[$_GET] vars" from self php file and print it in swf.

(swf is in test.php file)




PHP Code:



if(empty($_GET["link"])) {$link="null";} else $link=$_GET["link"];

echo "&page=$link&";?> 




ActionScript Code:
phpVars = new LoadVars();

phpVars.onLoad = function(){

page = this.page

}

phpVars.load("test.php");

Vars In CS3 ?
I can't edit Vars in ActionScript 3 in Flash CS3, it says make Publish setting for AS 2.0 or 1. So how do I do this in AS 3.0 ??

Help With Vars
Hi Everyone,

I am trying to use a variable as a instance name and I'm not able to make it work. This is an example of what I'm trying to do.

function clicked(myParameter){
var button = myParameter;
test_mc.button.gotoAndStop("start");
}

clicked(myMC);


When I trace the for the value button I get undefined.

Thanks
Mike

Getting Vars From Php
Ok guys,

I have a simple question.

I want to make a loop for php. I am loading a php file, and want to echo a loaded variable to flash, so flash can check if the file is loaded or not.


What is the best way to do this?

How should I echo() from php? Then how should I check it in flash?

How should I make my loop? If(loaded eq "true") etc..

Or is there a better way to approach this?

Here is what I am doing..

Loading a check.php

This checks a file to see if it has updated. If it has, it should send out update=true(or is there a better way, such as update=yes, etc)

Then if update eq true, we will load a new file, which will add the new line into the chat(That's what I am making) Then it will change the variable inside the mysql database back to false, until someone else submits a message.


What is the best way to organize this so each one loads, gets everything, then checks, then if it is true, load a new file, and check on it, and then if the first one is false, just reload the first file again and again. Each time this should be reloaded. Because I have had problems with the old variables still being used, and it not reloading the php file.

As1 To 2 Vars
in AS1 you could do this
this["cat"+i] = whatever;

but in AS2 ive tried differnet things like
var "cat"+i =
var ["cat"+i] =
var this.cat+i =
var this["cat"+i] =
this var "cat"+i =

etc. etc.

how would oyu do this in AS2?

Vars HELP
Var HELP PLease!!!!!!!
Hi!
I'm trying to control a dynamic element

here's my code
///////////////////
myvar = "mc.element";
_root[myvar].stop();


//-> if I only use myvar="mc", it works but the dot seems to make an error!

How can I do this without telltarget?
Thnx

Help Getting Vars From PHP
Hi everyone.
Can u help me with something I can't seem to figure out.
When I use LoadVars object to get the variables supplied
by a PHP script the object content is changed to the script code instead of to the output from that script. It seems Flash considers PHP as a text file and the script is not parsed at all.
10x in advance.

JS Popup Win With Vars
I need to create a popup window through Flash using JavasScript...but I need to send the JS function a URL as a var. I have the JS function created, and my var all set - Just need to send it to JS...How do I do this?

Thank you,
Brian Riley

Getting Vars Into Flash From Url?
hello-
I have a flash navigation on my site and the buttons when clicked go to a new page.. but it loads the same flash file on the new page and this is where i want to read the "p" variable that is passed in the url (i.e. index.php?p=1) now how do you read a variable in the URL into the flash movie on the same page?

for example:
the url of the page is this:
http://www.domainname.com/index.php?p=1

how do you get the value of "p" into the flash movie that's is loaded when http://www.domainname.com/index.php?p=1 is loaded?

i hope i'm making sense..

jay

Help Loading XML Vars
Hello All,

I haven't worked much with XML, but I have now come across a time that requires I learn FAST!

I'm making a calendar; found here:

http://www.cadvision.com/birdgenj/calendar.html

Now here's the problem:

I need to load dates into this calendar from XML so that I can have the dates appear on their place in the calendar (for example I click aug 26th, and then the description appears at the bottom.)

So...

How can I parse the following XML to load these variables into flash (Month, Day, Year, Description);


[EVENT]
[MONTH]7[/MONTH]
[DAY]26[DAY]
[YEAR]2001[/YEAR]
[DESCRIPTION]Student Orientation 10:00[/DESCRIPTION]
[/EVENT]


Thanks in advance!
Help is greatly appriciated

Birdgenj

Which Vars Are Global?
I have a movie in _root which has the ability to load a form that is contained in its own movie into _level1.

When this form sends the data to the server, it's sending a **LOT of information along with it. Some of this is good, some is a waste of bandwidth.

How do I know which variables will be submitted? I understand that global variables will go, does this mean all variables defined in _root, or will variables defined in _level1 go too?

Is there a common practice on where to store your variables so that they are not arbitrarily sent to the server? If so, how can I selectively send my vars to the server?

I thought that maybe I could load a different movie into _level1, and put variables there. Then load my form into _level2. Will this help?

Thanks,
Matt

PLEASE HELP - Passing Vars Through MC
Hi!

Simple question.
I have MC that is called by this:
<param name=movie
value="/images/navpanel.swf?what=destination&whatID=1&lang=EN">
embed tag is the same.

Now, I have in the MC Action script following
onClipEvent (enterFrame) {
if (menu.done == undefined) {
menu = new Object();
tree = new XML();

tree.load("/assets/navpanel.cfm?what="+what+"&whatID="+whatID+"&lang= "&lang)
;
menu.done = false;
}
if (tree.loaded && menu.done != true) {
makeFlashVars();
menu.done = true;
}
}

The problem is - MC is not passing the parameters through.

If I change all '+' in URL query string to '&' - then the movie content is
not showing
And if I put all '+' then parameters are not shown.

HELP!

How to define variables so that they are loaded from HTML and then passed
through to another XML.

Loaded Vars 911
i got a movie that loads some simple variables from a txt file but i can't see them. i have a variable named "amounts" that i load but when i trace it nothing shows up. so i made a text field and load a number into it. i can see it show up but when i trace that text field it gives me this value "<P ALIGN="LEFT"></P>" instead of "12" or whatever number i put in the txt file.

in flash i got this :: loadVariablesNum ("text.txt", 0);

in the txt file i have :: _root.counter.amount=12
amounts=8

do any of you flash gurus out there know how i can read these vars or at least make it so when they load and i trace them i get a number?

Loading Vars
anyone here can explain how to load variables into a txt file??

i know we can call variables from a txt file.

is it possible tjhat i load vars into a txt file and tyen call them later so that i mnaintain the top score list.

thanx

Posting Vars
hi,
if i post data to a processing script can the flash prog read back the responce or will any script output be sent to the browser aka a normal http post?
i know flash can open xml sockets but i want to post to a static script not a running prog..

thx

Exchanging Vars
Is it possible to pass vars from an external .txt(whatever PHP, JAVA, ect...) file into flash ??? Note this file has to be on a different server than the .swf .


Thanks

Loading Vars From URL
want to load in some variables from the url, for example:

http://www.mydomain.com/flash.asp?data=var1,var2

anyone know if it is possible to load var1 and var2 into FlashMX as a string?

oh yeah, the SWF that needs these vars is also loaded onto this page... if that helps.. ; |

ta

Controlling MCs W/ Vars
Okay, I would like to control a movie clip clips deep into the movie. The animation goes like this... a "professor" is drawing on the chalkboard, and he "writes" but all it really does is move a mask to let it viewable. Anywho, the hand animates by itself in its own layer, I have it set now like this..
The first frame, it sets a variable to "0". Then when the full animation is done, it sets the variable to "1".
Then, inside the animating hand... I have an if statement.

Code:
if (check == 1) {
stop();
}
And guess what... it doesnt work!!! instead, it does not animate the hand... it is just static... can anyone help me?

Sending Vars To Another Swf In An Htm
How to do? Flash help is no help here

I've got a menu in one flash file. If the user clicks on a button there I want it to tell a nearby frame to load an htm which contains another .swf file. This is a simple getUrl

This frame will open a .swf which then loadMovie's a path to an image: i.e. loadMovie("photobar1.jpg");

However, because I have so many photobars, its become a pain to have several .swf's and several .htm's that are specific to photobar1, photobar2, photobar3, etc..

So I would like to have a way to have the .swf menu send a variable which I'm calling "event" to the newly opening .swf that is equal to 1, 2, 3, 4... etc. Then I can tag this variable onto the loadMovie request

(kinda like loadMovie("photobar" add event add ".jpg");

But so far as I have tried, the variable event never gets from the menu to the viewer pane swf.

Simple fix? Maybe have it write a quick txt file that the other can load in? What's the syntax?

SendAndLoad Vars
I have this code and it never load the variables, which is the problem?


misVariables = new LoadVars();
misVariables = "codCategoria=1";
misVariables.sendAndLoad(familias.asp,misVariables , post);
if (misVariables.loaded){
gotoAndPlay (10);
}else{
gotoAndStop(17);
}

I tried it also with the get method and the result was the same.

Load Vars Into MC
I'm having trouble getting vars to load into an mc. If I keep them on the main timeline, everything is great, but if I load them in an mc then they don't work. Any ideas?

I Need Load Vars Help...please
I am building a Flash MX site where a section of the site will have Bios of people.
I have a database built out using MySQL and PHP.
I created this button function in my Flash movie

randall.onRelease = function() {
getBio = new LoadVars();
getBio.memberName = this._name;
getBio.send("php/bios.php", "_blank", "POST");
};

This works perfectly! My PHP echoes the info exactly how I need it. URL encoded and all!

randallBio=Randy+was+born+and+raised+in... etc

Now that I know the info is being interpreted correctly, I need to get it back into Flash.
Can anyone help me with converting my current send function into sendAndLoad?

Thanks in advance!
- Patrick

Load Vars
Hello all,
I want to send variables sitting in one swf in an html page to another, different swf in the HTML same page.
Both SWF's sit in the root directory with the page they're embedded in.

Would i use Load Vars for this?
I can't seem to get the 2 swf's to share their precious variables...they just keep repeating, "my precious, my precious" to them! <just kidding).

Thanks.

Global Vars Help
I guess I've just sort of passed them off as unmentionable in the past, but I don't really even know how a global var is diff from a normal var. Is it a variable that any mc on any timeline can call without a target path? That's my hunch... Thanks for your time.

Send Vars To Another Swf?
Hello guys. Although i am an old timer of fk i never posted enough messages to be known around...
anyway, to my thoughts.

I have a movie, which contains the main site. In this movie, i have an email form, which communicated with the formmail script.
As many of you probably know, formmail has the option to send your visitor to any page you want after the emai has been sent.
Handy for custom output pages!
BUT, here is my thoughts. How can i send the NAME variable to the second swf file, located to another html page (or even loaded by itself in the new window- without the html) so i can have a dynamic textfield that prints the sender's name?

Lets explain that better:
1) You (john doe) decide to send me an email. You send the message using the form, having typed 'JOHN DOE' as your name in the name text field.
2) After the message is sent, a popup window loads a swf document, either alone or embedded in html (i dont care) to inform the user that the message has been sent.
3) A text field outputs something like this : 'THANKS JOHN DOE FOR SENDING EMAIL TO US'.

thats the tricky part.
If anyone can help me send this variable to the other swf, it would be great!
Thanks
George

Passing Vars Via A URL
I'm pretty sure this should work but I must be doing something wrong

I have an swf/html file.

test.html

If I want to send some vars do I just do test.html?var1=1&var2=2 ??

Also if I want to display the vars, can I just set up a dynamic textbox called var1 or var2?

thanks

Emailing Vars.
I am trying to build a simple survey that collects the "set" or chosen variables and sends them to a mailbox. I have 250 variables which are set when chosen
(answer1_one="") when chosen than
answer1_one="answer1_one".

how do I collect the chosen(set variables and send them when the user clicks submit? It is a form broken into 10 pages, any help?

thanks
stash

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