Javascript to Flash communication doesn't work

后端 未结 2 1388
闹比i
闹比i 2021-01-26 08:05

I\'m trying to control a flash player from javascript, i did as i saw on the internet and i get an \"not supported\" error

here what i\'ve wrote:

on js:

2条回答
  •  后悔当初
    2021-01-26 08:24

    Several things in addition to the previous recomendations:

    You'll need to make sure your flash movie has

    
    

    in the embed code. If that doesn't work, try logging out the function in the javascript to make sure it exists before calling it as in

    var x=getFlashMovieObject("flashmovie");
    console.log("function", x.Setvariable);  // see what you get in your console log here
    

    If you see undefined in the console, chances are you have a sequencing issue and will need to change your order of execution to make sure your swf exists and the callback has been added before it's called. A lot happens in that split second in initialization and you want to make sure things happen in the correct order.

    lastly, if this still doesn't work, there may be a security problem which you can quick fix by adding

    Security.allowDomain('*');
    

    Just under your class definition (or wherever you are storing your code) in the actionscript. If this last item fixes the problem, you might want to look into Security.allowDomain , particularly if you are using ExternalInterface and you might be worried about cross site scripting attacks. In most cases, this is fine but it can end up being very bad if your swf has access to your database, will be loaded by other sites, or areas of your own site that should be secure, so use the global solution above only with caution.

提交回复
热议问题