Thanks for the replies. I figured out the problem, it was from overriding
the MovieClip prototype from within a loaded clip, and then reloading the
clip a second time.

Here's a blog post that discusses the issue of using hitTest in loaded swfs
( i.e., x,y coordinates must be in global not local coordinates), and a
workaround for overriding the prototype...

http://www.bit-101.com/blog/?p=499

The workaround...

MovieClip.prototype.oldHitTest = MovieClip.prototype.hitTest;
MovieClip.prototype.hitTest = function(x, y, sf){
        var obj = {x:x, y:y};
        this._parent.localToGlobal(obj);
        return this.oldHitTest(obj.x
, obj.y, sf);
}

That works great, unless the swf gets loaded a second time. Here's what I
changed and everything is rosey again...

if(!MovieClip.prototype.oldHitTest) {
   MovieClip.prototype.oldHitTest = MovieClip.prototype.hitTest;
   MovieClip.prototype.hitTest = function(x, y, sf) {
       var obj = {x:x, y:y};
       this._parent.localToGlobal(obj);
       return this.oldHitTest(obj.x, obj.y, sf);
   };
}

Thanks to everyone who responded.


And to all those who are complaining about receiving so many messages from
the mail list: you're not really helping matters.




On 2/24/07, Hans Wichman < [EMAIL PROTECTED]> wrote:

Hi,
can you check if these singletons are in the correct state?
For example, although not entirely how they were meant to be, but if you
add
a MySingleton.reset() method, which causes the first getInstance() to
return
a NEW instance (so reset clears the static _instance), is the problem
solved?

So eg each of your singletons gets a static method reset and it resets the
single instance it wraps.
Before you load the new game you call these reset methods.

Might be worth a shot.

greetz
JC




On 2/24/07, Jay Bibby <[EMAIL PROTECTED]> wrote:
>
> Thanks Hans,
>
> _root._name is exactly what I expect in both circumstances.
>
> However, yes, the shell uses a GameManager, and a LoadManager, both of
> which
> are singletons.
>
> Funny thing is, this is my 2nd time around with this shell. I had
> previously
> created one for 21 games that worked flawlessly. Now I get a game that
> breaks the system and I don't know what to try next.
>
>
>
> On 2/23/07, Hans Wichman < [EMAIL PROTECTED]> wrote:
> >
> > ps what also might be the case is that you are using static classes,
> > singletons etc and that the whole mumbojumbo is not correctly
> initialized
> > (or already 'used') the second time around.
> >
> > On 2/23/07, Hans Wichman <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi,
> > > i had a similar problem last week. In my case, even though _lockroot
> was
> > > on, the second time I loaded a clip, the reference to _root suddenly
> > pointed
> > > to the main _root again and not the subroot as it had to. Trace
> (_root)
> > from
> > > the subclip to see whats happening.
> > >
> > > In my case I lost the reference somewhere around instantiating
> > webservice,
> > > so as long as i stored it in another reference before creating the
> > > webservice, I was fine.
> > >
> > > hth
> > > JC
> > >
> > >
> > >  On 2/23/07, Harris, Mike <[EMAIL PROTECTED]> wrote:
> > > >
> > > > What happens if you put ? and a random number after the name of
the
> > swf
> > > > when you load it? Like, mymovie.swf ?343423
> > > >
> > > > Mike
> > > >
> > > >
> > > >
> > > >
> > > > This Message (including attachments) is intended only for the
> > identified
> > > > Recipient(s) and may contain information that is confidential or
> > subject to
> > > > copyright, trade secret or other restrictions.  It may also
include
> > attorney
> > > > client, attorney work product, or other privileged
> > communications.  The
> > > > information and opinions presented in this Message do not
> necessarily
> > > > represent those of the Jones Companies.  If you are not the
intended
> > > > Recipient, you are hereby notified that any use, copying or
> > distribution of
> > > > this Message (including attachments) is unauthorized and
> > prohibited.  If you
> > > > have received this Message in error, please notify the Sender (
> > > > [EMAIL PROTECTED]) immediately by replying to and then
> > > > completely deleting the Message (including all attachments) from
> your
> > > > computer.  Additionally, the integrity and security of this
Message
> > and its
> > > > attachments cannot be assured on the Internet; Recipients assume
all
> > risk of
> > > > loss by accepting this message, including from their failure to
use
> > > > effective anti-virus software.
> > > > -----Original Message-----
> > > >
> > > > From: [EMAIL PROTECTED]
> > > > [mailto: [EMAIL PROTECTED] ] On Behalf Of
Jay
> > > > Bibby
> > > > Sent: Friday, February 23, 2007 2:54 PM
> > > > To: [email protected]
> > > > Subject: [Flashcoders] Problem when loading swf a second time
> > > >
> > > >
> > > > Hi,
> > > >
> > > > I'm at my wits end on this and I don't know where to turn for
help.
> > > > Numerous Google searches have turned up little in the way of
anyone
> > > > encountering a similar issue.
> > > >
> > > > I have an interface shell swf that handles the selection, loading
> and
> > > > display of various external game swfs within it. All are loaded
via
> a
> > > > MovieClipLoader object and all of them have _lockroot set to true.
> > > >
> > > > One particular game behaves fine when loaded the first time into
the
> > > > shell. But loaded a 2nd time, I get the following 256 levels of
> > > > recursion error message...
> > > >
> > > > 256 levels of recursion were exceeded in one action list.
> > > > This is probably an infinite loop.
> > > > Further execution of actions has been disabled in this movie.
> > > >
> > > > The error occurs while the external swf is attaching a movieclip
> from
> > > > its library...
> > > >
> > > > t = _root.attachMovie("title", "title", 1000);
> > > >
> > > > I thought perhaps that it just might be a timing issue, since
> loading
> > > > the swf a second time is virtually instantaneous, even though I
wait
> > > > until the MovieClipLoader's listener object receives the
onLoadInit
> > call
> > > > before allowing the loaded swf to continue.
> > > >
> > > > So I created several delays in the swf, via timeouts and also by
> > > > extending the main timeline. Doing so actually seemed to fix the
> > > > problem. The title screen was created and the start button on it
was
> > > > functional. Subsequently starting the game created the first
puzzle
> > and
> > > > all seemed good until one of the objects in the first puzzle was
> > clicked
> > > >
> > > > on... then the same recursion error.
> > > >
> > > > I'm at my wits end.
> > > >
> > > > To recap: The game functions perfectly the first time it is
loaded.
> > > > However, after unloading the swf and reloading it again, the same
> swf
> > > > seems to be unstable.
> > > >
> > > > Has anyone seen similar behavior before when using externally
loaded
> > > > swfs? Or do you have any ideas as to what to look for in the code?
> > > >
> > > > Thanks very much.
> > > >
> > > > Jay
> > > > jayisgames.com


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to