Skip to main content
Known Participant
March 17, 2013
Answered

Dynamic Text field not updating in actionscript when in 2nd Frame

  • March 17, 2013
  • 1 reply
  • 6008 views

I am having a movie clip with two frames. In 2nd frame there is a movie clip which has a text field.

My goal is to on some event I will move to the frame that has the movie clip with text field.

I am trying to update the text field with a code something like:-

public function updateTxtFld(e:Event)

{

          //My goal is to on some event show the movie clip with the text field

          questBG.gotoAndStop("glow");

          arrowText.text = "some text"; //arrowTextt has been assigned with the correct text field

}

After some time I again move back to the frame which has no movie clip thus hiding the movie clip

public function hide()

{

          questBG.gotoAndStop("idle");

}

The text field does not get updated from the actionscript even though trace(arrowText.text) shows the updated value.

Now if I remove frames from the movie clip & modify the updateTxtFld() like

public function updateTxtFld(e:Event)

{

          (questBG.getChildByName('arrowBG') as Sprite).visible = true;

          arrowText.text = "some text"; //arrowTextt has been assigned with the correct text field

}

Then it works fine with the text getting updated in the text field. It seems there seems to be some problem in updating dynamic text field in frames.

I have also verified that text embedding is fine in both the cases

I have created the flas using CS Professional 5.5 & I am trying to change the text field using actionscript running in Flex Builder 4.7.   Let me know if I need to send the fla (both working & non-working version).

This topic has been closed for replies.
Correct answer kglad

you're assigning text to arrowText before the timeline moves to "glow".

use the render event to assign text:

public function updateTxtFld(e:Event)

{

          //My goal is to on some event show the movie clip with the text field

          questBG.gotoAndStop("glow");

stage.invalidate();

this.addEventListener(Event.RENDER,assignTextF);

}

function assignTextF(e:Event):void{
          arrowText.text = "some text"; //arrowTextt has been assigned with the correct text field
}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 17, 2013

you're assigning text to arrowText before the timeline moves to "glow".

use the render event to assign text:

public function updateTxtFld(e:Event)

{

          //My goal is to on some event show the movie clip with the text field

          questBG.gotoAndStop("glow");

stage.invalidate();

this.addEventListener(Event.RENDER,assignTextF);

}

function assignTextF(e:Event):void{
          arrowText.text = "some text"; //arrowTextt has been assigned with the correct text field
}

dm1985Author
Known Participant
March 17, 2013

Tried as you suggested. Still not working.

Just to clarify once again in the first case(not working case) questBG is a movie clip which has a frame named label 'glow' which contains a movie clip arrowBG which has the text field. in the second case(working case) it is same instead i do not have the frame 'glow'. To control the visibility now instead of doing gotoandstop() I have to use 'visible' property of 'arrowBG' to control the visibility of the text field

kglad
Community Expert
Community Expert
March 17, 2013

use:

public function updateTxtFld(e:Event)

{

          //My goal is to on some event show the movie clip with the text field

stage.invalidate();

this.addEventListener(Event.RENDER,assignTextF);

      questBG.gotoAndStop("glow");

}

function assignTextF(e:Event):void{

          arrowText.text = "some text"; //arrowTextt has been assigned with the correct text field

}