Broken SetVariable
I created an offline presentation communicating from javascript to Flash using SetVariable. Everything worked fine using Flash Player 7 however when updating to Flash Player 8, none of the 5 variables are passed. I have 2 Flash menus that are communicating with an IFRAME through the javascript.
The following code used to work no problem: window.document.statustext.SetVariable("statusbar. itemcount", itemcount);
How would I go about fixing this?
Thanks.
Jason
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 04-10-2006, 08:46 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Broken SetVariable
I created an offline presentation communicating from javascript to Flash using SetVariable. Everything worked fine using Flash Player 7 however when updating to Flash Player 8, none of the 5 variables are passed. I have 2 Flash menus that are communicating with an IFRAME through the javascript.
The following code used to work no problem:
window.document.statustext.SetVariable("statusbar. itemcount", itemcount);
How would I go about fixing this?
Thanks.
Jason
SetVariable, Wth Is It.
I am trying to figure out setVariable.
I've seen it.
I am pretty sure it exists.
But there's nothing in the actionscript reference about it other than "For Global variables use the setVariable or (=) method..."
And I do a search and everything I get is setVariable with netscape, or setVariable with javascript.
So what is it? What does it do?
I'm trying to pass variables back and forth between authorware and flash and maybe this will help?
Thanks.
Use SetVariable
Call the SetVariable() function on the swf file object to a variable 'into' the swf file.
And if you want to invoke this from the swf file itself, just call a javascript function that sets this variable.
-Mav
SetVariable
Hi
I have a flash file created in a program other than adobe flash and have imported it into adobe flash to see the variable names.
Shown below is some of the variables from the flash file.
Global Variables:
Variable _global.param = [object #1, class 'Array'] [
Movie.Text:"Click here to move onto Stage 1",
Movie.ClickLinkUrl:"
SetVariable
hi,
i just want to pass a variable from java script to actionscript.
so i have used SetVariable for it. And its working fine. Means its passing a variable from java script and displaying its value into a textfield which is in flash.
but now...depending on that value i want to write if else statement.
but its not going into the if else statement.
actionscript code:
var a;
if(a == 1234)
{
a = "success";
}
else
{
a = "no luck";
}
Javascript code:
<script language="JavaScript">
<!--
function setVariable() {
theValue = prompt ("Please entr a phrase:", "1234");
if (theValue!=null) {
document.setvariable_usingVariable.SetVariable('a' , theValue);
}
}
-->
</script>
</head>
<a href="javascript:setVariable()" title="Pass variable to flash from JS">Ok, JS to Flash Now!</a>
its very very important to me...
please help me.....
waiting for ur help.....
thanks
SetVariable In IE6.0
I'm using the following code in a javascript function to set variables in a SWF
It works fine in IE7 and FF2 but variables are not being passed in IE6.0 - they show up as undefined.
I spent several hours Googling for some enlightenment on this, checking the code, trying alternative syntax, etc. but the dang thing just doesn't work.
I know about query strings - and it does work in that format on IE 6.0 but I wanted to use javascript so that I can pass multiple sets of vars into Flash using separate lines of code versus having to concatenate them all on one long, error prone line.
Attach Code
window.document.tooltips_sample_2.SetVariable("tName1", "tooltip1");
window.document.tooltips_sample_2.SetVariable("tText1", "One");
window.document.tooltips_sample_2.SetVariable("bLoc1", "275,213");
window.document.tooltips_sample_2.SetVariable("bSize1", "20,20");
SetVariable
i'm stumped. i've followed every example i could find and still can't get SetVariable (javascript talking to flash) to work. i am able to get other javascript-to-flash methods to work, for example mc.play();, but SetVariable just won't work for me. i've tried with both ie and netscape.
does anyone know of common syntax errors or any other problems that would cause SetVariable to fail?
i initialize a variable on the first frame of the _root timeline:
var appName;
then i call the javascript variable setter:
getURL("javascript:callApp();");
in javascript in the embedding .html:
function callApp() {
window.document.app.SetVariable("appName","app1");
}
but appName never changes.
anybody?
thx
depth
SetVariable Command In NS?
I'm trying to set a variable in my flash movie from the html page containing it. According to Macromedia, I can accomplish this by giving my object/embed tags an 'id', adding 'swliveconnect=true' to the embed tag, and then targeting it thus:
document.all.MovieName.SetVariable('variable',valu e);
I believe this is the structure that is necessary for NS, but my test movie is not working. As a matter of fact, the script stalls on this line, and will not execute any further.
So, does NS not support this function? Or have I screwed up the syntax somehow? Any help appreciated.
Quasi
If Statement With SetVariable?
I'm trying to control a movie with the onRelease event. The movie is simply a window that expands open and then contracts closed. I have a stop() in the middle of this movie to prevent it from running all the way through as I want it to stop halfway, when the window is fully open, if need be. I have set a variable, windowState, at the beginning, middle and end, with the beginning and end frames being 'closed' and the middle being setVariable=open. I have tried to attach an if statement to the onRelease event of my object on the stage, hoping that onRelease, I could use an if statement to check if the variable windowState was either 'open' or 'closed', prompting the playhead to go to specific frames of the window movie (either closing or opening the window). I'd planned on replicating this script to the remainder of my buttons but have seemed to come to an abrupt stop at the moment. I've played around with the syntax thinking something may have just needed to be moved around but I've still be unsuccessfull and could use a bit of help. Also, I'm running MX if that helps any.
SetVariable And Netscape
my flash file is not reading the variable from html through javascipt in netscape. i have used the SetVariable function.
it is working fine in ie.
is there any problem with the javascript function SetVariable in netscape?
samtom.
Still More SetVariable Issues
Is there a bug or something where sometimes variables won't set like you tell them to?
I have a text field that is supposed to receive a variable from a .txt file (via loadVariables).
There are two ways in which you can set the variable.
There is the incorrect answer to a question, click the next button, get it wrong and then it loads the variable. In the next frame, the variable is in the text field as it should be.
but!
if you answer the question correctly and click the next button, the variable is not in the field.
both NEXT buttons use EXACTLY the same script to execute this process.
the .txt file is set up correctly because it's well behaved in other parts of the movie.
this is driving me nuts!
SetVariable In Netscape
I am using a Javascript function to set a value in .SWF file.
function checkcik()
{
// ei is a name of .swf
window.document.ei.SetVariable("dirsel", "test");
}
This function is working fine in IE but not in netscape. I guess the problem is related to the notion of the .swf object. I tried several notions like document[ei], document.ei, ... but nothing worked.
Thanks,
Keeyong
SetVariable (javascript)
I am trying to send a value from a javascript in my html doc, to a dynamic text field in a swf file. I am using Flash MX, and also working on a Mac.
here's the code i am having problems with :
var time = tid
window.document.getvar.setVariable("displayVar", time);
Where "tid" is a string, and "getvar" is the flashMovie in which the value is to be sendt to.
When trying the html doc in browser i get the following error :
Object doesn't support this property or method.
Are there anyone out there who can help me out a bit?
Regards,
Lars Schlanbusch
Netscape And SetVariable
Yo Flash community,
Ive been looking thru your threads to try and resolve a problem,
I cant get setVariable to work, ive done the following
1 > Made sure the file name and object-id and embed-name are all the same
2 > Included swLiveConnect=True in the embed tag
3 > Written a function that returns the flash movie object path dependant on which browser is being used;
function getObject(movie){
if (navigator.appName.indexOf ("Microsoft") !=-1){
return window[movie];
} else {
return document[movie];
}
}
Im using flash MX and Netscape 7..... The html code is constructed using asp,
here's the code that should work,,,
if lcase(page) <> "booking" then
s = s & "<td colspan='" & c & "' height='40' valign='top' align='left'>"
s = s & "<OBJECT classid='clsid27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' WIDTH='700' HEIGHT='40'
id='display' ALIGN=''>"
s = s & "<PARAM NAME=movie VALUE='assets/flash/display.swf'>"
s = s & "<PARAM NAME=quality VALUE=high>"
s = s & "<PARAM NAME=bgcolor VALUE=#ddeeff>"
s = s & "<EMBED name=display src='assets/flash/display.swf' quality=high bgcolor=#ddeeff
WIDTH='700' HEIGHT='40' ALIGN='' TYPE='application/x-shockwave-flash'
PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer' swLiveconnect=true></EMBED>"
s = s & "</OBJECT>"
s = s & "</td>"
s = s & "<script language='javascript'>" & vbcrlf &
"getObject('display').setVariable('caption','" & page & "');" & vbcrlf & "</script>"
end if
Any help will be well appreciated. Thanks
L8r
SetVariable To Movie Outside Url
my page has url www.myserver.com/page1.html
but flash in it is loaded from www.diffrentserver.com
<param name="movie" value="http://www.diffrentserver.com/test.swf">
and following function not working
function passToFlash(urll) {
window.document.startFlash.SetVariable("_root.out" ,urll);
//window.document.startFlash.SetVariable("_root.out" ,aa);
}
when I put swf in same url there is no problem.
I know that I can't load variables from outside [.swf?myvar=123]
but this is diffrent situation I think.
It is possible to solve this?
Possible Bugs In SetVariable()?
I've run up against a wall using setVariable trying to set a negative value inside of my flash document.
Has anyone else had trouble with this? At all the reference I've looked at there is nothing mentioned about negative nubers not being a valid datatype.
Using SetProperty & SetVariable
Hi there,
I'm trying to play around with the Moving Solar Boxes tutorial example, but i'm having troubles with the Setproperty & SetVariable functions.
It says add the code as follows:
setProperty("/box", X Position) = 17.5
setProperty("/box", Y Position) = 14.2
Set Variable: "origx" = GetProperty ( "/box", _x )
Set Variable: "origy" = GetProperty ( "/box", _y )
Set Variable: "sizex" = GetProperty ( "/box" , _width )
Set Variable: "sizey" = GetProperty ( "/box" , _height )
Set Variable: "d" = 1
Set Variable: "squares" = 1
Loop While (d <= 46)
Duplicate Movie Clip ("/box", "box"&d, d)
Set Property ("box"&d, X Position) = origx + d*sizex
If (GetProperty("box"&d, _x) <%gt> squares*sizex + origx - 5)
Set Property ("box"&d, Y Position) = origy + sizey
Set Property ("box"&d, X Position) = origx
If (n < squares)
Set Property ("box"&d, X Position) = origx + n*sizex
Set Variable: "n" = n+1
Else If (ntwo < squares)
Set Property ("box"&d, Y Position) = origy+2*sizey
Set Property ("box"&d, X Position) = origx + ntwo*sizex
Set Variable: "ntwo" = ntwo+1
Else If (nthree < squares)
Set Property ("box"&d, Y Position) = origy+3*sizey
Set Property ("box"&d, X Position) = origx + nthree*sizex
Set Variable: "nthree" = nthree+1
Else If (nfour < squares)
Set Property ("box"&d, Y Position) = origy+4*sizey
Set Property ("box"&d, X Position) = origx + nfour*sizex
Set Variable: "nfour" = nfour+1
End If
End If
Set Variable: "d" = d+1
End Loop
But there is no set Variable function that I can find, and i'm not sure how to use the parameters for set property. Does it matter that i'm using Flash 2004?
SetVariable Problem
I am using a Flash object on asp page and the asp page is reloaded with different variables on clicking on a link. The variables then sent in flash,
The problem is that on some PCs it works but on others it does not set the variables on reloaidng the page.
what can be the possible reason.
i am using this code to call the flash object
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="customProdReady"
width="580" height="300" align="middle">
<param name="movie" value="../flash/customProdReady.swf?id=2050&img=<%=imgFile%>&Side= <%=picSide%>" />
<embed src="../flash/customProdReady.swf?id=2050&img=<%=imgFile%>&Side= <%=picSide%>" quality="high" bgcolor="#000000"
width="580" height="300" swLiveConnect=true id="customProdReady" name="customProdReady" align="middle"
allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
/></object>
then <%=sTextForFlash%> comes as the result of sql query
and after this the variable is sent to flash
window.document.customProdReady.SetVariable("TextD ata", "<%=sTextForFlash%>");
SetVariable In Same/next Frame
I have problems setting a variable to flash from JavaScript using FSCommand in the same and next frame.
The variable is set correctly if i add a button and alerts the variable in on(press) function when the button is pressed. However, it is not set correctly if i alert the variable after fscommand() and even in the next frame.
My code in flash is as follows:
Code:
var myvar = 5;
fscommand("setvar", myvar);
fscommand("alert", myvar);
My code in JavaScript is as follows:
Code:
function myFlash_DoFSCommand(command, args) {
if (command == "setvar") {
window.document.myFlash.SetVariable("_root.myvar", 10);
}
else if (command == "alert") {
alert(args);
}
}
The result alert shows 5. If i call fscommand("alert", _root.myvar); when a button is pressed, it will prompt the correct value which is 10.
Can anyone help me with this? Thanks.
SetVariable In Actionscript 2.0
Im using a quite old book that is telling me to choose the setvariable function in actionscript, but its for actionscript 1.0 and Im using 2.0 and I cant seem to find the setVariable action anywhere. Does it still exist? and if not, what is the equivalent??
Can You Setvariable To The Instance Name Of A Mc?
Hi,
Thanks for looking at this thread,
I dont know if this is a stupid question but...
I have a movieclip with a button animation in it, when I rollover it tells the button to scale and the descale on roll out. there is also a setvariable command to tell another part of the movie to goto the nextImage.
ie _root.pics.nextImage = "pic1";
Now I would like to make this "pic1" be "this mc's instance name";
so that I dont have to change it in every MC'S actionscript
hope this makes sense,
Any help greatly appreciated
ta
Matt
Troubles With SetVariable
Making a practice quiz. When the user gets a right answer, they get a popup window in flash with more info and a close button that should reset the question and answer. I am able to increment the counter, but can't seem to get the variables reset. I've tried eval(), set(), and setVariable with no luck. I also can't get the main timeline to play again afterwards. Here is my code for the Close button:
on (release) {
_level0.counter = _level0.counter + 1;
trace(_level0.counter);
this["question"+_level0.counter] = "_level0.question";
this["answer"+_level0.counter] = "_level0.answer";
//setvariable("answer"+ _level0.counter,"_level0.answer")
//setvariable("question"+ _level0.counter,"_level0.question")
_level0.play();
trace (_level0.question);
trace(_level0.answer);
_root.answerBlock.gotoAndStop(1);
}
In frame 1 of main movie I have:
var question1 = "1. What is the capital city of Georgia and location of a vibrant black urban middle class?"
var answer1 = "Atlanta Georgia
This city was both a major destination and embarkation point for black southerners in search of jobs and a better way of life. Atlanta University, Morehouse University, and Spellman College are a few of the historical black colleges and universities located in Atlanta. "
var question2 = "2. What is the largest city and seaport in Maryland?"
var answer2 = "Baltimore, Maryland
Baltimore attracted large numbers of black southerners because the city had both a well-established black community since early nineteenth century and labor intensive industry that needed workers."
// initiate the first Q&A //
var answer = answer1;
var question = question1;
var counter = 1;
stop();
Can anyone see where I'm goofing up?
SetVariable/Netscape 7
I am using the Flash javascript method Setvariable to pass variables from an html file to a Flash movie. Works just fine with IE 6. However, I have not be able to make it work with Netscape 7.
The only way I've been able to make it work with NS7 is to remove the OBJECT tag entirely and use only an EMBED tag. However if you do that, IE 5.5 and above won't work with SetVariable (predictably, because that's the release in which IE stopped recognizing Netscape-style plug-ins).
And, yes, I'm using swLiveConnect=true.
Has anyone else run into this and found a solution?
SetVariable Problem
I am using SetVariable() function call to pass new data to a variable inside Flash animation(swf).I do it from c++ code using wrapper for Shockwave Flash Object.It works ok if I do not call SetVariable too often. However, most of the time I need to call it more frequently. For example, 10 times per second and when I do that, my application crashes in Flash9d.ocx.
Does it mean I cannot use SetVariable very often or there are other ways to do this for may case?
Thank you very much.
Edited: 11/02/2007 at 11:53:56 AM by Michael Nejelski
Setvariable With Firefox
Hi there
I have the following javascript code and works with IE but produces an error with firefox, any suggestions recieved with thanks
window.document.movie.SetVariable("var_con.FilmVar","love in a lecture.flv");
error reported :
window.document.movie.SetVariable is not a function
Thanks
SetVariable Problems
I am using setVariable to pass the results of an LMS query back into flash. The process works like this:
Flash sends LMS commands using fscommand to javascript via a vb handling script (DoFSCommand) - this a standard and well documented method.
Javascript handles the LMS commands and passes this onto the LMS. Some of the commands we pass require values from the LMS.
The LMS returns the values requested to javascript which then, using a setVariable function, passes them back into the flash movie.
The problem I have is that this works most of the time but on some occassions there are no values returned. This is a timing issue in flash. I know that passing values to a dynamic text field happens instantly, but I don't want to do this. I just need the variable and value, I have read that this takes longer for some reason?!!
I have _root.watch (variable, perform some function) for all the variables I need. I have also declared and initialised the variables on frame 1 of the root timeline.
on frame 15 of the timeline I have my fscommands and my _root.watch functions (don't ask me why, it just works if I place them further along the timeline??), I have also left an additional 15 frames to allow 'time' for the variables to be passed back (once again this may just be paranoia on my part!!). Even with all this, It does not work 100% of the time!
I must confess, I realise the need for _root.watch but don't fully understand it as there are no stop(); or functions that ensure if the variable has not changed it does not allow the movie to progress, or is this built in to the watch command? My feeling is that the problem lies with the watch command.
My apologies for the verbose nature of this posting but I'm hoping it provides most, if not all, of the information required for the experts out there.
Thanks in advance.
Regards
T.
AS3 + DocumentClass + SetVariable...?
In previous AS versions, the Javascript in an HTML page could communicate directly with variables in the Flash by using SetVariable(). However, with AS3, this appears to be different.
I am well aware of ExternalInterface, and the goodies it provides for function calling in both directions. However, from a stylistic programming perspective, I have some cases where in the Javascript, I'd rather have a variable that it could set, rather than a function call. YES, I know that in reality, it's just a function call anyway, with "SetVariable", but ideally, I'd like to be able to set a variable directly, and if that can't be achieved, I want to back up little by little until I get the closest solution I can to that ideal. Using a single function called SetVariable seems to be a better compromise than having a whole slew of separate functions to call from Javascript, one for each variable.
My ideal case was something like:
document.myFlashObj.varname = "blah";
I was then hoping that I could have an implicit setter function in the DocumentClass object like:
public function set varname(val:String):void { ... }
I then tried:
ExternalInterface.addCallback("varname",varname);
I got a compiler error about it not recognizing the varname function to add.
-------------------------
So, once I decided that this probably wasn't going to work (the assignment to varname in the Javascript, specifically), I switched to the SetVariable() approach.
I was hoping that:
document.myFlashObj.SetVariable("varname","blah");
would call my setter function. it did not.
moreover, even trying to use the SetVariable to set an ACTUAL public string variable in my DocumentClass object still didn't work. I get no errors or exceptions, but the value doesn't get put into my DocumentClass's variable. I don't know if it's failing, or getting put in some other scope I'm not aware of, but it's definitely not where I wanted it to be.
So, I figured that maybe SetVariable() was no longer available to AS3 (even though the online docs seem to indicate it is). So, I tried this:
ExternalInterface.addCallback("SetVariable",mySetV ariable);
and
public function mySetVariable(varname:String,varvalue:String):void { ... }
the call from javascript STILL didn't execute my function.
so, what gives? Apparently SetVariable() is still around, and pseudo-reserved in that it cannot be reused or overridden. But it doesn't function as expected or documented.
My next best option is to have a callback name like "SetVariable2" or whatever. This btw DOES WORK. but now my javascript is using an ugly third-string quarterback ("document.myFlashObj.SetVariable2(...)") to do its business, and I don't like that.
help?
Using SetVariable With AS3 - Its Ridiculous
I'm trying to make a flash 9 example of using AS3 and VB / VB.NET to set a variable inside the flash.
The flashplayer ocx has its method SetVariable("<variableName>", "<valueToGive>") which sets a variable in the code to whatever you put as the second argument. This is callable with any language hosting the flashplayer.
The problem is that with AS3 this seems not to do anything... For the <variableName> I have tried:
_level0.myVar
level0.myVar
root.myVar
myVar
It works in AS2 with the textField var... But this is useless to me as I moved to AS3.
The code is in a class, and is the Document Class.
The code is below. A quick explanation follows that. What I really need to know, if anyone can help me, is:
How do I set a variable declared in the Document Class in AS3 from the flash container?
Code:
package {
import flash.display.Sprite;
import flash.display.Graphics;
import flash.events.Event;
import flash.text.TextField;
import flash.system.fscommand;
public class ColourChanger extends Sprite{
public var BackColour:String = "0xFFFF00";
public var TextColour:String = "0x000000";
public var Text:String = "";
private var oldBackColour:String = "0xFFFFFF";
private var oldTextColour:String = "0x000000";
private var oldText:String = "";
private var bg:Sprite;
private var sampleText:TextField;
public function ColourChanger(){
// add bg movieclip that can change colour
bg = new Sprite();
bg.graphics.beginFill(parseInt(BackColour),1);
bg.graphics.drawRect(0,0,100,100);
bg.graphics.endFill();
addChild(bg);
bg.width = bg.stage.stageWidth;
bg.height = bg.stage.stageHeight;
// add textfield
sampleText = new TextField();
sampleText.text = Text;
sampleText.textColor = parseInt(TextColour);
sampleText.wordWrap = true;
addChild(sampleText);
sampleText.x = 25;
sampleText.y = 25;
sampleText.width = sampleText.stage.stageWidth - 50;
sampleText.height = sampleText.stage.stageHeight - 50;
// set the text
sampleText.text = "To change this text, set the variable Text (String)
";
sampleText.appendText("To change the colour of the text, set variable TextColour (0x000000)
")
sampleText.appendText("To change the colour fo the bg, set variable BackColour (0x000000)
")
// set up function to monitor those vars for change;
addEventListener(Event.ENTER_FRAME, checkForChanges);
}
private function checkForChanges(e:Event){
if (BackColour != oldBackColour){
changeBgColour();
}
if (TextColour != oldTextColour){
changeTextColour();
}
if (Text != oldText){
changeText();
}
}
private function changeBgColour(){
try{
bg.graphics.clear();
bg.graphics.beginFill(parseInt(BackColour),1);
bg.graphics.drawRect(0,0,100,100);
bg.graphics.endFill();
oldBackColour = BackColour;
}
catch (e:Error){
sampleText.text = e.toString();
}
}
private function changeTextColour(){
try{
sampleText.textColor = parseInt(TextColour);
oldTextColour = TextColour;
}
catch (e:Error){
sampleText.text = e.toString();
}
}
private function changeText(){
try{
sampleText.text = Text;
oldText = Text;
}
catch (e:Error){
sampleText.text = e.toString();
}
}
}
}
Basically the file checks onEnterFrame for any changes in the vars at the top (BackColour,
TextColour, & Text). If it notices a change it sets the appropriate colour / text.
I have even tried taking this out of a class, and sticking it on the first frame of the root timeline. It seems like either I am missing something fundamental about flash's display object heirarchy, or that functionality has been removed form the flash 9 ocx...
Any help would be greatly appreciated. Cheers
SetVariable() Problems
Hi, I have a clip that has 120 frames and I wish to pass a variable from Javascript that has a value of 1- 120 to use as a marker. Here is the JS code:
movie.SetVariable("stopValue", 75);
Here is what I have in SWF clip:
onClipEvent (load) {
gotoAndStop(_level0.stopValue);
}
I have also used other methods such as having the code outside the clip like:
_level0.clip.gotoAndStop(stopValue);
Both work when the pages is loaded fresh, but if you hit F5 (Refresh) the browser page the variable value is lost or not repassed or something. Can anybody please tell me why this is happening?
Thanks,
Rob.
SetVariable Problems
I am using setVariable to pass the results of an LMS query back into flash. The process works like this:
Flash sends LMS commands using fscommand to javascript via a vb handling script (DoFSCommand) - this a standard and well documented method.
Javascript handles the LMS commands and passes this onto the LMS. Some of the commands we pass require values from the LMS.
The LMS returns the values requested to javascript which then, using a setVariable function, passes them back into the flash movie.
The problem I have is that this works most of the time but on some occassions there are no values returned. This is a timing issue in flash. I know that passing values to a dynamic text field happens instantly, but I don't want to do this. I just need the variable and value, I have read that this takes longer for some reason?!!
I have _root.watch (variable, perform some function) for all the variables I need. I have also declared and initialised the variables on frame 1 of the root timeline.
on frame 15 of the timeline I have my fscommands and my _root.watch functions (don't ask me why, it just works if I place them further along the timeline??), I have also left an additional 15 frames to allow 'time' for the variables to be passed back (once again this may just be paranoia on my part!!). Even with all this, It does not work 100% of the time!
I must confess, I realise the need for _root.watch but don't fully understand it as there are no stop(); or functions that ensure if the variable has not changed it does not allow the movie to progress, or is this built in to the watch command? My feeling is that the problem lies with the watch command.
My apologies for the verbose nature of this posting but I'm hoping it provides most, if not all, of the information required for the experts out there.
Thanks in advance.
Regards
T.
SetVariable/Netscape 7
After a fair amount of beating my head against the computer, I have not be able to get the Flash javascript method SetVariable to work with Netscape 7. Of course, it works just fine in IE 6.
I did figure out that if you remove the OBJECT tag entirely and use only an EMBED tag, then it will work with NS7--SetVariable will pass a variable from the html file to the Flash movie. However if you do that, IE 5.5 and above won't work with SetVariable.
Has anyone else run into this and found a solution?
SetVariable Does Not Work In ASP.NET
Hi,
I have a dynamic text box in my flash movie with a variable myVar associated with it. When I use setVariable("myVar", "Text") from java script in ASP.NET, it does not work. However, the same swf file and java script code work as expected in standard HTML.
I've read in several forums that there is a problem with setVariable and ASP.NET but alas, no solutions were posted.
Help Please!
James
SetVariable To Nested Mc
setVariable target nested clip
--------------------------------------------------------------------------------
I'm passing variables from javascript to flash. the setVariable code works great for what i'm doing.
However, it will only pass the values to the root of the swf or to the root of clip1(the main movie). I NEED to pass the values into a clip2 nested inside the main movie.
Many attempts to target the nested clip 2 inside clip1 have failed.
--here is the syntax i'm using...
function fprocess(){
window.document.jstoflash.SetVariable("_level0.iclip1.iclip2.mytargetfield", cookie_stuff);
}
Any help would be geratly apperciated.
Thank You
Ike,
SetVariable Problems
I am using setVariable to pass the results of an LMS query back into flash. The process works like this:
Flash sends LMS commands using fscommand to javascript via a vb handling script (DoFSCommand) - this a standard and well documented method.
Javascript handles the LMS commands and passes this onto the LMS. Some of the commands we pass require values from the LMS.
The LMS returns the values requested to javascript which then, using a setVariable function, passes them back into the flash movie.
The problem I have is that this works most of the time but on some occassions there are no values returned. This is a timing issue in flash. I know that passing values to a dynamic text field happens instantly, but I don't want to do this. I just need the variable and value, I have read that this takes longer for some reason?!!
I have _root.watch (variable, perform some function) for all the variables I need. I have also declared and initialised the variables on frame 1 of the root timeline.
on frame 15 of the timeline I have my fscommands and my _root.watch functions (don't ask me why, it just works if I place them further along the timeline??), I have also left an additional 15 frames to allow 'time' for the variables to be passed back (once again this may just be paranoia on my part!!). Even with all this, It does not work 100% of the time!
I must confess, I realise the need for _root.watch but don't fully understand it as there are no stop(); or functions that ensure if the variable has not changed it does not allow the movie to progress, or is this built in to the watch command? My feeling is that the problem lies with the watch command.
My apologies for the verbose nature of this posting but I'm hoping it provides most, if not all, of the information required for the experts out there.
Thanks in advance.
Regards
T.
SetVariable And TCallLabel
Hi Guys,
Quick question here-- I've created a flash movie which is being embedded in a C# application. The application and movie are communicating back and forth through the flash-javascript interface.
So, the flash file just contains a main menu with seven items. Interacting with the app occasionally needs the ability to adjust the active area marked on the main menu.
So, as it stands, the app makes a SetVariable call (changing a variable called 'forceVar' to anything from 1-7), and then makes a TCallLabel call (to menuRedirect), a frame which calls a method on the menu that forces it to emulate the click of whatever button number forceVar is set to.
Here's the problem: If I set up buttons in flash to change sections based on a variable change and a call to that frame, it works with absolutely no issues.
Coming from the application, it gets very weird, very quickly-- after some extensive testing, it seems that making the two calls in sequence doesn't actually guarantee that they'll be completed in sequence . . sometimes the variable call seems to lag behind the label call. The buttons quickly fall out of synch with the menu items.
So, for the time being I've changed it so that the app buttons make calls to unique frames which have the new forceVar value hardcoded into the method to update the main menu. This isn't the cleanest or most manageable way to do it, obviously.
I have to admit, I haven't had the need to do this since flash 5, so is still the way this sort of communication is accomplished? Has anyone else run into this before, and does anyone know of anyways around it?
Thanks in advance for any replies--
SetVariable Through Pressing A Button?
I gave a button the following script:
set:
on (release) {
gotoAndPlay (124);
variable = 2;
Later I made a keyframe with
set:
if (variable = 1) {
gotoAndPlay ("Szene 2", 1);
}
but my PC keeps crashing when it reaches this very frame.
And Yet Another Javascript - SetVariable Question
OK,OK,OK... I have javascript recoginizing the movie object.
alert(parent.control_area.control.control);
Frame is control_area, Form name = control, Object ID Name = control.
Now I have a movie named 6_0_0_0_Area_Position that is embedded in the sixth frame which I named locator. The variable name is lat_dec. If it makes any difference the scene is called "GIS Control Panel".
I swear I've tried every combination known to man.
What I have is a Mapguide activex program in one of five frames. This activex program has an observer waiting for a ondigitized point to be enacted. This is going to make the server program find the point on the map and then send back Latitude and Longitude coordinates in both decimal degrees and degrees, minutes, and seconds. My old non-flash program worked because it was just filling text boxes through javascript on an HTML based page. Javascript appears to be a little harder time finding a buried variable in Flash.
And yes, I'm not proud. I'll take anybody's free work in finding a solution.....of course I'll tell the boss I figured it out, but hey, don't we all?
Javascript SetVariable Problem
Hi,
I need to do this simple thing- set a variable in a flash movie from JS, but the silly code doesn't wanna work. Here is the javascript code snippet:
..
function setModuleCount()
{
window.littlemovie.SetVariable("moduleCount", "10");
}
..
and the flash code is:
..
var moduleCount;
getURL("javascript:setModuleCount();");
..
But after that, I have verified that moduleCount does NOT get the value of 10 as it should get. What is missing? The flash code is written in a layer of a frame, and the <object> had id set correctly to "littlemovie". I've even tried to, within the setModuleCount function call alert(window.littlemovie.IsPlaying())) and that works..
/puzzled David
TROUBLE WITH Ns 7.0 AND Flash.SetVariable
Hi!
I am using NS 7.0 with Flash 6.0 r47 player.
When I am want to change some flash value from select,
in javascript console I have an error ".SetVariable is not a function".
I have this function and object:
function ChangeLocation(prostorija) {
//document.tlocrt.SetVariable("trenutni", prostorija);
mObject("tlocrt").SetVariable("trenutni",prostorij a);
}
<script language="JavaScript">
out='<OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"';
out+=' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"';
out+=' WIDTH="200" HEIGHT="240" name="tlocrt">';
out+='<PARAM NAME=swliveconnect VALUE="true">';
out+='<PARAM NAME=movie VALUE="../include/flash/tlocrt.swf#trenutni=<?=$play_vr_no?>">';
out+='<PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF>';
out+='<EMBED swliveconnect="true" ID="tlocrt" name="tlocrt" src="../include/flash/tlocrt.swf#trenutni=<?=$play_vr_no?>" quality="high" bgcolor="#FFFFFF"';
out+=' WIDTH="200" HEIGHT="240" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"';
out+='></EMBED></OBJECT>';
if (canIFlash(5)){
document.write(out);
} else {
document.write("<img src='include/images/tlocrt.gif' border='0' usemap='#tlocrt'>");
}
</script>
Any ideas please...
Cash
Flash Javascript SetVariable
i wanna dynamic load .txt info flash , and use javascript to control
which .txt(1.txt or 2.txt or.....my.txt) should be load into flash , what should i do ?
<script language="JavaScript">
function thisSendValue(){
var movie=window.document.a;
movie.SetVariable("load_my_file","my.txt");
}
</script>
in flash
-----------------------------
var loader_loft= new LoadVars();
if(load_my_file){
loader_loft.load(load_my_file);
.....
}
why it's can't work , plz help me
Setvariable And Link Question
Is there a way to set a text box equal to a string and have parts of the string become hyperlinks?
Im baically working on a photography section.
When a new swf (photo) is loaded, it sets a variable = to something like "by aaron at returntothepit.com"
I was wondering if I could make the "returntothepit.com" a link by using actionscript.
Thanks in advance.
Once Again.. SetVariable Not Working (is This A Known Issue?)
I can't even get it working in IE, let alone Firefox 1.5! This is frustrating.
Here's the actionscript in a frame:
Code:
fscommand("getCookie");
foob.text= playMusic;
And here's the Javascript:
Code:
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function musicPlayer_DoFSCommand(command, args) {
var musicPlayerObj = isInternetExplorer ? document.all.musicPlayer : document.musicPlayer;
if (command=="getCookie")
{
if (document.cookie == "noAutoPlay=true")
musicPlayerObj.SetVariable("_root.playMusic", 0);
else
musicPlayerObj.SetVariable("_root.playMusic", 1);
}
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
document.write('<script language="VBScript">
');
document.write('On Error Resume Next
');
document.write('Sub musicPlayer_FSCommand(ByVal command, ByVal args)
');
document.write('Call musicPlayer_DoFSCommand(command, args)
');
document.write('End Sub
');
document.write('</script>
');
}
What is the prob? Firefox reports a Javascript error, that SetVariable doesn't exist. IE just doesn't do anything. I'd be grateful for any help.. all I'm trying to do is get my Flash music player to read a cookie from the browser.. to auto-play or not. You'd think by now (Flash 8), they would've just given us a cookie object to read in cookies from the browser..
SetVariable - Timing Issues
I am using setVariable to pass the results of an LMS query back into flash. The process works like this:
Flash sends LMS commands using fscommand to javascript via a vb handling script (DoFSCommand) - this a standard and well documented method.
Javascript handles the LMS commands and passes this onto the LMS. Some of the commands we pass require values from the LMS.
The LMS returns the values requested to javascript which then, using a setVariable function, passes them back into the flash movie.
The problem I have is that this works most of the time but on some occassions there are no values returned. This is a timing issue in flash. I know that passing values to a dynamic text field happens instantly, but I don't want to do this. I just need the variable and value, I have read that this takes longer for some reason?!!
I have _root.watch (variable, perform some function) for all the variables I need. I have also declared and initialised the variables on frame 1 of the root timeline.
on frame 15 of the timeline I have my fscommands and my _root.watch functions (don't ask me why, it just works if I place them further along the timeline??), I have also left an additional 15 frames to allow 'time' for the variables to be passed back (once again this may just be paranoia on my part!!). Even with all this, It does not work 100% of the time!
I must confess, I realise the need for _root.watch but don't fully understand it as there are no stop(); or functions that ensure if the variable has not changed it does not allow the movie to progress, or is this built in to the watch command? My feeling is that the problem lies with the watch command.
My apologies for the verbose nature of this posting but I'm hoping it provides most, if not all, of the information required for the experts out there.
Thanks in advance.
Regards
T.
Javascript's SetVariable Command
Hello everyone, have been having a few questions lately. This one is about suing th SetVariable command to make the new variable you set using javascript to take effect immediately and change things that are dependent on it.
situation:
I have a text area named bob in my flash movie. a variable named variable is definded to have a value of "yo" when the flash movie loads, and then I have a command that does bob.text = variable; so when the movie first loads the text area says "yo".
I have javascript that runs when a link is clicked on the page, and it does this:
flashMovie.SetVariable("/:variable",
'hello');
it makes a variable called variable equal hello, and then sends it to the _root of the movie. However, the text area bob does not change because its value has already been set to the old variable and it still equals "yo". What shall I do? just doing what I have above will indeed change the value of the variable to hello, but I want the text area to also update once the variable is changed. Does anyone have any Ideas for me? I'd greatly appreciate the help.
[F8] Basic SetVariable Question
I am working on a number of elements in my movie that I need to be able to address dynamically at runtime. For instance I have a rather complicated (for me) gallery mc and would like to be able to perform it's "move off stage" routine when the nest item is selected. Since I will be able to predict the order the visitor chooses I need to assign a variable to that item and call on it somehow when I need it to go away.
How do you set a variable?
How do I apply an action (###_mc.gotoAndPlay(3) or better yet a tween class like blur.
Thanks ahead of time.
SetVariable Method In FireFox
Hi All
I am having a problem using the setvariable method in FireFox (works in IE 5 & 6). Can anyone spot what I am doing wrong?
My tags:
<OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codeBase="http://active.macromedia.com/flash/cabs/swflash.cab#version=6,0,0,0"
id='Flash' name='Flash'
style="
LEFT: 0px;
TOP: 0px;
POSITION: ABSOLUTE;
WIDTH: 100%;
HEIGHT: 100%;
Z-INDEX: 0;
VISIBILITY: visible;
">
<PARAM NAME="_cx" VALUE="21166" />
<PARAM NAME="_cy" VALUE="15875" />
<PARAM NAME="FlashVars" VALUE="21166" />
<PARAM NAME="Movie" VALUE="interface.swf" />
<PARAM NAME="Src" VALUE="interface.swf" />
<PARAM NAME="WMode" VALUE="Window" />
<PARAM NAME="Play" VALUE="-1" />
<PARAM NAME="Loop" VALUE="0">
<PARAM NAME="Quality" VALUE="HIGH" />
<PARAM NAME="SAlign" VALUE="" />
<PARAM NAME="Menu" VALUE="0" />
<PARAM NAME="Base" VALUE="" />
<PARAM NAME="Scale" VALUE="ShowAll" />
<PARAM NAME="DeviceFont" VALUE="0" />
<PARAM NAME="EmbedMovie" VALUE="0" />
<PARAM NAME="BGColor" VALUE="#FFFFFF" />
<PARAM NAME="SWRemote" VALUE="" />
<embed
ID="Flash"
NAME="Flash"
src="interface.swf"
loop="false"
menu="false"
quality="high"
bgcolor="#ffffff"
width="100%"
height="100%"
swliveconnect="true
align="middle"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</OBJECT>
my Code:
function F_SetVar(variable,value){
if(FlashObj==null){
FlashObj = getFlashMovieObject("Flash")
alert(typeof(FlashObj))
}
FlashObj.setVariable(variable,value)
}
function getFlashMovieObject(movieName){
if (window.document[movieName]){
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1){
if (document.embeds && document.embeds[movieName]){
return document.embeds[movieName];
}
}else{
return document.getElementById(movieName);
}
}
Safari SetVariable Is Undefined
This script, which takes variables defined by an onClick event in Javascript and pulls them into flash on multiple iframe levels, works great in IE and Mozilla on a PC...but Safari tells me the object is undefined:
Code:
<SCRIPT LANGUAGE=JavaScript>
<!--
function doPassVar(args){
var sendText = args;
window.document.myFlash.SetVariable("myVar", sendText);
if (top != undefined) {
if (top.nav != undefined) {
if (top.nav.document != undefined) {
if (top.nav.document.myFlash != undefined) {
alert('Found page and variable is: '+sendText);
top.nav.document.myFlash.SetVariable("myVar", sendText);
top.nav.document.myform.myfield.value = sendText;
}
}
}
}
}
-->
</SCRIPT>
Anyone know of a solution to SetVariable on Mac?
SetVariable, TCallLabel + Flash 7 + Mac
Hey all,
I'm trying to use JavaScript to communicate with my Flash movie using SetVariable and TCallLabel. This works well on Windows in both Firefox and Internet Explorer, all the way back to Flash 7. However, using Flash 7 on my old PPC Mac is problematic. When I try to call movie.SetVariable() I receive the following error: "SetVariable is not a function." I've used Firebug to verify my "movie" object is a valid flash object instance. Any advice would be much appreciated.
thanks
ExternalInterface And SetVariable Not Playing Well Together
So, I've got a couple of issues related to SetVariable, ExternalInterface, DocumentClass, and implicit property accessor methods. I know that SetVariable is somewhat deprecated, but there are times in javascript when I'd like to set a variable in flash rather than use ExternalInterface to call a method (more stylistically than anything else). According to all documentation I've found, SetVariable is supposed to still be a valid function call on a Flash object embedded in a webpage. But it's behavior is confusing at best.
1. It appears that "SetVariable" is still a reserved function name, which cannot be overridden by setting up an ExternalInterface.addCallback(). The add of the callback worked (no error or exception in flash), but calling it from javascript did not pass control to *my* function as expected, even though no javascript error/exception was thrown either.
2. I tried silly #1 because using the default SetVariable (which seems to still be there on the Flash object) didn't seem to be working to set public variables inside of the main ("root") DocumentClass object. The call from javascript didn't fail, but I couldn't seem to find in what scope in flash (if any) that the variable value was getting set, because it obviously was not inside my DocumentClass as intended and expected.
3. Moreover, what I want is to actually have an implicit accessor method (a "set") which is called when a variable is set on the Flash object. Ideally, I'd like to be able to say: "myFlashObj.varname = 'blah';", but I settled on "myFlashObj.SetVariable('varname','blah');". The point is, I want there to be an accessor method that responds to the setting of the varname property.
Also, related to this, actionscript 3 did away with "watch", so I don't know any other way to properly have my DocumentClass respond to the "event" of one of its properties being set unless I use an accessor method.
I've been wholly unsuccessful at any of the above points. My only workaround thus far is to just have a function (named "SetVariable2" for instance) that I call from Javascript to accomplish this. This works, but is the ugliest of all my attempts.
Any thoughts or help?
|