Link to home
Start Free TrialLog in
Avatar of acseven
acsevenFlag for Portugal

asked on

Control Flash SWF from HTML (and/or ASP) menu (providing vars)

Hi,

  I am making a flash movie that has most the content (text, imgs, etc..) in the site I am building. This swf is included in a CSS based page, that has a menu (<a> tags, basically).

   As the content in the flash movie mentioned earlier is created "on the fly", using actionscript, I  want to know how to control the SWF movie using the html menu. I can tell you that I know how to make the html menu play/stop/gotoframe in the flash movie, so what I needed is something a bit different.

   What I want is to flash to pick up a click in the menu bar, and receive the click with a variable, so that flash can redirect that instruction to the specific funtion it'll have to make in the movie. So basically, here's an a example of one of the functions I'll need to implement:

 > click LINK1
 > send variable LINK1
 > flash receives LINK1
 > flash loads an SWF file named LINK1.swf onto a scrollpane.

I would very much appreciate *code* for this, all ASP/JS coding (this is very important, as I dunno almost nothing about those), and regarding the linkage of the variable to the import of the SWF file.

Important bit: the page couldn't refresh (mainly because I have other animations running that I don't want to break the animation at mid-play), hence the ASP...

also, this is kinda urgent.:S

thank you very much in advance ;)
Avatar of apg88
apg88

This link says it all(with javascript). http://www.iota-six.co.uk/html/32_flash.htm
Avatar of acseven

ASKER

Hi, thanks for the link, but besides not answering fully to my question, the thing doesn't work using Firefox (JS doesn't make anything in the video, only in IE)... i need this to be cross-browser, obviously... :S

nice link though, thanks anyway ;)
Yes, I noticed the firefox thing.
The problem with javascript is that it is different with every browser. Hopefully in one of the later builds of firecix, this will be fixed.
The problem basically is how the Flash object is being referenced, and, as far as I know, has always been a difference between Microsofts JScript, and NS/Mozilla's JavaScript.  Personally, I don't see this as a "bug" that will be fixed.

Basically IE accesses Flash via the "document" object, and NS/FireFox use the "window" object

Here is a slightly more comprehensive tutorial, with IE detection:
http://www.moock.org/webdesign/flash/fscommand/
As far as detecting when a variable has passed, I think you could use the Flash MX function Object.watch() which will trigger a function when the variable changes value
Avatar of acseven

ASKER

Hi again,

thanks for the link and ideas, but as I don't have much free time to look at this extensively, I looked around based on your suggestions [keywords], and found this tutorial:

http://www.mustardlab.com/developer/flash/jscommunication/

could you please tell me if u can implement this?  if successful, please explain a bit better on what is needed...

sorry for the trouble, but like I said, it is kinda urgent, and I am doing tons of other stuff at the same time...

thank you very much ;)
> could you please tell me if u can implement this?

It's perfectly implementable in so far as the tutorial you have found comes complete with a fully functional downloadable example (with source code).  What more do you need?
Avatar of acseven

ASKER

yes, you're right, I should have been more specific, I apologise:

The problem is that that example compiles just fine, but inserting the code in a project of mine (like the one in ex. movie.fla, code in first frame, included or not), I get execution errors, which I don't know why they occur in my fla and not in this one:

Quote:
_______________________
**Error** Scene=Scene 1, layer=actionscript, frame=1:Line 2: There is no property with the name '$jsvarlistener'.
Stage.$jsvarlistener = new LocalConnection();

**Error** Scene=Scene 1, layer=actionscript, frame=1:Line 3: There is no property with the name '$jsvarlistener'.
Stage.$jsvarlistener.setVariables = function(query) {

**Error** Scene=Scene 1, layer=actionscript, frame=1:Line 11: There is no method with the name '$jsvarlistener'.
Stage.$jsvarlistener.connect(_level0.movieid);

Total ActionScript Errors: 3 Reported Errors: 3
____________________________

sorry again :S






Hmm...  I take my last statement back - it isn't "perfectly implementable!"

The short answer to your problem now is to change the publish settings to ActionScript 1.0 rather than ActionScript 2.0, but that may effect other areas of your coding.

The long answer is explained here:
http://rantworld.blogs.com/flashlit/2003/12/quirks_of_dynam.html

Basically, the upshot is that your tutorial implements a dynamic variable assigned to LocalConnection - however, Macromedia in their wisdom, have now made the LocalConnection class non-dynamic.  This means that you can't just assign new values to it (which the tutorial uses).

Of the two solutions, probably the better one is to define a dynamic sub-class rather than to amend the LocalConnection class provided with Flash MX 2004 (this seems to me like a hack, and something that may have unforseen implications in the future).

With this in mind, how do you now want to move things forward acseven?
Avatar of acseven

ASKER

thanks muso, the answer should lie somewhere.. :D

well, truth is that I don't know that much scripting to understand how to do that, or how to even start understanding how to do it.. and right now I haven't got time to look at this as I really would like to...

If you could help me out only with this code revision, it would be great, because I have already made the rest of the scripting in the flash movie, being this part (receiving the variables) the only thing left ...

either way, thank you very much for help until now ;)

Okay, I'll revise the code for you this evening.
Avatar of acseven

ASKER

Hi, sorry to bother, but any luck with the revising?

if not, or if too much trouble, I'll try to do a local connection, replacing the HTML menu by a flash menu...

thank you ;)
>  Hi, sorry to bother, but any luck with the revising?

I'm terribly sorry!  I hadn't forgotten - just got a bit overloaded with other work :-(

I promise that I will have something tonight - and don't worry, it isn't too much trouble at all!

muso
Avatar of acseven

ASKER

thanks! ;)
ASKER CERTIFIED SOLUTION
Avatar of muso120999
muso120999

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of acseven

ASKER

hi, thanks for the code, I'll implement on the weekend. I will be away, but I'll let you know smtg on sunday night or monday ;)
Avatar of acseven

ASKER

you probably tested it, it works! thank you very much!

I now have another problem, but I guess it's best to open a new question for this one ;)=

thanks again for your help ;)
> you probably tested it, it works! thank you very much!

I usually do (unless otherwise specified); saves embarassment ;-)

Glad to help!

muso