Welcome to TalkGraphics.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    1,436

    Default

    I have hundreds of coloured squares which, when the user chooses one, the click sends data to another variable.

    Each square is named uniquely. The tedious coding is to have:

    on (release) {
    myColor = new Color(p1s1);
    rgb = myColor.getRGB();
    }

    Is there any way to make it assume the 'p1s1' bit so I don't have to have special code for every one of the x hundred squares? I've tried (blundered round) several This... variations but none worked.

    Thanks...

    www.bricksandbrass.co.uk
    Simon
    ------------------------------
    www.tlaconsultancy.co.uk
    www.bricksandbrass.co.uk
    IP

  2. #2
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    1,436

    Default

    I have hundreds of coloured squares which, when the user chooses one, the click sends data to another variable.

    Each square is named uniquely. The tedious coding is to have:

    on (release) {
    myColor = new Color(p1s1);
    rgb = myColor.getRGB();
    }

    Is there any way to make it assume the 'p1s1' bit so I don't have to have special code for every one of the x hundred squares? I've tried (blundered round) several This... variations but none worked.

    Thanks...

    www.bricksandbrass.co.uk
    Simon
    ------------------------------
    www.tlaconsultancy.co.uk
    www.bricksandbrass.co.uk
    IP

  3. #3
    Join Date
    Aug 2000
    Location
    Toronto, Ontario, Canada
    Posts
    432

    Default

    how are you creating the squares? are they all done on the stage? or are they done by code? cuz if you create them via code (duplicating movie clips, then setting the colour of the squares), then you can name them dynamically. alternately, you can set their colour object on an enterframe using a loop. here's some pseudo-code:

    myColor = new Array;
    var i = 0;
    var j = 0;
    for i = 1 to x {
    for j = 1 to y {
    mySquare = "p" + i + "s" + j;
    myColor[mySquare] = new Color(mySquare);
    }
    }

    then you can use an on release to check the color of the square by using "mySquareColor = myColor[square_clip_name].getRGB;", which would work if you've named each square clip properly (like p1s1, p1s2, etc.)

    hth
    deep (just a guy)


    hth,
    Deep (just a guy)
    <font face="arial" size="2">
    Pradeep Kumar Nair, B.Math
    Interactive Developer
    http://www.bluespark.com
    ICQ: 39102360
    </font>
    hth,
    Deep (just a guy)
    --
    Pradeep Kumar Nair, B.Math
    CTO
    9 Story Entertainment
    http://www.9story.com
    IP

 

 

Bookmarks

Posting Permissions

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