0
votes

Suppose you are using flash builder(4.7) with flash professional (or bringing in flash professional assets in a swc or swf) and you have the whole screen in one symbol. So then you want to pull everything out into a variable. Something like this:

_pictureThing = _startScreen["pictureThing"] as Sprite. 

It will give you the red under bar because you haven't mentioned _pictureThing yet. So you hit ctrl+1, choose make an instance variable. Sure. But now when you go up to the top of the class, it is a String! WHAT? I said as Sprite. The only thing I would expect this to be is a Sprite. How could this possibly not be a feature of Flash Builder? It's as if they went to almost the perfect editor and then said, "Nah. Let's just not finish it. Let's just make it do this crazy camera jumping instead". Making every variable type String may seem like not a big deal, but when you have a lot of variables the time really adds up. Maybe my way just works, but isn't actually the syntax that Flash Builder wants me to write it?

1
_pictureThing = Sprite(_startScreen["pictureThing"]);Fygo

1 Answers

0
votes

Since every object has a toString() implementation, if the Flash Builder editor cannot detect the supposed type of a variable, it assumes a String as default failsafe value for its type. The question of why did FB's devs not made it parse as statement as a supposed var type setter is open, my weird suggestion will be inheritance, as Sprite is a descendant of say DisplayObjectContainer type, so maybe that var should be of that type, or maybe one level less (EventDispatcher), or maybe Object right away. Probably the fix Fygo posted in comments can make it for you:

_pictureThing = Sprite(_startScreen["pictureThing"]); – Fygo 22 mins ago

but the inheritance ambiguity still remains. I say just let it be.