Gary Rosenzweig's

Developer Dispatch

News and Notes For Developers Using Flash, ActionScript, Director, PHP and JavaScript.


MY BLOGS
Developer Dispatch Blog
Flash Game U
iPhone Dispatch Blog
INFO & FEEDBACK
About Developer Dispatch
About Gary Rosenzweig
Gary Rosenzweig's Books
Feedback
Contact Gary Rosenzweig
SHARING
Add to Technorati Favorites
Add to Del.icio.us
Stumble Upon
LINKS TO MY SITES
CleverMedia
Fun Games at GameScene.com
MacMost
Director Online
LINKS TO MY FRIENDS
Tech Support from Ask Dave Taylor
Ask Leo
Amy Gahran
Custom Stickers
Dean's Director Tutorials
Flash Website Templates
Time 4 Learning
RSS FEEDS
Raw RSS
Add RSS to your My Yahoo


03/02/04

Split Properties Bug and Workaround

Found a really odd and nasty MX04 bug today. I had a script that attempted to set the property of a behavior of a sprite externally, like sprite(1).pMyProp = 7. What was happening was that it appeared to change externally (put sprite(1).pMyProp), but the code in the behavior saw the old pMyProp value, not the new one. So in the behavior, I had two different values for pMyProp and sprite(me.spriteNum).pMyProp. This was the only behavior of the sprite.
What I discovered, thanks to JHT at Macromedia, was that Flash sprites in MX04 have the ability to have variables that are directly addressable. So sprite(1).pMyProp = 7 was creating a Flash variable in the Flash movie that had a value of 7. So I had a Flash variable and a sprite behavior property of the same name.
There are plenty of fixes for this. One would be to have setMyProp() and getMyProp() fuctions in the behavior and only set them this way. That’s a very object-oriented approach. You could also refer to the property externally via the scriptInstanceList: sprite(1).scriptInstanceList[1].pMyProp = 7.
This bug could very well break old Shockwave movies, so be on the lookout.


Leave a Reply