Update vars sent to Flash WITHOUT 'GET' or loadvars?

  • Head In A Pan
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13
  • Loc: Sydney

Post 3+ Months Ago

OK - could somebody simply tell me if this is even possible -


My main.swf is embedded in my index.html page.

It loads external swfs in ONLY WHEN a HTML button, sitting outside my main.swf but ON index.html is clicked - posting it's variable/value to my swf?

So what I am saying is - Flash will not be functioned to do it's loadVars magic, I want Flash to be ready & waiting for a new variable to arrive at any given time - THEN action a function depending on the value of the variable.

Does this make sense to anyone? ;)

I'm just not sure on the limitations of Flash - the program where I thought absolutely ANYTHING is possible.

If it's not possible then I will go around this problem another way.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

In the Flash Movie, use the following to register a function Javascript can call, with Flash.
Code: [ Select ]
flash.external.ExternalInterface.addCallback
(methodName:String, instance:Object, method:Function)
  1. flash.external.ExternalInterface.addCallback
  2. (methodName:String, instance:Object, method:Function)



For instance, if the Flash Movie has a function named "react", the above call in Flash would look like
Code: [ Select ]
import flash.external.ExternalInterface

var react:Function = function(val:Object) {
 ExternalInterface.call("alert", val);
}

ExternalInterface.addCallback("swfReact", this, react);
  1. import flash.external.ExternalInterface
  2. var react:Function = function(val:Object) {
  3.  ExternalInterface.call("alert", val);
  4. }
  5. ExternalInterface.addCallback("swfReact", this, react);


This would give the swf a method name "swfReact" for Javascript to use.

Code: [ Select ]
<script type="text/javascript">
var swf = document.getElementById('myswf');
swf.swfReact("somthing");
</script>
  1. <script type="text/javascript">
  2. var swf = document.getElementById('myswf');
  3. swf.swfReact("somthing");
  4. </script>


Which, in this example would just use another method of ExternalInterface to pass the argument to Javascripts alert method.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 25 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.