Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : Window Class - accessing the "content"


pjazzlg NO[at]SPAM yahoo.com
4/11/2004 2:05:17 PM
I am using the Popup manager to load a Window Component which loads a
clip that displays a simple text field. The "content" gets loaded, but
I cannot access any variables within the clip inside the window.

var myWindow = mx.managers.PopUpManager.createPopUp(_root,
mx.containers.Window, true, { title:"EDIT",
contentPath:"simple",closeButton:true});

adireddy
4/12/2004 9:30:23 AM
The problem with your code is you are trying to set the values od the window
contents before it is entirely loaded...

You have to use the Window.complete event to set the value of the text field
after it is loaded..

var lo:Object = new Object();
lo.handleEvent = function(evtObj){
if(evtObj.type == "complete"){
myWindow.content.theTextField.text = "does not work";
}
}
myWindow.addEventListener("complete", lo);
pjazzlg NO[at]SPAM yahoo.com
4/12/2004 1:48:46 PM
[quoted text, click to view]

Thanks! It works now. Another question.... The movie I am loading has
two buttons ("save" and "cancel") How do I access them? I have tried
to add a listener fucntion as follows without much luck:

var saver:Object = new Object();
saver.click = function(){
trace("SAVE");
}
adireddy
4/13/2004 5:13:01 AM
Try the following code... it should work...

var lo:Object = new Object();
lo.handleEvent = function(evtObj){
if(evtObj.type == "complete"){
myWindow.content.theTextField.text = "does not work";
myWindow.content.__save.onRelease = function(){
trace("Save Clicked");
};
}
}
myWindow.addEventListener("complete", lo);
CFFLDave
10/27/2004 5:43:44 PM
The "complete " event does not facilitate the setting of the .content property,
as apparently the window is not fully loaded there. There are many frustrated
forum messages posted to that effect. I do not know how the message poster
here says this works. The only way I got this to work was to set an interval,
and then set the .content property after a couple of seconds, or as appropriate
timing for the content to load. The "complete" event is a great spot to set
the size with setsize().
listillo
10/27/2004 7:04:07 PM
You're right. Yesterday, I posed a similar question regarding triggering
functions embedded in the content movieclip. I tried the windows.complete
event, but it doesn't start the function. Setting an interval does help.

This is what I did:

function TriggerWindowStartFunction(){
myWindow.content.Test()
clearInterval( intervalID )
}
var intervalID
intervalID = setInterval(TriggerWindowStartFunction, 2000 );

regards
Richard

_semaphore_
11/30/2005 11:40:31 AM
The main problem lies in the fact that you are loading, essentially, a
movieclip within a component. What you will find is that the 'complete' event
is sent by the Window *before* the onLoad event is called on the movieclip that
you have loading INTO the content of the Window.

Your best bet is to create a class for your content movieclip that defines an
onLoad method that can coordinate with the 'complete' event sent to the window.
AddThis Social Bookmark Button