[Flashcoders] Passing Var value to loaded swf

2010-06-07 Thread Lehr, Theodore
I found this code:

in the parent swf
gameLoader.contentLoaderInfo.addEventListener(Event.INIT, onInit);

function onInit(e:Event) {
MovieClip(gameLoader.content).userId = 100;
}

In the loaded swf

public class Game extends MovieClip {
public var userId:int = 0;
function Game() {
addEventListener(Event.ADDED_TO_STAGE,Init);
}
function Init(e:Event) {
testText.text = String(userId);
}



I am not seeing how I can add the swf to the stage ( 
MovieClip(gameLoader.content).userId = 100;)



How can I add it to the stage?



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Passing Var value to loaded swf

2010-06-07 Thread Steven Sacks
Loader is a DisplayObject. You can add Loader to the stage before telling it to 
load.  You don't have to wait to addChild() the content of the Loader after it 
loads.


You cannot dispatch bubbled events from your loaded swf through the Loader that 
loaded it. Keep that in mind.


Doing parent.parent is generally a bad idea, since it requires that the swf 
being loaded have intimate detail of its parent. You wouldn't want to walk in on 
your parents having sex, but your parents might walk in on you masturbating 
(since you live in their house).


Maybe I should rethink that metaphor...
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Passing Var value to loaded swf

2010-06-07 Thread Juan Pablo Califano

Maybe I should rethink that metaphor...


Yes, please. Although in this case, wouldn't grandpa and granny be the ones
having sex? Not sure if that makes the metaphor more or less disturbing,
though.

Cheers
Juan Pablo Califano

2010/6/7 Steven Sacks flash...@stevensacks.net

 Loader is a DisplayObject. You can add Loader to the stage before telling
 it to load.  You don't have to wait to addChild() the content of the Loader
 after it loads.

 You cannot dispatch bubbled events from your loaded swf through the Loader
 that loaded it. Keep that in mind.

 Doing parent.parent is generally a bad idea, since it requires that the swf
 being loaded have intimate detail of its parent. You wouldn't want to walk
 in on your parents having sex, but your parents might walk in on you
 masturbating (since you live in their house).

 Maybe I should rethink that metaphor...

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders