Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Mar 17, 2013 Mar 17, 2013

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).

TOPICS
ActionScript
5.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 17, 2013 Mar 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
}

Translate
Community Expert ,
Mar 17, 2013 Mar 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
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2013 Mar 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2013 Mar 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

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2013 Mar 17, 2013

Tried this also. Still not working.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2013 Mar 17, 2013

show the code you're using.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2013 Mar 17, 2013

I can't share the exact actionscript code. But i am using exactly same code as you mentioned in the function where I am doing the update

public function updateTxtFld(e:Event)

{

     stage.invalidate();

     this.addEventListener(Event.RENDER,assignTextF);

     questBG.gotoAndStop("glow");

}

private function assignTextF(e:Event):void

{

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

}

If you need I can send you the aseet (questBG movie clip) that was created in CS 5.5. If you still need the actionscript then I will create a seperate prototype & send it to you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2013 Mar 17, 2013

then arrowText is the wrong reference.

redefine it's value in assignTextF or, even better, just use the full path/name.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2013 Mar 17, 2013

I don't think  arrowText is the wrong reference because if I take out the frame & just add the movie clip, arrowBG(contaiing arrowText) in the first frame & instead of doing goToAndStop() if I do visible = true /  false (as mentioned in the first comment) then everything works fine. If the arrowText is the wrong reference then it would  fail in the second case as well. But it is working fine if I take out the goToAndStop(). So, I think there seems to be some problem in updating the Dynamic Text Field in the frames.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 18, 2013 Mar 18, 2013

In 2nd frame there is a movie clip which has a text field.

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

You are clerarly never reaching arrowText if you write:

arrowText.text = "";

it should say sth. like: questBG.arrowBG.arrowText.text = "" ... if you are calling from the root

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2013 Mar 18, 2013

look, as soon as your movieclip changes frame to "glow", your textfield reference is incorrect.  comprende?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 18, 2013 Mar 18, 2013

Thanks kglad for taking time to look into this.

Yes I actually did that way I did not put the full code I am doing that only.

Full Code is like this:-

First I am doing this:-

var arrowBG:Sprite = questBG.getChildByName('arrowBG') as Sprite;

& then this:-

var arrowText:TextField = arrowBG.getChildByName('arrowText') as TextField;

I am making sure that it is pointing to the correct text field.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2013 Mar 18, 2013

if the following doesn't work, what's the trace show?

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{

var arrowText:TextField = arrowBG.getChildByName('arrowText') as TextField;

trace(arrowText);

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

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 20, 2013 Mar 20, 2013

You meant to say

trace(arrowText.text) or trace(arrowText);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2013 Mar 20, 2013
LATEST

trace(arrowText);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines