FORUMS: list search recent posts

Passing variables via javascript

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
shayan malik
Passing variables via javascript
on Jun 7, 2008 at 12:02:51 pm

well, i hav an html application that will embed a swf file and will also pass some variables (strings) via JavaScript functions. swf file is to be created using Action Script 3 that will use those variables (that were passed from javascript).
i have searched alot and got a javascript method setvariables(varname,var_value) but unfortunately it works with AS2 (or i dont know how to use those variables in AS3 as it is not working in as3.) :(
kindly some one help me in finding a way to pass variables via javascript and then sucessfully use them in my swf application.

Return to posts index

Pieter Helsen
Re: Passing variables via javascript
on Jun 7, 2008 at 10:22:24 pm

Are you talking about SWFObject?

It's hard to help if I don't know what kind of javascript you're using. However, some of the things I would suggest looking into if you are, indeed, using SWFObject.

- Did you upload the SWFObject.js file to your server?
- Did you import the SWFObject.js file in your .html page?
- The correct syntax is addVariable("name", "value");
- How are you accessing the variables in flash? (they should be in the _root timeline and you can just access them by the name you gave em in your .html file)

Kind regards,

Return to posts index

shayan malik
Re: Passing variables via javascript
on Jun 9, 2008 at 4:55:41 am

initially i was using SetVariable method for passing variables from javascript to flash as follows:



then i was able to use the variable "MyVar" in my flash application using watch method:

myFlash.swf (action script 1.0 & 2.0):

// An empty string variable
var MyVar:String = "";
// The callback function to be executed when the variable changes
watchCallback = function (id, oldval, newval):String {
// Here you place the new value in a text field for display
tbMyVar.text = newval;
return newval;
};"MyVar", watchCallback);

the above codes were working fine..but when i use the same logic in action script 3 then it is giving an error tht "access of undefined property '' "

i hav also used swfobject.js file as follows:

it is giving an error tht "swfobject is undefined". i have placed swfobject.js file,myFlash.swf file and html file in the same folder.

kindly tell me where i m making mistake..?? :(


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved