TwelvestoneBack End

Help putting this javascript inside of flash


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
Media44
 
2012-02-01

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?

Storm
 
2012-02-01

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.

Stickman
 
2012-02-01

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); }

Stickman
 
2012-02-01

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.

Storm
 
2012-02-01

yup

Media44
 
2012-02-01

Ah I figured it was the browser but I completely closed and reopen I guess I'll try again clearing out the cache. Dumb.

Media44
 
2012-02-01

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!

Stickman
 
2012-02-01

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.

scudsucker
 
2012-02-02

--------------------------------------------------------^ 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!

persist
 
2012-02-02

was this ever solved?

Stickman
 
2012-02-02

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*

Media44
 
2012-02-02

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.

Stickman
 
2012-02-02

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.

Storm
 
2012-02-02

post a zip file.....

Media44
 
2012-02-02

there's a zip file in the kennybunch.com link at the bottom. thats what ive been working with.

Storm
 
2012-02-02

yeah I just thought people could look at yours to see where you may have missed something

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneBack End

Help putting this javascript inside of flash