Mikko Tapionlinna
Mikko Tapionlinna

Reputation: 1458

Is there an way to load external swf into a sandbox in flash?

I'm loading flash ad-banners inside my all flash site with Loader. I have no control over the code inside the banners as they come from advertisers.

I'd like to load them so that there is no way they can mess up the mouse events on the site outside their limited area. Sloppy code on advertisers banner should not kill my site's functionality in any situation.

Bonus question, how can I solve the problems caused by the banners being a different frame rate than my main site? (Or is there an easy way to convert currently drawn animations into my frame rate while keeping the animation speed same as before?)

There must be people who have dealt with these issues before.

What's the best way to do this?

Thanks!

Upvotes: 1

Views: 1859

Answers (3)

Caio Cunha
Caio Cunha

Reputation: 23394

I've just found a Adobe PDF about this: Loading Applications.

Upvotes: 0

marketer
marketer

Reputation: 43677

When you load the external swf, make sure it's loaded into a separate Security domain and into a child application domain. That way it won't be able to access stage Mouse and Keyboard events (and certain others), and there won't be any class definition conflicts.

Check out this document: Developing and loading subapplications

Upvotes: 1

evilpenguin
evilpenguin

Reputation: 5478

Theoretically, the loaded swf does not have access to the parent's objects and variables without permission. You can read more about Security.allowDomain here. Unless you do an allowDomain() on the banner's domain, it will not be able to call objects in your website.

You could also do one or more of the following:

  • create a mask for the Loader object of the banner, in order to prevent the banner from expanding more than it's assigned space

  • use the mouseChildren property in order to disable all mouse events of the Loader.content object and then add a single click event on the Loader, for navigation to the banner's target page

I've played with the frame rate myself, but to no avail. The child seems to follow the parent's frame rate in all cases. The only thing that worked was stopping auto frame rate advance for the child and do it via a TimerEvent, but that generates extra processor load.

Upvotes: 1

Related Questions