A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: This should be easy

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Posts
    134

    Thumbs down

    okay i finally found a way to make an actionscript strobe effect.
    heres the problem, I made a word strobe with no sweat. But i want it to break apart and make each letter strobe randomly.
    do i have to apply the effect to each letter?
    well i guess i ansered my own question huh. anyways hweres the other part.

    heres the code i am using, and it works by itself in a movie but when i tried to add the effect to an object in my movie i get the following error messages.

    my code:

    num = random(101);
    setProperty("micro", _alpha, num);

    Error:

    Scene=Scene 1, Layer=Layer 13, Frame=2: Line 1: Identifier expected
    onClipEvent () {

    Scene=Scene 1, Layer=Layer 13, Frame=2: Line 3: Statement must appear within on/onClipEvent handler
    num = random(101);

    Scene=Scene 1, Layer=Layer 13, Frame=2: Line 4: Statement must appear within on/onClipEvent handler
    setProperty("/city", _alpha, num);

    what the heck am i leaving out that i get this error here and not on the other??? I know its really easy so thanks for the help.

  2. #2
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    You have placed this code on a movieClip object and didn't include the onClipEvent.. your code should look like this:

    onClipEvent(load){
    num = random(101);
    setProperty("micro", _alpha, num);
    }

    If you want the _alpha to change as soon as the clip loads. Here is the same code written differently:

    onClipEvent(load){
    num = Math.random()*100+1;
    _alpha=num;
    }

    If you wanted it to change x times a second based on x frame rate:


    onClipEvent(enterFrame){
    num = Math.random()*100+1;
    _alpha=num;
    }

    Happy strobing!


  3. #3
    Senior Member
    Join Date
    Jan 2001
    Posts
    134

    thanks

    thanks a great deal for all your help it works like a champ thanks again

  4. #4
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    My pleasure.

  5. #5
    Senior Member
    Join Date
    Jan 2001
    Posts
    134

    i got a new error

    it worked for a second but now i am getting this error:

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: You must export your movie as Flash 5 to use this action.
    onClipEvent(load){

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: You must export your movie as Flash 5 to use this action.
    onClipEvent(load){

    ever seen such a thing, its not a problem to export as flash 5 but i was wondering what changed in MX that would cause such a problem.

    thanks

  6. #6
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    the Math.random()*100 + 1 line

    Change that back to the way you had it for export to Flash 5. Sorry, didn't know that was required.

    Cheers

  7. #7
    Senior Member
    Join Date
    Jan 2001
    Posts
    134

    Wink okay last time i bother you

    i did everything i could think of and changed it back even. but when i export or test the movie the alpha fade just fades once and stops so it looks like my object is alpha'd at about 50% is there something that could be stopping the effect. I have to export as MX though cause i have stuff not supported by version 5.

    so in effect i have alpha faded my object (the fade is random) but it stops right there and no more fading. It just sticks there. at whatever random fade it chooses. so one time it will be 10 the next 80 but no strobing.

    heres my how i did it i added a square for testing purposes
    converted it to an MC renamed it "bob" and changed the script to act on "bob". It works fine by itself in a movie but in my movie with the other stuff it locks up. But my masking MC works fine. so its just this one thats locking up and sticking at a random fade. Any ideas??? I tried the other scripts too and to no avail. I really appreciate your help by the way.

    here it is again:

    onClipEvent(load){
    num = random(101);
    setProperty("micro", _alpha, num);
    }

  8. #8
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    the alpha fade just fades once and stops so it looks like my object is alpha'd at about 50% is there something that could be stopping the effect?
    Yes, it is because the onClipEvent(load){} only operates one time, well, each time the clip loads, that is.

    If you use the onClipEvent(enterFrame) handler instead and say your fps is set at 12, then 12 times a second your clip will pick a new _alpha between 1 and 100.

    Code:
    onClipEvent(enterFrame){ 
         num = random(101); 
         _alpha=num;//this affects whatever clip this code is on
    }
    l8r

  9. #9
    Senior Member
    Join Date
    Jan 2001
    Posts
    134

    Smile thanks it finally works

    thanks i really apprecizate it you have come through for me thanks a lot.

  10. #10
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    My pleasure m8!

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