Hi Scott,
I don't know what your evalAppendedPath contained so I wrote my own to
test your code. Everything worked as expected for me so maybe you have
a typo in your movie clip names or path. I've uploaded an FLA if you
want to take a look at my version:
http://www.synergymedia.net/downloads/evalTest.zip
My code:
function evalAppendedPath (obj:Object, str:String):Object {
// Over simplified because I'm unsure what code
// you actually have in here. This function could
// use error handling.
return eval( obj + . + str );
}
var result:Object = evalAppendedPath( my_mc, some.nested.clip );
trace( result ); // _level0.my_mc.some.nested.clip
trace( typeof( result )); // movieclip
var mc:MovieClip = MovieClip( result );
trace( mc ); // _level0.my_mc.some.nested.clip
Let me know if you find your problem,
JOR
___
=== James O'Reilly
===
=== SynergyMedia, Inc.
=== www.synergymedia.net
Scott Whittaker wrote:
Hi there,
I have discovered what appears to be a bug in Flash (player 7): I have
a class method which takes an object and a path string in dot-notation
format, and evaluates the result of the combined path. e.g.
evalAppendedPath( my_mc, some.nested.clip );
would return the object result of: my_mc.some.nested.clip;
This is a general purpose method which can take any object as an
input, and the evaluated result could also be of any type, so the
method return type is always going to be Object.
This method works just fine, and is not the source of the problem.
The problem comes when I know what the expected return type is and I
need to cast it so that I can use it with strong typing. In every
case, casting the returned result works just fine, with the exception
of movieclips placed on the stage at authortime. For example:
var result:Object = evalAppendedPath( my_mc, some.nested.clip );
trace( result ); // _level0.my_mc.some.nested.clip
trace( typeof( result )); // movieclip
var mc:MovieClip = MovieClip( result );
trace( mc ); // null
But if I load an external swf asset, evaluate its path, and cast it,
the cast works and doesn't yield null.
Short of changing all my internal class references to type Object
instead of MovieClip (which could cause all sorts of problems trying
to mesh with other code) or loading all my assets externally (which
will cause load time issues) is there anything else I can do?
Thanks!
--
Scott Whittaker
Trilobyte Interactive
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders