doubingling4706 2011-08-04 13:48
浏览 22
已采纳

将变量从父变为子并将其插入动态文本字段

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!

  • 写回答

1条回答 默认 最新

  • donglie1994 2011-08-04 13:50
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度