Re: [flexcoders] Loaded SWF loses nested child instance name
Your a gentleman Oleg thanks for explaining. Clark On 15 July 2010 11:41, Oleg Sivokon wrote: > > > Nope, not really, what happens is like this: the document class is a > sprite, which has some code in it, which is called first in the application > and this class is automatically added to stage, if it is not loaded. > However, if the SWF is loaded, then the class isn't automatically added to > stage, however, the constructor is executed before that. > Now, Flash will create variables and assign the library instances to those > variables if you put those instances on the stage, however, if you turn off > the "automatically declare stage instances", Flash will not create the > corresponding variables for them (and so you will get an option to define > them yourself in your class. You don't need to initialize those variables to > anything, Flash will initialize them to the timeline placed instances of the > same name. > >
Re: [flexcoders] Loaded SWF loses nested child instance name
Nope, not really, what happens is like this: the document class is a sprite, which has some code in it, which is called first in the application and this class is automatically added to stage, if it is not loaded. However, if the SWF is loaded, then the class isn't automatically added to stage, however, the constructor is executed before that. Now, Flash will create variables and assign the library instances to those variables if you put those instances on the stage, however, if you turn off the "automatically declare stage instances", Flash will not create the corresponding variables for them (and so you will get an option to define them yourself in your class. You don't need to initialize those variables to anything, Flash will initialize them to the timeline placed instances of the same name.
Re: [flexcoders] Loaded SWF loses nested child instance name
Thanks for your quick reply Oleg as always. I have been looking for ways to make this happen over the last few hours. My latest brainwave (pathetic guess attempt) was a Document class called Main which looked something like this: public var itemRef:MovieClip = MovieClip(this.item); public var colorRef:MovieClip = MovieClip(itemRef.color); public var overlayRef:MovieClip = MovieClip(itemRef.overlay); I dont really understand the document class as Flash isnt really my working tool. However, i assumed this would work. If Main.as is a flas document class, then Main essentially becomes "root" ? In any case loadedSWF.itemRef = undefined. Usually we generate SWCs with Actionscript identifiers but since thats a compile time process?, and this is a runtime process, im a little confused. All of these swfs simply have: root -item --color --overlay I might just be best to stick to depths as long as im clear to explain that color must always be on the bottom depth. I still dont understand why names break however. Cheers, Clark. On 14 July 2010 12:50, Oleg Sivokon wrote: > > > Well, that wasn't a good idea from the start, as instance name isn't a > reliable identification (you can assign two identical names to different > instances and that will compile, while the second instance will not > be available). What I usually do in such case is: I prepare the class with > the fields it should have, give it to designer and explain hot to link their > library items to that class, and then when I compile, I use my own version > of that class with the functionality added, this way we (me and designer) > can work on the same class and I don't have problems using it in my project. > Ah, important to note, this approach requires that the designer turn off > the "automatically declare stage instances" in publish settings. > >
Re: [flexcoders] Loaded SWF loses nested child instance name
Well, that wasn't a good idea from the start, as instance name isn't a reliable identification (you can assign two identical names to different instances and that will compile, while the second instance will not be available). What I usually do in such case is: I prepare the class with the fields it should have, give it to designer and explain hot to link their library items to that class, and then when I compile, I use my own version of that class with the functionality added, this way we (me and designer) can work on the same class and I don't have problems using it in my project. Ah, important to note, this approach requires that the designer turn off the "automatically declare stage instances" in publish settings.
[flexcoders] Loaded SWF loses nested child instance name
Bit of a horrible title. In Flash i have this as a SWF: root -item --overlay --color Where root holds MovieClip with instance name "item" and item holds moviclips with instance names "color" and "overlay". Loading this SWF is then converted into a MovieClip var loadedSWF:MovieClip = //the loaded swf For some reason, i cannot access overlay and color by instance name but i can access item. var item:MovieClip = MovieClip(loadedSWF.item) // result [MovieClip] But thats as far as i can reference any other item. var overlay:MovieClip = MovieClip(loadedSWF.item.overlay) //result "undefined" or null var color:MovieClip = MovieClip(loadedSWF.item.color); //result "undefined" or null However item.numChildren() //returns 2 which is correct (overlay and color) item.getChildByIndex(1); //returns color Because of the nature of this project, i really need to have access to instance names as opposed to depths. Depths is going to get complicated and cause mistakes between me and the designer. Does anyone know why i cannot access the children of item? Yet i can access the child of loadedSWF. Thank you.