I'm working with this template:
http://www.kennybunch.com/blog/2009/09/embedding-javascript-into-a-swf/
But I need to be able to modify it. So far if I edit and republish the .swf just as simple as writing "TEST" on the page then the alert never functions.
I then tried starting by modifying what the alert says and changed the .js from "Hello" to "Output test" but it still said Hello. Thinking maybe its something else I modified the .as file and there too changed line 22 (the last line of commands) from:
ExternalInterface.call("hello");
to
ExternalInterface.call("output test");
Still the alert says "Hello".
What I'm ultimately trying to do is get the ability to put an external javascript onto our domain but since I don't have access to edit the html instead trying to use it as a workaround to manually monitor the outbound links on banners using this:
http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55527
Any idea as to how I can get those files to do what I need them to do? Or even why the most minute change is causing it to break?
the parameter in the brackets is the js function name
As long as those match then ExternalInterface works perfectly and you can write anything within the function you want.
maybe I'm not understanding the problem.....but don't change the function name in the JS at all. Or if you do then you change the parameter in the brackets of the EI call.
[edit] one thing I've found frustrating over the last few years is caching that even if a refresh of the Flash itself in a page, the externals seem to be in the browser or something so it only works if I clear the browser completely from a blank page or google.com or something. I waste so much time but I found that to be a huge issue for me when developing external to Flash pieces.
ExternalInterface.call("hello");
...is calling the JavaScript function called 'hello' -- check out the first code block on the first link you posted.
If you want to pass arguments to the function, you append them to the function call
ExternalInterface.call("some_function", "Hello");
Then you'd need a function in the JS:
function some_function(message){ alert(message); }
then tried starting by modifying what the alert says and changed the .js from "Hello" to "Output test" but it still said Hello.
This might be a browser cache issue.
yup
Ah I figured it was the browser but I completely closed and reopen I guess I'll try again clearing out the cache. Dumb.
Nope didn't work, and to clarify in the javascript:
it reads:
function hello() { alert("hello"); }
i changed it to
function hello() { alert("output test"); }
and the alertbox still says "hello"
p.s. Fuck gists I want a damn [code] command and the ability to single space!
Did you re-export your Flash file? I'm guessing (haven't touched Flash in years) that the Embed command is called at compile-time so changing the .js file afterwards won't have any effect.
--------------------------------------------------------^ look there. "Code block / Code" button when in edit mode.
p.s. Fuck gists I want a damn [code] command and the ability to single space!
was this ever solved?
I have to admit that one of my pet peeves is people who ask for help and then don't follow up to let you know if the problem was solved. That applies to more than one regular user on this board...
*makes the evil eye*
If something was solved I usually say Thanks. Hell I usually say Thanks even if it wasn't solved. In this case so far it wasn't solved and I can't spend too long at work trying to figure out a method for doing this.
No matter what changes I made to any of the files it broke instantly. If I even opened the .fla and then just closed it without even saving the file broke. I have no idea why. I do know its in legacy I think CS4 so maybe thats why. I might give it another shot when I have time but right now I've got advertisements to get completed.
That wasn't aimed specifically at you -- more a general observation. And I get annoyed about it not because I'm seeking gratitude (although obviously it's nice to get a thank you, too) but more because I'm interested in the outcome.
Very weird problem, though. It breaks even if you don't change the file? That's just bizarre.
Unfortunately this has exhausted my very limited knowledge of AS3. Persist is more likely to be able to help, I think.
post a zip file.....
there's a zip file in the kennybunch.com link at the bottom. thats what ive been working with.
yeah I just thought people could look at yours to see where you may have missed something