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

Problems propagating info between ?DataObjects

Explorer ,
Nov 01, 2008 Nov 01, 2008

Copy link to clipboard

Copied

Hi, I'm a forum newbie, and just starting to learn AS3 (Flash CS3 on Mac OSX).

I'm hoping someone can steer me towards the source of one problem (amongst many) I am experiencing.

The code I'm building creates two MovieClips on the stage, in one it instantiates several text boxes and in the other some buttons.

What I can't do is access data from the text boxes (e.g. textField.text) for use in the functions called by the eventListeners attached the buttons. I had the system all working nicely before I placed the text boxes and the buttons on separate movie clips ... but this structure makes it much tidier to refresh the text I'm using.
The button functions are fine with variables created prior to the building of the text boxes.

Am I failing to address the text boxes correctly (because they're on another movie clip) or is there a stage / movie clip property I need to set so they can see each other ... or is this something else altogether??
Could it be that the buttons are created before the text boxes?

Any / all help would be appreciated.

Cheers
Dougal



TOPICS
ActionScript

Views

426

Translate

Translate

Report

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

LEGEND , Nov 02, 2008 Nov 02, 2008
Try:

var newEquationText:String = MovieClip(parent.parent).card.txtEquation.text;

That might work.


Votes

Translate

Translate
LEGEND ,
Nov 01, 2008 Nov 01, 2008

Copy link to clipboard

Copied

If a button in mc1 needs to see text in a field in mc2, and the two mcs are at the same level, it should be able to say:

var sometext:String = MovieClip(parent).mc2.fieldname.text;


Votes

Translate

Translate

Report

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
Explorer ,
Nov 01, 2008 Nov 01, 2008

Copy link to clipboard

Copied

Thanks Colin,

As far as I am aware the structure is stage/MovieClip1("card")/textBoxes(including "txtEquation") and stage/MovieClip2("console")/buttons.

I have just tried putting the following into the function called by a button's eventWatcher:
var newEquationText:String = MovieClip(parent).card.txtEquation.text;
trace(newEquationText);
Is my structure not as I'd thought?

Cheers
Dougal

... and it's thrown up "TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@1dcab461 to flash.display.MovieClip. at quiz_fla::MainTimeline/Next_card()"

Votes

Translate

Translate

Report

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
Explorer ,
Nov 01, 2008 Nov 01, 2008

Copy link to clipboard

Copied

... but that change did at least let the swf move into its runtime, something I'd not been achieving previously.

Votes

Translate

Translate

Report

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
LEGEND ,
Nov 02, 2008 Nov 02, 2008

Copy link to clipboard

Copied

Try:

var newEquationText:String = MovieClip(parent.parent).card.txtEquation.text;

That might work.


Votes

Translate

Translate

Report

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
Explorer ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

LATEST
Thanks Colin. I will try that and report back.

Cheers
Dougal

Votes

Translate

Translate

Report

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