Skip to main content
Known Participant
March 30, 2014
Answered

Variable in Movie Clip [ActionScript 2.0]

  • March 30, 2014
  • 1 reply
  • 2045 views

Hello, I am still newbie, i just want to create a very simple thing with the movie clip, i have search through internet for 2 days and found nothing.

So, this is a problem :

-> I have a movie clip name flip_box and in the Frame 1, i add action :

nowtext = "0000";

-> in the frame 15 until 23 -> I have dynamic Text -> Instance name = hitungan

--> in the Frame 15 , I add action :

hitungan.text = nowtext;

and then in the Scene 4

i add action in the Frame 1 :

var box1:MovieClip = _root.attachMovie("flip_box_lg", "fb1", this.getNextHighestDepth(),{_x:100,_y:100});

box1._width = 100;

box1._height = 40;

//_root.box1.nowtext = "50/5";

trace(_root.box1.nowtext);

trace(_root.box1[nowtext]);

trace(_root.box1['nowtext']);

trace(_root.box1.fb1.nowtext);

trace(_root.fb1.nowtext);

trace(_root.box1.flip_box_lg.fb1.nowtext);

trace(_root.flip_box_lg.fb1.nowtext);

trace(_root.flip_box_lg.nowtext);

trace(_root.MovieClip.nowtext);

trace(_root.MovieClip.box1.nowtext);

trace(_root.box1.variable.nowtext);

And this is the photo of the flip_box properties

all the trace is undefined,

i just want to change the Dynamic Text (hitungan) via actionscript

all I wanna to do is Change Dynamic Text inside the Movie Clip that i attach to the stage.

Thanks Before


This topic has been closed for replies.
Correct answer kglad

Could you please give me a code that probably could fix the problem ?

Is my code (writing the as2 about movie clip variable) wrong or there is another problem ?


it's not necessarily a problem.  it's just a matter of understanding how flash works.

as already mentioned, when you create a new instance of flip_box the code in its first frame does NOT instantly execute.  it executes after the movieclip is created.

you could use a delay to assign nowtext after it's assigned on the movieclip's timeline.  eg,

var box1:MovieClip = _root.attachMovie("flip_box_lg", "fb1", this.getNextHighestDepth(),{_x:100,_y:100});

this.onEnterFrame=assignF;

function assignF():Void{

delete this.onEnterFrame;

nowtext="50/5";

}

1 reply

kglad
Community Expert
Community Expert
March 30, 2014

what's trace(box1) show?

if undefined, you must publish for fp 7 or better to use getNextHighestDepth and you should be using _root.getNextHighestDepth() because you're attaching that box to _root.

else you have a typo somewhere.

JiQAuthor
Known Participant
March 31, 2014

_level0.fb1 -> trace(box1)

[if undefined, you must publish for fp 7 or better to use getNextHighestDepth and you should be using _root.getNextHighestDepth() because you're attaching that box to _root.

else you have a typo somewhere.]

What does it mean ? And how ?

kglad
Community Expert
Community Expert
March 31, 2014

it means there's no nowtext on frame 1 of box1 (or nowtext is a component like a textarea).