When Flash invokes a Javascript function via GETURL which refers to THIS, what object is THIS pointing to?
January 7, 2005 11:49 AM Subscribe
When Flash invokes a Javascript function via getURL which refers to this, what object is this pointing to? [More»]
I'm looking for a means by which a Flash object can affect its own presentation without requiring external code, and this doesn't seem to map to a standard DOM object. For example, this bit of ActionScript:
getURL("javascript:this.style.border='4px solid red';");
should produce the intended effect, but simply throws an error claiming this.style is undefined. I am perplexed.
I'm looking for a means by which a Flash object can affect its own presentation without requiring external code, and this doesn't seem to map to a standard DOM object. For example, this bit of ActionScript:
getURL("javascript:this.style.border='4px solid red';");
should produce the intended effect, but simply throws an error claiming this.style is undefined. I am perplexed.
kindall knows (apparently) more about it than I do, but I can back what he's saying: you can't pass
posted by yerfatma at 3:14 PM on January 7, 2005
this
from an anchor tag for some reason that's probably clearly (and sensibly) delineated in the specs. Well, you can pass it, but it doesn't work the way it does with every other element. In my experience.posted by yerfatma at 3:14 PM on January 7, 2005
You could assign the Flash object an ID, and then use something like
document.getElementId('flash').style.border = '4px solid red'
(Caveat: I have not testing this...)
posted by Khalad at 4:45 PM on January 7, 2005
(Caveat: I have not testing this...)
posted by Khalad at 4:45 PM on January 7, 2005
window.
When a method is called, 'this' points to the object the method was grabbed from. This is somewhat odd as it means that unlike in many programming languages:
object.foo();
behaves differently to:
var boing= object.foo;
boing();
If the case like this where 'boing' is called as a function instead of a method, 'this' doesn't get assigned to any object, so it's the global object which for a web browser is 'window'.
So, yeah, forget 'this' and use something along the lines of getElementById.
posted by BobInce at 5:56 PM on January 7, 2005
When a method is called, 'this' points to the object the method was grabbed from. This is somewhat odd as it means that unlike in many programming languages:
object.foo();
behaves differently to:
var boing= object.foo;
boing();
If the case like this where 'boing' is called as a function instead of a method, 'this' doesn't get assigned to any object, so it's the global object which for a web browser is 'window'.
So, yeah, forget 'this' and use something along the lines of getElementById.
posted by BobInce at 5:56 PM on January 7, 2005
« Older How do you stay focused on a project when you keep... | Where does Falun Gong get all its money? Newer »
This thread is closed to new comments.
posted by kindall at 12:24 PM on January 7, 2005