So:
I had this problem (Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.
) and I followed the recommended solution:
// container ( IVisualElement ) for DisplayObjects
var container:UIComponent = new UIComponent();
addElement( container );
// displayObject goes to container
var displayO:Sprite = new Sprite();
container.addChild( displayO );
--> works great (sizing and layout is another problem aside), because my "child" swf is loading.
Using this method, how can I pass data from the parent to the child (and have the child read it)? It never has to go from Child to Parent, except to close the Child swf (if you've got an idea for that, it doesn't seem to be fond of the unload method).
I have to ask, because almost every method I have found to pass data between swfs is using the Loader class to call the other into view and I haven't had success with that at all. I'm using FlashBuilder 4.6 to code and package both swfs.
Thanks for the input! I'll probably keep updating this question with multiple edits as I get more info or think of something new to add. Thanks for the help!
EDIT 1 - March 27, 17:16 EST
Created a class:
Child.as:
package classes
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.net.URLRequest;
public class Child extends Sprite
{
public var location:String;
public function Child()
{
super();
var loader:Loader = new Loader;
var urlReq:URLRequest = new URLRequest("http://myswf.com/myswf.swf");
loader.load(urlReq);
addChild(loader);
}}}
and I am opening the child swf with the following method:
//in main code
public var containter:UIContainer = new UIComponent;
public var Locale:String;
private function CallSwf():void
{
container.x=0;
container.y=0;
container.width = totalSize.width;
container.height = totalSize.height;
addElement(container);
var displayO:Child = new Child;
container.addChild(displayO);
displayO.data = Locale;
if (container.visible = true) {
totalSize.visible = false;
}
}
What I need to be able to do, is get the string Locale to be read by the Child swf.