Image

Imagequill18 wrote in Imageflashdev

Components in a Window

I'm fairly new to working with components, and I've just hit my first major stumbling block. My goal is to popup a Window component with more form bits inside. (A couple TextInputs and Cancel/Okay buttons.)

I can have my window popup and have the content be the correct movie clip. The controls inside this movie clip look right and seem to behave okay, except that I seem unable to interact with them from Action script. Here's what I mean:


////  Creating Rooms
function onCreateRoom(eventObj:Object) {
	myWindow = PopUpManager.createPopUp(_root, 
	mx.containers.Window, true, {closeButton:true,title:"Create Room", contentPath:"createRoomWindow"});
	myWindow.addEventListener("load", createRoom_onLoad)
	myWindow.content.onLoad = createRoom_onContentLoad; // Doesn't run...
}
createRoom_pb.addEventListener("click", onCreateRoom)

function createRoom_onLoad(eventObj:Object) {
	trace("createRoom_onLoad")
	
	eventObj.target.setSize(eventObj.target.content._width+25, eventObj.target.content._height + 50);
	
	eventObj.target.content.onLoad = createRoom_onContentLoad; // Doesn't run...
	eventObj.target.content.onEnterFrame = createRoom_onContentEnterFrame;
	
	eventObj.target.content.roomName_ti._x = 0	// Why does this work....
	eventObj.target.content.roomName_ti.text = "Doesn't work." // but not this?
}

function createRoom_onContentLoad(eventObj:Object) {
	/* Doesn't Run At All! */
	trace("createRoom_onContentLoad")
	this.roomName_ti.text = "Might work, if onLoad ever ran."
}

function createRoom_onContentEnterFrame(eventObj:Object) {
	trace("createRoom_onContentEnterFrame")
	this.roomName_ti.text = "It worked!"	// But what a silly hack.
	this.onEnterFrame = null
}



Putting the code inside the content movie clip does seem to work, but results in less elegant code for my particular application.