A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: problem with setting alpha in script

  1. #1
    Senior Member
    Join Date
    Dec 2000
    Posts
    104

    problem with setting alpha in script

    I created a component that has a green button in it. Then on my main timeline I have a script that runs through a loop and sets the button's alpha in each component instance to 0. Then, after that I load some data from an asp page and attempt to set the alpha to 30 on certain instances. No matter what I do, resetting the alpha doesn't seem to show up. I've set up the script so that after it resets the alpha to 30, I then trace the alpha setting of it. Sure enough it outputs 30, but visually, it's still at 0. Is there something I need to do to get the component or screen to refresh to actually show the new alpha setting? Thanks.

  2. #2
    Senior Member
    Join Date
    Jul 2003
    Posts
    156
    This may seem like a painfully obvious suggestion, but make sure that your pathing is correct. If you are setting the alpha via code it will have the number stored even if you haven't actually been succesfull at changing the the object alpha.

  3. #3
    Senior Member
    Join Date
    Dec 2000
    Posts
    104
    Yes, I made sure that the path was correct. In fact, when my movie loads, I first use AS to loop through all the instances of this component with the following code...

    for (i=1;i<81;i++){
    bth = eval("bth"+i);
    _root.bth.opac=0;
    }

    That all works fine. But after that code fires, then my loadvars code executes...

    var BoothVars = new LoadVars();
    BoothVars.onLoad = function(success){
    if (success){
    TakenBooths = BoothVars.booths.split("|");

    if (TakenBooths != "" && TakenBooths != undefined){
    for (i=0; i < TakenBooths.length; i++){
    bth = eval("bth" + TakenBooths[0]);
    _root.bth.opac = 30;
    //trace(_root.bth.opac);
    }
    }
    }else{
    bthDetails.txtCompanyName.htmlText = "error";
    }
    }

    BoothVars.load("ReturnTakenBooths.asp?CareerFairId =3");


    So, it appears that the path is correct from as far as I can tell. Does anything look wrong to you? Also, to make sure the path was correct, each component also has a number property. Along with tracing the alpha, I also traced the number property and it returned the correct one. So, I'm sure I'm working with the right instance. Thanks.

  4. #4
    Senior Member
    Join Date
    Jul 2003
    Posts
    156
    Try changing "opac" to "alpha". I've never seen opac before and I just looked in the dictionary and didn't see it either. Otherwise it looks like it should work.

  5. #5
    Senior Member
    Join Date
    Dec 2000
    Posts
    104
    opac is a property I set on the component. when you set opac, the component then sets the alpha of the correct portion of itself. I ended up getting it to work by creating a function in my component that sets the alpha. so, in the ...

    for (i=0; i < TakenBooths.length; i++){
    bth = eval("bth" + TakenBooths[0]);
    _root.bth.opac = 30;
    //trace(_root.bth.opac);
    }

    code, I changed _root.bth.opac=30 to _root.bth.opac.SetOpacity(30) and that took care of it. What's strange is that the same function will not work in the 1st loop where it goes through all bth instances. But, I've got it all working now, one way or another, so I'm not going to worry about it much more. Thanks though!

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