1

I'm using JQuery with the jQuery flash plugin and trying to send a JS call back to the flash, I keep running into "xxx is not a function" so apparently something is off. I'm new to JQuery and very new to this jquery flash plugin and just can't quite wrap my head around what I am doing wrong.

Here's where I'm lading up the flash:

<div id="tagimgback">
<script language="javascript">
$(document).ready(function(){
$('#tagflash').flash(
    {
      src: 'tagflash',
      width: 200,
      height: 200,
      flashvars: {theYear:'2010',theTagNumber:'123'}
    },
    { version: 8 }
);

});
</script>
</div>

And here's where I'm trying to call it:

$("#tagflash").gotoNewFrame(theTagNumber);

gotoNewFrame is an AS function within my flash. I know the function works as I've been able to test it prior to bringing jQuery into the mix.

4
  • Aha, okay so I didn't realize I needed a wrapper div with the same tag to replace the flash into. Now that I added that, I no longer get the "undefined" error, and now I get "flashObject.sendTextToFlash is not a function" even though it is clearly defined in my AS code. Commented Mar 16, 2010 at 18:37
  • When you say "I've been able to test it prior to bringing jQuery into the mix"; how did you call it then? Commented Mar 16, 2010 at 18:50
  • Using this JS provided from adobe, which actually doesn't work in IE at all. For that and several other reasons I moved my JS to jQuery and now its not working on either browser (although jQuery did fix ALL of the other issues). Here's the adobe JS: function getFlashMovie(movieName) { //var isIE = navigator.appName.indexOf("Microsoft") != -1; return (isIE) ? window.getElementById(movieName) : document[movieName]; } getFlashMovie("tagflash").sendTextToFlash(line1,line2,line3,line4,line5,line6,yearText,startNum,tagColor,theTagNumber); Commented Mar 16, 2010 at 19:01
  • 1
    were you able to solve the "undefined function" error.. I am also getting the same error! Commented Mar 6, 2011 at 18:02

3 Answers 3

4

$('#tagflash') returns a jQuery object set, rather than your element.

If you want to call a custom method on your object (instead of a method supported by the jQuery object), I think you need to first get your object via a call to the jQuery object Get method, like such:

var flashWrapper = $('#tagflash object');  // returns a jQuery object set
var flashObject = flashWrapper.get(0);     // should return your flash element object
flashObject.gotoNewFrame(theTagNumber);

Note that it looks like the jQuery Flash plugin injects an Object tag into the target div, so you actually need to use #tagflash object as your selector to access the flash object.

UPDATE: Make sure that you have published the method via a call to the ExternalInterface class in your action script too:

ExternalInterface.addCallback("gotoNewFrame", callFromJavaScript);

If all you are trying to do is call a method when your flash movie first loads, why not bind to the onLoad event and call gotoNewFrame within your action script? You've just passed the tagNumber in as a parameter when you called the flash method, so the value is already available..

Sign up to request clarification or add additional context in comments.

8 Comments

Do you have a div with id 'tagFlash'? The only reason that flashObject would be null is if there is no element on the page with that id.
Okay that makes sense... see my additional comment above about adding the div
The purpose of using Javascript to call the flash is that I am using the flash to display a preview of the tag, and it is updated automatically at the user selects various options on the page. Each option selected triggers an update to the flash to change the tag accordingly.
sure, that makes sense. did changing the selector to target the object tag help?
now I am getting "document.getElementById("tagflash").gotoNewFrame is not a function. Grrr!!!
|
0

Assuming #tagflash really exists (and you don't mean #tagimgback instead) you should try this.

document.getElementById("tagflash").gotoNewFrame(theTagNumber);

No need for jQuery here. As $("#tagflash") returns a jQuery object (wrapper around the real dom element) which is an unneeded wrapping here that only costs ;) cpu-time

3 Comments

With this one, I get "document.getElementById("tagflash") is null
I ask again does an element with id tagflash even exist?
Okay that makes sense... see my additional comment above about adding the div
0

I got the same problem, to fire and recieve listener events between javascript and flash.

The solution was to use AC_OETags.js file from Adobe as embedd script instead of JQuery flash.

The trouble based on a race condition when the flash builds the javascript callbacks in the browser. This is not handeled correctly by a straight embed for some reason.

<div>
<script>
// Major version of Flash required
var requiredMajorVersion = 10;
// Minor version of Flash required
var requiredMinorVersion = 0;

var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
AC_FL_RunContent(
"src", "tagflash",
    "width", "200",
    "height", "200",
    "id", "myTagFlash",
    "quality", "high",
    "bgcolor", "#FFFFFF",
    "name", "myTagFlash",
    "allowScriptAccess","allways",
    "type", "application/x-shockwave-flash",
    "pluginspage", "http://www.adobe.com/go/getflashplayer",
    "flashvars", "templateData=theYear:2010&theTagNumber:123"
);
</script>
</div>

Then you can do: (works in IE, FF, Safari, Crome,++)

$("#tagFlash").gotoNewFrame();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.