20 November 2006

Casting Fails - Flash 8 - Follow Up

Written by Richard Leggett ( Contact the author of this post )
Published on November 20th, 2006 @ 09:04:38 am, using 245 words, 506 views
Categories: Flash

A while ago I posted about casting failing if you cast the result of attachMovie() but only in certain cases.

I had the same thing happen today, so I opened it up in FLASM, and I think I can see what is happening:

push 'sp'
getVariable
trace
push 'sb', 0.0, 'getNextHighestDepth'
callFunction
push 'sb', 'com'
getVariable
push 'domain'
getMember
push 'controls'
getMember
push 'ScrollBar'
getMember
push 'LINKAGE'
getMember
push 3, 'attachMovie'
callFunction
push 1, 'com'
getVariable
push 'domain'
getMember
push 'controls'
getMember
push 'ScrollBar'
callMethod
varEquals

As you can see here, it seems instead of performing a cast operation (and "cast" is a keyword you do see in the FLASM output), it actually tries to perform a conversion (as you see with Array or Boolean), treating com.domain.controls.ScrollPane as a function, and applying it to the result from the attachMovie() operation. This results in the undefined/null value we are experiencing because in itself, this function has no return value unless used with the new keyword as a constructor.


As I stated in the previous post on this subject, splitting the code onto two lines seems to fix the problem (i.e. attachMovie() then cast on the next line). Is this a compiler bug? Has anyone more experience with the inner workings of the Flash Player? Why do Macromedia's v2 components not suffer this, I have a feeling it is to do with the inline dynamic dereferencing, maybe #initclip needs to be brought in for AS2?

Comments, Pingbacks:

No Comments/Pingbacks for this post yet...

Comments are closed for this post.

About

Richard Leggett is an RIA and Web Developer, co-founder of Ubrae Ltd. He is co-author of Foundation Flash Applications for Mobile Devices (Friends of ED), an Adobe Community Expert and speaker at industry conferences and user groups.



January 2009
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Categories

Miscellany

XML Feeds

Information

Contact the admin  /   b2evo template by Two18 Media