dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: build target path using random

Hybrid View

  1. #1
    Junior Member
    Join Date
    Nov 2004
    Location
    Jax, Fl
    Posts
    13

    build target path using random

    hello,

    Im having trouble with datatypes in my variables. What I would like to do is build a target path like this:
    PHP Code:
    targetCell ="_root.space" + (random(3)+1)+".load1"
    and then reference it later like this:
    PHP Code:
    al targetCell._alpha 
    it works fine if I dont include the random like this:
    PHP Code:
    targetCell =_root.space1.load1
    so my problem is in transforming the string back. How do I do that? Or is there a way to build the path without strings in the first place?

  2. #2
    dubba you tee eff steven_h_2000's Avatar
    Join Date
    Oct 2000
    Location
    Columbus, Ohio
    Posts
    137
    you cant reference a String

    I think this is what you are wanting:

    Code:
    var targetCell:Object = _root["space" + (random(3)+1)].load1;
    al = targetCell._alpha;
    the strict data typing is not a must but you won't see me coding without it! see Why strict data typing is Good for more details

  3. #3
    Junior Member
    Join Date
    Nov 2004
    Location
    Jax, Fl
    Posts
    13

    doesn't work

    I'm sure its user error. I have a trace on it that comes back as undefined.

  4. #4
    Junior Member
    Join Date
    Nov 2004
    Location
    Jax, Fl
    Posts
    13
    Got it.

    var targetCell:Object = new Object();
    targetCell=_root["space" + (random(3)+1)].load1;

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