Ok, it must be because I’m down to the wire on this project, but after the 2nd time of having attachMovie not return a value in one of my functions, I just couldn’t take it anymore, and had to solve it.
And I did, MOFO!
…I just don’t understand the results.
– attachMovie was not returning a value
– tracing the function call printed the movie clip path in the Output Window
– tracing it with a string in the trace statement printed a NaN in the Output Window; trace(“ref_mc: ” + attachMovie(“MyComponent”, “my_mc”, 0));
– utilizing typeof and instanceof showed undefined in the Output window
– any return value showed undefined
…uh, no, that’s not how attachMovie works. It doesn’t attach a component and then have that component magically work, but not return a value. If I accessed the movie clip, however, it worked. Now, a RAD type of developer would of moved on, simply replacing ref_mc with a pointer to the movie clip’s real name.
Personally, I don’t like shiot breaking and not knowing why. So, after investigation, it turns out that placing a “stop();” in an AS2 constructor/init function will cause the return value to fail. this.stop, using a stop in AS1, or this.stop in AS1 are all fine.
Uh, yeah…ok… sure, that makes tons of sense. :: dar dar dar :: * hits right wrist on chest heavily *
This is important in designing AS2 components because you now place your component’s assets on frame 2 on a non-guided frame. You now have to add a stop to prevent your component from ever reaching that frame since it’s merely there to ensure your component includes all it needs in either travelling to another FLA’s library, or transforming into an SWC. You can place a “stop” command on the timeline on frame 1 if you wish, but most purists don’t believe in any timeline code if possible. Putting it on the constructor/init function is best.