• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Scripted Snow with camera layer

Explorer ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

I have a problem combining the Scripted Snow from the templates with camera layer.

If I create a new document using Templates\Animation\Scripted Snow, I cannot activate the camera layer. Consider the document has Flash Player 11.2/Actionscript 3.0 settings by default but also works if changed to Flash Player 30.0. I assume the FLA was created on a previous version of Animate CC.

However, If I create a new Actionscript 3.0 FLA and paste the template’s layers, including the actions layer, as well as copy all items to the library and the scene, I do get the camera option but I also get a repeated error message and the snow effect does not work:

TypeError: Error #1006: addTarget is not a function.

                at Santa18altsnowB_fla::MainTimeline/randomInterval()

                at Function/http://adobe.com/AS3/2006/builtin::apply()

                at SetIntervalTimer/onTimer()

                at flash.utils::Timer/_timerDispatch()

                at flash.utils::Timer/tick()

So, my main question is: what is the problem and how can I use this or similar code to create snow effect on new type documents with the camera layer option.

Secondary question is: how can I limit the snow effect to part of the screen, preferably using a mask layer. I have tried using a mask layer on the actions layer unsuccessfully.

Below is the Actionscript 3.0 code included in the template FLA.

Thanks

// Number of symbols to add.

const NUM_SYMBOLS:uint = 75;

var symbolsArray:Array = [];

var idx:uint;

var flake:Snow;

for (idx = 0; idx < NUM_SYMBOLS; idx++) {

    flake = new Snow();

addChild(flake);

    symbolsArray.push(flake);

    // Call randomInterval() after 0 to a given ms.

    setTimeout(randomInterval, int(Math.random() * 10000), flake);

}

function randomInterval(target:Snow):void {

   

    // Set the current Snow instance's x and y property

                target.x = Math.random()* 550-50;

    target.y = -Math.random() * 200;

               

                //randomly scale the x and y

                var ranScale:Number = Math.random() * 3;

                target.scaleX = ranScale;

                target.scaleY = ranScale;

               

                var tween:String;

                // ranScale is between 0.0 and 1.0

                if (ranScale < 1) {

                                tween = "slow";

                               

                // ranScale is between 1.0 and 2.0

                } else if (ranScale < 2) {

                                tween = "medium";

                               

                // ranScale is between 2.0 and 3.0

                } else {

                                tween = "fast";

                               

                }

    //assign tween nested in myClip

                myClip[tween].addTarget(target);

               

}

Views

326

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Nov 29, 2018 Nov 29, 2018

Got help on Reddit: apparently turning off advanced layers solves the problem.

However, it is obvious that this should not happen. Is there any turn-around so I can get both the script working and use the camera layer and parenting at the same time?

Votes

Translate

Translate
Explorer ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

LATEST

Got help on Reddit: apparently turning off advanced layers solves the problem.

However, it is obvious that this should not happen. Is there any turn-around so I can get both the script working and use the camera layer and parenting at the same time?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines