PDA

View Full Version : Passing Javascript strings into Flash movie


surfinglilbro
10-01-2005, 09:20 AM
I'm generally trying to make a blog. So I've tried declaring string variables in between the <heads> section like this:

<script type="text/javasrcipt">var blogcontent = "something something."</script>

So I'm trying to get it to be dispalyed in my flash movie like so:

_root.somewhere.htmlText = blogcontent;

Now the problem is I don't know how to tell the flash movie to reach out and get the the javascript variable and display it. I've tried the getURL; getProperty commands, but it don't work. :( The only progress I've made after spending hours staring at tutorials and forums is that I've to set the swLiveContent to equal true to allow the flash to communicate with javascript.

Please help!!

oldnewbie
10-02-2005, 01:47 AM
SetVariable...

http://www.macromedia.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html

surfinglilbro
10-03-2005, 10:46 AM
Thanks "oldnewbie"...hmm...paradox. :D I read up the article and tried to apply it. But I still doesn't work. In the flash I did something like this:
var BLOG;
myLeftMargin = 10;
_root.bg.createTextField("theText", 1, 10, 10, _root.bg._width-(2*myLeftMargin), 100);
_root.bg.theText.wordWrap = true;
_root.bg.theText.html = true;
_root.bg.theText.htmlText = BLOG;
And in the webpage something like this:
<script language="JavaScript">
var movie = window.document.movie;
movie.SetVariable("BLOG", "If this shows. Then it works.");
</script>
Am I doing something wrong here? :confused: I seem to be missing the beef patty in the beef burger I'm trying make!! ARRGGHHH!!! :mad:

oldnewbie
10-03-2005, 02:32 PM
A little more complex than just that...

You should attach your testing .fla (along with your .html) zipped up and in a MX only format (or lower), not MX2004, and I'll set it up for you...

surfinglilbro
10-04-2005, 10:17 AM
"Ooo!!! Thanks!!"
Here's the file, thanks!! Really appreciate this!! :D

oldnewbie
10-04-2005, 04:21 PM
Here ya go!

I've move your movie elements to frame 2, and added a stop(); action, because there's a delay between creating a dynamic textfield and assigning some text to it.

I've also corrected your .html and commented it...

That said, you could possibly achieve the same results with appending a simple query string variable or using FlashVars...

http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14253#querystring

http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_16417

surfinglilbro
10-06-2005, 05:38 AM
but it still doesn't work...kinda starting to understand...I published the flash file and opened the html file...but no text appeared in the text field!! I've checked the URL and I don't think there's anything wrong...btw...I tested it on both Mozilla Firefox and Internet Explorer 6 and still doesn't work.

And why is it you put in
<!-- Hide JavaScript from old browsers// // done hiding -->
Why do you want to hide it?