ExternalInterface troubles with callBack!
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: ExternalInterface troubles with callBack!

  1. #1
    Member
    Join Date
    Nov 2003
    Posts
    90

    ExternalInterface troubles with callBack!

    Alright guys, I have been researching the ExternalInterface for the past couple of days, and I think it would really be good for what I'm trying to do with a project of mine.

    In this project, the user reads information about a subject, then is quizzed at the end. The quiz is made in flash, and works 100% fine (it imports an XML file and then builds itself accordingly). However, the way I'm doing it now, I would have to compile a new flash movie to reference each XML file, and obviously that is a waste of time. On the quiz pages, I want to make javascript code that will, upon loading of the page, call that function in the flash movie to load the XML file that has the questions about the section. How can I do this? I am lost as to:

    1) Where to put the Javascript
    2) How to get the callBack to work (I know you can make a function external with the line ExternalInterface.callBack("myFuncForJava",null,fl ashFunction), but I do not know how to get JavaScript to reference my flash movie)

    Any help on this would be MUCH appreciated. Thanks in advance

  2. #2
    Why don't you just import a parameter that indicates which XML document to call (done from your swf embed)? This would require you to set up a series a variables in your swf equal to each subject matter.

    So, lets say you have four subjects: Math, English, Science, and History. If your wanting to load the Math quiz, in your embed you would pass the parameter Math with a value of true.
    Code:
    //Using swfObject to embed you movie your embed would look like this -
    <script type="text/javascript">
    // <![CDATA[
    var so = new SWFObject("Quize.swf", "", "430", "225", "8", "");
    	/*-- To activate quiz set subject to "True" --*/
    	so.addVariable("Math", "true"); 
    	so.write("flashcontent1");
    // ]]>
    </script>
    Then in your swf just establish a variable URL and set a series of cases or else(if) statements for each subject. If Math is == true then make URL = math.xml. And finally, when you load your XML object, just replace your url string with the variable "URL".

    You could define each subject variable in a separate xml document but if you're only dealing with 3 or 4 subjects, that might be a bit overkill.

    Hope I haven't confused the issue.

    Best of luck!

  3. #3
    Member
    Join Date
    Nov 2003
    Posts
    90
    I have a few questions about that... first, don't you need to install certain files to the domain to use an SWFObject in Javascript? Secondly, it would be far better for me to have a function callBack into the Flash movie, because I'm actually developing a training module with different categories, and the types of categories can change at different times, so it would still require that I recompile to meet these new needs.

    Do you know how I could get this working The callBack that is.

  4. #4
    Quote Originally Posted by Giblaz
    ...don't you need to install certain files to the domain to use an SWFObject in Javascript
    Yes, there is one script you will need to reference. Info here: http://blog.deconcept.com/swfobject/

    Sounds like your developing a SCORM - Sharable Object Reference Model: http://download.macromedia.com/pub/s...rm_flashlo.pdf

    Here info that should assist you with what you're looking to achieve:
    http://www.communitymx.com/content/a....cfm?cid=0922A

    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com