A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Object conversion problem.

  1. #1
    Junior Member
    Join Date
    Sep 2001

    Object conversion problem.


    I want to convert a String to Object. I know in AS2.0 eval or [] can be use for this. But in AS3.0 Eval has been dropped and I was not able to find the solution for my problem. Anyone can help?

    My Code is very simple:

    I have a variable in the MainTimeline var tVari = "test Text"
    I have a MovieClip in the MainTimeline name "MC"
    Inside MC I have a component. For this component I have a parameter "vari" as String. My intension is to pass a string into this parameter to point the MainTimeline. So vari="parent.parent"

    I want to use this string into my component to get the data of tVari which is in the MainTimeline.

    Note: I know [] can be use to convert String to Object. But this is not working in my case !! If we have the string as "parent" it is working but not with "parent.parent".

    How can I make this work?

    Thanks for your help.

  2. #2
    Half Empty happinessSam's Avatar
    Join Date
    May 2003
    Using eval or [] doesn't convert a String to an Object. It gets you a reference to a property of an object. So ["parent"] is a reference to the parent property of an object. To get that object's parent you add another ["parent"]. So ["parent"]["parent"].

    But this is beside the point - if you need to access the main timeline why don't you just use stage?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center