1

I want to override flash.display.Loader and to dispatch my own Event with a my own target.content

How can i override Event.target? "Property is read only"

Or use some other way to unit test the loading sequence

tnx Hed

Hed
  • 45
  • 5

2 Answers2

2

The target is always set to the object that dispatches the event. The proper way to unit test loading sequence is to mock the loaders - this unit test should test the logic used for loading sequentially, not the file system or network connection.

Wrap your loader into a custom class implementing a custom loader interface that extends IEventDispatcher. Use that interface to create a mock loader, and dispatch the event from the mock object.

weltraumpirat
  • 22,544
  • 5
  • 40
  • 54
  • I did mock the Loader + did dispatch the event from the Loader - but didn't see it set as a target I'll check again (If it is being set that's good enough for my tests) – Hed Jan 30 '12 at 18:53
0

You can't override target property. Though you can trick flash with special custom extended event but that will get ugly very soon.

What you need to do is to create a mock loader which contains a Loader instance, catches its event and dispatches a new one.

Valentin Simonov
  • 1,768
  • 10
  • 14