Flash Embed Dynamic XY Coordinates

Hello all -

I am having an issue, I need to know if there is a way that when a swf is embedded into another page, ie a 300x250 flash banner ad in an html page, is there a way that the Java or the Flash can know where it has been placed on that page?

Does that even make sense? I need my Flash piece to be able to expand up, down, left or right but don’t want to make four different files, would love for it to be done dynamically. Any suggestions?

Thanks in advance

When you say “expand” do you mean you need the Flash element to be resizable?

And you can definitely figure out where your Flash element is on a page with javascript.

[quote=digitalmatt;2359088]When you say “expand” do you mean you need the Flash element to be resizable?

And you can definitely figure out where your Flash element is on a page with javascript.[/quote]

Not resizable, on roll over, the Flash piece expands out to double in size, I need to know if its on the left or right side in order to tell it to expand left or right.

Thanks

My apologies, but I’m not clear on what you need. Is there anyway you can show me?

I suppose the expansion part doesn’t matter because I have that taken care of in Flash so you can ignore that.

I just need to know a way that when someone puts my Flash ad on their site it can read where on the page it has been placed. Some type of coordinates to be sent, make sense?

I think so. What I would do is wrap that Flash banner ad in a div. Give the div a unique id like “flashObj” or something. Write a javascript function to be called when the page loads. The function should be trying to get the “left” and “top” value of the div. So it the javascript might look something like this:



window.onload = function() {
     var theDiv = document.getElementById("flashObj").style;
     var top_pos = theDiv.top;
     var left_pos = theDiv.left;

     alert(top_pos, left_pos); // to check and see if this function was able to grab the values

}


This would get the top and left coordinates (which is like X and Y) of the div. Now do you need to do something with those two values? Because we might need to return them in which case we’ll have to do some fancier javascript.