开发者

taking variable from parent to child and inserting it into dynamic text field

开发者 https://www.devze.com 2023-03-26 01:31 出处:网络
I\'m trying to take a variable from the parent movieclip and use it in the child movieclip inside of a dynamic text field.

I'm trying to take a variable from the parent movieclip and use it in the child movieclip inside of a dynamic text field.

The variable has a value that is taken from a php file.

I'm completely lost at the moment and know that my code is probably completely wrong.

here it is:

parent movieclip:

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE,onLoaded);
loader.load(new URLRequest("../SC/FLA_cont-btn.php"));


function onLoaded(evt:Event):void
{
var data:URLVariables = new URLVariables(event.target.data);
variables.sponny = data.sponny_name;
}

开发者_开发问答Child movieclip:

trace((parent as MovieClip).variables.sponny);

sponsor_name.text = +variables.sponny;

I get 2 errors using this code:

1120: Access of undefined property event. 1120: Access of undefined property variables.

any help would be much appreciated!


Error 1:

Its called evt here: function onLoaded(evt:Event):void

And here you are trying to inspect an event: new URLVariables(event.target.data);

Error 2:

Is variables a property of the parent movie clip? Then you should write:

trace((parent as MyMovieClipClass).variables.sponny);

sponsor_name.text += (parent as MyMovieClipClass).variables.sponny;

Additional Tipp:

If sponsor_name is a TextField, use appendText(text) instead of += text.

0

精彩评论

暂无评论...
验证码 换一张
取 消