Skip to main content
Known Participant
April 30, 2013
Answered

Writing to a Specific Text Field in a Specific "Frame"?

  • April 30, 2013
  • 1 reply
  • 1456 views

Hello All,

First off I'm very new at this so bare with me if I'm not using the correct terminaology...

Ok so I'm modifying an existing Flash Program that someone here created a while back with Actionscript 1.0 and rewriting to

Actionscript 3.0. The Flash program reads in some XML Data using XMLSocket and I collect the data and save some of it into string variables.

Now when a certain piece of string data comes in from the XML Data, which contains the name of a specific "Frame" to display, I use

a switch statement to decide which of the 5 frames to display.

     The "Movie" is called "WBDMovie"....

So lets say I receive the string that tells me to display "Frame 1". So I issue this command below to go to that Frame:

WBDMovie.gotoAndStop(1);

This command takes me to "Frame 1" and stops. Now in Frame 1 there are 5 "Text Fields" in this area all set to "Dynamic Text". Now, I'm

trying to write a string variable to one of these Txt Fields in this Frame but I keep getting an error for undefined variable. See the Error below:

          *The "Text Field" is called "F1_agentsReady".

            *The "String Variable" is called "agentsReady".

          Line w/ Error:     F1_agentsReady.appendText("Agents Ready = " + agentsReady);

ReferenceError: Error #1065: Variable F1_agentsReady is not defined.

    at CSRBoard2013_fla::MainTimeline/dataHandler()[CSRBoard2013_fla.MainTimeline::frame1:104]

    at flash.events::EventDispatcher/dispatchEventFunction()

    at flash.events::EventDispatcher/dispatchEvent()

    at flash.net::XMLSocket/scanAndSendEvent()

So to write to this particular Text Field do I need to reference to the specific Frame that the Text Field is in?

I'm kinda confused how I was able to create another Text Field called "msgArea" which I placed in the Movie and can write to it (and its visible)

no matter what frame I'm currently displaying..?

Any suggestions would be much appreciated!

Thanks in Advance,

Matt

This topic has been closed for replies.
Correct answer kglad

you need to wait until that frame in that movieclip is rendered before you can reference objects created in that frame:

stage.invalidate();

WBDMovie.addEventListener(Event.RENDER,renderF);

WBDMovie.gotoAndStop(1);

function renderF(e:Event):void{

// you can now reference objects created in frame 1 of WBDMovie

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 30, 2013

you need to wait until that frame in that movieclip is rendered before you can reference objects created in that frame:

stage.invalidate();

WBDMovie.addEventListener(Event.RENDER,renderF);

WBDMovie.gotoAndStop(1);

function renderF(e:Event):void{

// you can now reference objects created in frame 1 of WBDMovie

}

mrm5102Author
Known Participant
April 30, 2013

Hey kglad, thanks for the reply!

Ok cool... I'll give that a try and post back with my results.

Thanks for the info!

Thanks Again,

Matt

kglad
Community Expert
Community Expert
April 30, 2013

you're welcome.