Passing dynamic variable from html to Flash
I know this is pretty simple but all that I have read doesn't make much sense to me. I have one swf calling another swf that I have embedded into an htnl. In other words just calling another html page in a seperate window.
In one.swf (runing in broswer) I use the below to call another html page passing the variable NewLessonArray. This contains an array of completed chapters.
// LOADING URL
var NewLessonCompleteArray:String = LessonCompleteArray.toString();
navigateToURL(new URLRequest("two/index.html?CurrentLessonInfo=<NewLessonCompleteArray>"), "_blank");
In the receiving swf I want to retrieve the passing parameters.
two.swf
// Getting the parameters passed
this.loaderInfo.parameters.toString()
All that is returned that I can see is object Object. But since I am passing on a address line into another swf embedded in a html page I am unable to determine that correct syntac for retrieving the information.
Any suggestions? This has got to be pretty simple... I think.
THANKS
What you are trying to do is not extremely difficult to do, but it is not something I would consider as being simple. With Andrei's approach you should be able to take the url String and dissect the parameters from it using String methods, like split().
As for the loaderInfo end of things, you are not passing the parameters to the swf file, you are passing them to the html page. So the loaderInfo won't have any info for you regarding the url parameters. The loadInfo would typically get parameters via the FlashVars parameters passed in in the html's swf embedding code.
Here are some other solutions that you might consider. I have not dealt with these myself, they are merely in my collection of useful info, so you might have to experiment to get them working. One is a link to a class-based approach and the other is an approach that use swfObject embedding to dynamically add the parameters as FlashVars to the embedding code....
http://mikethenderson.com/2009/02/as3-return-query-string-value-version-2/#more-105
OR
In your HTML:
var flashvars = {};
if (swfobject.getQueryParamValue("aParameter")) {
flashvars.param = swfobject.getQueryParamValue("aParameter");
swfobject.embedSWF("myMovie.swf", "myContent", "550", "400", "9.0.0", "", flashvars);
And the param variable will be available as a FlashVar to your movie:
var theParam = loaderInfo.parameters.param;
Similar Messages
-
How to pass a variable from HTML to Flash
I have built my flash ad banner in Flash 9 and now want the
HTML code to pass the url over to the flash movie that it should
jump to when clicked.
The info in the help file seems out of date for the latest
HTML template as it uses mainly JavaScript to get round IE's
dreadful embeding issue. So my problem is, how do I pass a variable
from the HTML to the actionScript specified int he Help file
(running on a full screen button) as shown below?
myButton_btn.onRelease = function() {
if (clickTAG.substr(0, 5) == "http:") {
getURL(clickTAG);
via the html code now used by Flash 9 which is like this:
<!-- saved from url=(0013)about:internet -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Advert_long</title>
<script language="javascript"> AC_FL_RunContent = 0;
</script>
<script language="javascript"> DetectFlashVer = 0;
</script>
<script src="AC_RunActiveContent.js"
language="javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 115;
// -->
</script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!--
Coping
with
Growing
Audio
Series
Theraputic stories
for children aged
4 to 9
-->
<script language="JavaScript" type="text/javascript">
<!--
if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
var hasRightVersion = DetectFlashVer(requiredMajorVersion,
requiredMinorVersion, requiredRevision);
if(hasRightVersion) { // if we've detected an acceptable
version
// embed the flash movie
AC_FL_RunContent(
'codebase', '
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0',
'width', '120',
'height', '600',
'src', 'Advert_long',
'quality', 'high',
'pluginspage', '
http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'Advert_long',
'bgcolor', '#ffffff',
'name', 'Advert_long',
'menu', 'true',
'allowScriptAccess','sameDomain',
'allowFullScreen','false',
'movie', 'Advert_long',
'salign', ''
); //end AC code
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be
placed here.'
+ 'This content requires the Adobe Flash Player.'
+ '<a href=http://www.macromedia.com/go/getflash/>Get
Flash</a>';
document.write(alternateContent); // insert non-flash content
// -->
</script>
<noscript>
// Provide alternate content for browsers that do not support
scripting
// or for those that have scripting disabled.
Alternate HTML content should be placed here. This content
requires the Adobe Flash Player.
<a href="
http://www.macromedia.com/go/getflash/">Get
Flash</a>
</noscript>
</body>
</html>You should use SWFObject to embed your Flash. Not only does
it make
embedding more straightforward, it makes passing query
parameters very easy.
Check out:
http://code.google.com/p/swfobject/
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
How to pass a variable from HTML to Flash 9
I have built my flash ad banner in Flash 9 and now want the
HTML code to pass the url over to the flash movie that it should
jump to when clicked.
The info in the help file seems out of date for the latest
HTML template as it uses mainly JavaScript to get round IE's
dreadful embeding issue. So my problem is, how do I pass a variable
from the HTML to the actionScript specified int he Help file
(running on a full screen button) as shown below?
myButton_btn.onRelease = function() {
if (clickTAG.substr(0, 5) == "http:") {
getURL(clickTAG);
via the html code now used by Flash 9 which is like this:
<!-- saved from url=(0013)about:internet -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Advert_long</title>
<script language="javascript"> AC_FL_RunContent = 0;
</script>
<script language="javascript"> DetectFlashVer = 0;
</script>
<script src="AC_RunActiveContent.js"
language="javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 115;
// -->
</script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!--
Coping
with
Growing
Audio
Series
Theraputic stories
for children aged
4 to 9
-->
<script language="JavaScript" type="text/javascript">
<!--
if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
var hasRightVersion = DetectFlashVer(requiredMajorVersion,
requiredMinorVersion, requiredRevision);
if(hasRightVersion) { // if we've detected an acceptable
version
// embed the flash movie
AC_FL_RunContent(
'codebase', '
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0',
'width', '120',
'height', '600',
'src', 'Advert_long',
'quality', 'high',
'pluginspage', '
http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'Advert_long',
'bgcolor', '#ffffff',
'name', 'Advert_long',
'menu', 'true',
'allowScriptAccess','sameDomain',
'allowFullScreen','false',
'movie', 'Advert_long',
'salign', ''
); //end AC code
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be
placed here.'
+ 'This content requires the Adobe Flash Player.'
+ '<a href=http://www.macromedia.com/go/getflash/>Get
Flash</a>';
document.write(alternateContent); // insert non-flash
content
// -->
</script>
<noscript>
// Provide alternate content for browsers that do not
support scripting
// or for those that have scripting disabled.
Alternate HTML content should be placed here. This content
requires the Adobe Flash Player.
<a href="
http://www.macromedia.com/go/getflash/">Get
Flash</a>
</noscript>
</body>
</html>You should use SWFObject to embed your Flash. Not only does
it make
embedding more straightforward, it makes passing query
parameters very easy.
Check out:
http://code.google.com/p/swfobject/
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
Passing a variable from text to flash
How do you pass a variable from a text file to flash?
Check out Help for loadVariables.
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
Can't receive variables from HTML to Flash in AS3 passed via URL (not Flashvars)
hey all,
can't seem to get AS3 to recognize variables passed via URL
(not Flashvars). i can get vars passed with Flashvars in the
javascript but I don't want to use that method. i'm simply
extending the .swf call with .swf?var=123 in the embed and on the
AS3 side i'm calling loaderInfo.parameters.var
thought this would work but doesn't. what am i doing wrong?
HTML:
<object
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
width="1024" height="768" id="main" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="main.swf?var=123"
/><param name="quality" value="best" /><param
name="bgcolor" value="#ffffff" /> <embed
src="main.swf?var=123" quality="best" bgcolor="#ffffff"
width="1024" height="768" name="main" align="middle"
allowScriptAccess="sameDomain" allowFullScreen="false"
type="application/x-shockwave-flash" pluginspage="
http://www.macromedia.com/go/getflashplayer"
/>
</object>
AS:
t = new TextField();
t.text = String(loaderInfo.parameters.var);
thx in adv.
michaelappreciate you were going for brevity, but i think the
answer's going to be hidden either in your complete html code or
your complete AS code. without seeing this i can only keep
guessing.
that said, my latest guess is that you're not passing your
variable within the AC_FL_RunContent function. there are two
properties set in this function - src and movie, which contain your
movie name, to which you can add any parameters you wish to pass.
eg.
'src', 'main?var=123',
'movie', 'main?var=123',
where main is the name of your swf and var the name of the
parameter you wish to pass.
if this function fails - if javascript isn't available in the
browser, for example, or AC_RunActiveContent.js is missing, then
the <object> tag you described is used. (this object tag is
sitting inside a <noscript> tag.) -
Passing a variable from html to java
I'm trying to pass a value from a coldfusion page to an applet.
ThanksI'm trying to pass a value from a coldfusion page to
an applet.
ThanksGood luck! So what part of the code is the problem, or what exactly is your question? -
Passing variable from html to flash
Hi I have built a flash movie with buttons...depending on
which button is clicked it loads a different flash movie due to
variable setting. I am able to set and call the variable s in flash
fine
But now i have an html page that needs to blend with this
flash...So i created buttons on my html page to look like the
flash...But when i click a certain button i want it to know the
variable going into the flashpage and load correct movie...not just
go to the beginning of my flash movie then user will have to choose
the button again...
How can i do this?
thank you in advance
renowell, between the post to forum and this link below i got
this to work for me
Just needed to know about the javascript....along with
putting the value/variable in url as posted..thanks
http://noscope.com/journal/2003/12/query_string
thanks for replying with suggestions!
reno -
Best way to pass vars from html into flash?
I've read a variety of pages that describe how to pass a variable into a flash movie (AS3, player = v9) from the html in which it is embedded. This page describes AS3 but neglects to mention what to do with the object and embed tags in the noscript section. Furthermore, I'm not sure the javascript I see generated in my page looks like the example there (the js in my page doesn't check AC_FL_RunContenta against zero). This page is quite long and appears to deal mostly with AS1 and AS2 approaches which I have used before and neglects entirely the newish javascript approach which appears to be used to embed flash these days (i.e., the javascript function AC_FL_RunContent).
I was wondering if someone could spell out the proper way to pass in a variable from HTML so that flash can see it in such a way that works even if javascript is disabled, in all browsers, etc., etc.
I've attached the HTML generated by the Flash IDE to this topic. Any help would be much appreciated.You'll have to search for that concise and thorough list of steps or figure it out using the information you now have, which is sufficient to get it done. It's not that hard--add the FlashVars in the embedding code in the three places and use the various examples you have links to to add the code in the Flash file to access and use the FlashVars.
Your Flash will be embedded in a web page depending on the visitors settings... if they allow javascript then the javascript portion will be used. If they don't, then either the object or embed sections will be used depending on their browser.
As far as javascript changes go, don't sweat 'em until you have a problem... use whatever code your Flash-created html page creates to embed the file in the page. -
Passing a variable from Captivate 5 to Flash CS5/ActionScript 3
I don't get it. Why is it so difficult to pass a variable from Captivate 5 to AS3/Flash CS5. I must be making it harder than it really is. I cannot figure it out. Can anyone help?
I have a variable (gpDone = 1) defined in Captivate 5 (it's a guided practice) on the last frame which will indicate that the learner has completed the guided practice file.
Now I want to pass that variable back to Flash/AS3 so I can evaluate whether I should show the Continue button so they can continue. They have to complete the guided practice before they can continue. If it is equal to 1, the Continue button will display. If it is not equal to 1, the Continue button will not display, but a message will display telling them they have to complete the guided practice in order to continue in the course.
Do I need to edit the Flash html? Or just put code in the Flash timeline or the associated AS file?
Help would be greatly appreciated. Thanks in advance.
CAHHaving the same problem...getting variable values FROM captivate to my inserted .swf (not widgets).
I can set the value from the .swf to the captivate using Object(parent.parent.parent.parent).captivateVariable but not the other way around.
Very frustrating.
I hope someone answers your query. -
LoadVars-using send to pass a variable from flash to php
For the life of me, I've tried everything:
I've researched LoadVars on Adobe forum, used David Powers'
books, googled 'flash to php', LoadVars, etc. and tried
sendAndLoad, send, and using $_POST, $_GET, $_REQUEST.
$HTTP_POSTVARS but I keep getting this same error. any advice
please?
I have a Unix server running Apache/PHP 4 - LoadVars worked
to load name-value pairs into an array -see thread)
My goal with this simple app is to prototype being able to
pass a variable from flash to a variable in php.
Parse error: syntax error, unexpected T_VARIABLE in
flash_to_SQL.php on line 5
Actionscript 2.0 code:
var c :LoadVars = new LoadVars();
c.testing = "123FOUR";
c.send ("
http://127.0.0.1/flash_to_SQL.php","_self","POST");
php code: (I also tried $_POST, $_GET, $_REQUEST.
$HTTP_POSTVARS)
<?php
//mysql 4.1.2, php 4 , NO mysqli
ecbo $_REQUEST ['testing'];
/?>var formData:LoadVars = new LoadVars();
formData.fname = "Name";
formData.send("
http://www.website.com/flash_php.php",
formData, "POST");
<?php
$name = $_POST['fname'];
echo $name;
?> -
Passing a variable from a movie clip to the main timeline
Hi,
I'm having trouble passing a variable from a movie clip in my
flash file to the main timeline.
I have a movieclip with the instance name IntroNav which
contains several buttons. Clicking a button sets the variable
"page" to a specific name, i.e. page = "home"
However, outside of the movie clip, on the main timeline I am
unable to call this variable, and "page" seems to have no value.
Can anyone tell me why this is and how to solve it?
ThanksUmm, yes ... declare your variables correctly.
var page:String = new String(); //proper complete
var page:String; //strict typing
var page:String = "home"; //stirct typing with value
declaration
Do not declare the variable in your buttons, you would have
to do so in every button and be constantly resetting the value.
Declare it on the main timeline at the lowest level. You do not
need to use it as a _global, you just need to resolve your path
issues. You can 'set' the variable value from a button, without any
problem, but you have to call to the variable correctly.
You do not 'name' a variable as "_root.page" , the '_root'
refers to the lowest level of the SWF or the main timeline, as does
a call to ' _level0' (that's a zero). If the variable is declared
on the main timeline, and you're calling from the MC/button or
anywhere you can refer to the variable by calling to it by
the proper path of '_root.page'
To set the variable from any of your button/MC instances
call:
_root.page = "value"; OR _level0.page = "value";
But you must have the varibale declared on the main timeline,
and only once and the playhead should be stopped or it will reset
the value to the default upon looping. -
How to pass a variable from one class to another class?
Hi,
Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
class A {
int a;
int doA() {
a = a + 1;
return a;
class B {
int b;
A r = new A();
r.a; // error: <identifier> expected. What does that mean ?
int doB() {
int c = b/a; // error: operator / cannot be applied to a
}Thank you!elaine_g wrote:
I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
class B {
int b;
A r = new A();
r.a; //syntax error
}Why? Class definition restricts what you can define within a class to a few things:
class X {
Y y = new Y(); //defining a field -- okay
public X() { //defining a constructor -- okay
void f() { //defining a method -- okay
}... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
This is also illegal syntax:
int doB() {
A r = new A();
r.a; // error: not a statement
}Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that. -
Is it possible to pass a variable from one animation to another?
I have multiple animations on the same page. I need to pass a variable from one to the other.
Animation One has this:
sym.setVariable("myVarOne", 1);
Animation Two has this:
var myVarOneInTwo=Edge.getComposition("EDGE-12345678").getVariable("myVarOne");
Seems like it should work, but kinda hard to tell. I put in:
console.log("myVarOneInTwo = " + myVarOneInTwo);
But I get: Javascript error in event handler! Event Type = timeline
So it seems that it doesn't like getting a variable from another animation.
Is there a way to pull a variable from one animation into another?Sorry also had to fix this:
var myVarOneInTwo=Edge.getComposition("EDGE-12345678").getVariable("myVar One");
To this:
var myVarOneInTwo=Edge.getComposition("EDGE-12345678").getStage().getVariable("myVar One"); -
Is it possible to pass a variable from a shell script back to an Automator action?
Is it possible to pass a variable from a shell script back to an Automator action?
For instance, if I assign a value of foo to $var1 in my shell script how would I retrieve/pass that value in the next Automator action. I see that there is a variable called "Shell Script" but I can't any information on how to use it.red_menace,
Thanks but I still don't understand how to pass a single value that was set in the UNIX scipt back to Automator has a variable. Take the example below, I write 4 varables to STDOUT and all 4 are stored in a variable named "storage". How do I assign 1 of these values to the Automator "storage" variable? For instance if I wanted to assign the value of $var2 to "storage" , how would I do that? -
Passing a variable from a non DB block to a DB block
Im getting the error FRM-41003 when I try to pass a variable from a search screen i created to a results screen which is tied to a DB block. Ive searched this error and nothing seemed to match exactly what Im dealing with. Is it possible to do this? Anybody run into this issue?
This is the code/trigger launched when the search button is clicked from the search screen that is not tied to a DB block.
IF :NRHR1.NUMBER IS NULL THEN
Message('Please enter valid search criteria.', NO_ACKNOWLEDGE);
ELSE
:Global.BUFFER_VARIABLE := :NRHR1.NUMBER;
NUM_SEARCH;
END IF;
--This is the procedure that is called
PROCEDURE NUM_SEARCH IS
BEGIN
IF :NRHR1.NUMBER IS NOT NULL THEN
:Global.BUFFER_VARIABLE := :NRHR1.NUMBER;
ENTER_QUERY;
:NRHR.NUMBER := :Global.BUFFER_VARIABLE;
DECLARE
blk_id BLOCK;
s_old_order_by VARCHAR(100);
s_old_where VARCHAR(100);
BEGIN
blk_id := FIND_BLOCK( 'NRHR' );
s_old_where := GET_BLOCK_PROPERTY(blk_id, DEFAULT_WHERE);
SET_BLOCK_PROPERTY( blk_id, DEFAULT_WHERE, 'NRHR.NUMBER = ''' ||:Global.BUFFER_VARIABLE||'''');
EXECUTE_QUERY;
SHOW_WINDOW('WINDOW1');
SET_BLOCK_PROPERTY(blk_id, DEFAULT_WHERE, s_old_where);
END;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND OR VALUE_ERROR THEN
MESSAGE('NO RECORDS');
HIDE_WINDOW('WINDOW1');
SHOW_WINDOW('SEARCH');
END;
I am using forms 10g
Edited by: user8606340 on Jan 28, 2010 8:17 AM
Maybe you are looking for
-
I have a whole bunch of 1080p high resolution footage taken in 60 frames per second and when I play it in quick time it jumps... the audio runs smoothly but the video jumps as if its playing every other frame like quicktime isn't recognizing that the
-
New driver (Nvidia), gdm won't load
I am trying to install the appropriate Nvidia driver. My computer has the NVIDIA NV17 GeForce4 MX 440 controller. Based on the instructions at https://wiki.archlinux.org/index.php/NVIDIA I attempted the alternate install because my card is old. Ev
-
BPC 7.5 NW Business Process Flow reopen function
Hi, i have e question concerning the reopen function whithin business process flows. I set up a business process flow with several steps and use the match step region function. The users are able to go through the bpf steps just for one plant and the
-
A friend of mine just bought a macbook air, loves it. BUT when we went to fire up iWeb it was no where to be found. What gives? Has anyone else come across this? Is iWeb to heavy a program for the air and they just didn't included it with iLife?
-
Cant set up email on my Blackberrey
Just got a new Blackberry - I had email on my old one, but cant set it up on my new one, it is telling me that my password and email addresses are wrong (they arent) Any ideas?