Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Mouse events not fired for a while after loading?

Non working buttons

12:51 am on Jul 21, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts: 525
votes: 0

Hi there!

I have a movie made with (heavily) using AS3, connected to Red5, and also reads data from XML files. When the movie is loaded, it reads an XML file from the webserver, then connects to the Red5, opens and plays a stream, and in the meantime initiates a SharedObject as well. Basically everything works pretty fine (was a long way), but one annoying thing remains:

After the movie is loaded in the player, for about a few seconds (~5 seconds) I'm not able to click anything in the movie, even the mouse pointer is left unchanged when I hover a button, just as if the player would not care about my mouse. After those few seconds has passed, everything runs just fine.

During this time nothing happens anymore, the script runs fine, it does all the job it has to do, even the stream starts to play in 1-2 seconds after loading, but I have to wait ~3 more seconds to have the player react to the mouse events...

Any idea what could block the flash to react to mouse events? As far as I know there's no memory/CPU intensive tasks running in the background, no dead-loops, no tweens, nothing what would make me suspicious. I'm lost...

Thanks for any idea/suggestion!

My apologies if this is a frequently asked question, but looking it on google reveals millions of web pages (for example "flash buttons not working", but I couldn't come up with better phrasing for this, so I gave up on this...)

4:07 pm on July 21, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

Are you using preloaders to insure all the elements (including the XML) are loaded before anything displays?
5:19 pm on July 21, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
votes: 0

No, it is loaded (indirectly) from the class constructor. But as I mentioned everything is ready and working at the time when the mouse is still not functioning.

But actually the answer is yes, because the XML loaded contains the translations of the texts, and I do not show (more precisely it is not visible) anything before this XML is fetched and loaded.

Stripping out few hundred lines, the code looks like this:

public class Client extends Sprite { 
// Constructor

public function Client() {
// Hide interface
// Start configuring the client
// Load translations from XML

private function loadTexts():void {
var request:URLRequest = new URLRequest("http://www.example.com/flash_text.php");
this.mui.addEventListener(Event.COMPLETE, Delegate.create(this, function(){
// Initialize the client
// Method for configuring the User Interface

private function startClient():void {
// Initiate network connection
// There goes dozens of lines containing event listener assignments,
// other UI changes, and so on... This is the place where
// the mouse event listeners are assigned as well.
// ...
// Show interface

// Initiates network connection

private function connectNetwork():void {
this.connection = new NetConnection();
this.connection.client = this;
this.connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
// Network status handler

private function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Failed" :
// Do something
case "NetConnection.Connect.Success" :
// Continue the configuration...
case "NetStream.Play.Start" :
// Playback has started, execution goes idle, stream is being played,
// usually this happens in the fist 2-3 seconds after loading.
// After this point everything is loaded and ready to work - but it isn't...

// Configures shared object

private function setupSO():void {
this.remoteSO = SharedObject.getRemote('remoteSO', this.connection.uri, false);
this.remoteSO.addEventListener(SyncEvent.SYNC, soSync);
this.remoteSO.client = this;
// Sync handler for the remote shared object

private function soSync(e:SyncEvent):void {
if (!this.soSynched) {
// Connect to the Red5 stream
// Remember that the SO was synced, so next time called, this piece of code does not run.
this.soSynched = true;
} else {
// Handle changes in SO
// Connects to the Red5 stream

private function connectStream(force:Boolean=false):void {
this.stream = new NetStream(this.connection);
this.stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
this.stream.play('liveStream', -1);

For a simpler overiew of what happening here's the order of methods they are called:

Constructor => loadTexts() -> Anonymous method => startClient() => connectNetwork() -> netStatusHandler() => setupSO() -> soSync() => connectStream() -> netStatusHandler()

The mouse event listeners are assigner pretty early, I see no reason why flash does not respond to them? All other event listeners are working fine. If the swf would not be loaded properly (as there's no loader for the flash), it would not work at all, no? Me lost.

10:52 am on July 30, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
votes: 0

Bump. Bump. Anyone?