The 2DIY Script Archive

A resource of Actionscript examples for 2Simple's 2DIY software

  • Home
  • ActionScript
  • Animation Script
  • Collision Script
  • Start Button Script
  • Examples
  • Ideas
  • Help / Videos
  • Discuss

ActionScript Index

This section details more advanced settings in 2DIY - some technical knowledge is recommended.
On any of the activities in 2DIY, you have further scope for customisation if you right-click the play button (the green triangle). When you do this a new window will appear on your screen with extra settings, detailed below. All the settings start with “_root.”
  • allowMoveByKeys

applies to Drag, Multi Drag, Shapes, Sound Drag, Placing activities  
Possible Values are True / False 
Effect: Move objects using keys UDLR

  • allowRotateByKeys 

applies to Drag, Multi Drag, Shapes, Sound Drag, Placing activities 
Possible Values are True / False 
Effect: Rotate objects using left and right arrow keys

  • allowResizeByKeys

applies to Drag, Multi Drag, Shapes, Sound Drag, Placing activities
Possible Values are True / False 
Effect: Resize objects using up and down arrow keys

  • allowWidenByKeys 

applies to Drag, Multi Drag, Shapes, Sound Drag, Placing activities 
Possible Values are True / False 
Effect: Widen/thin objects using keys T and W

  • allowZorderByKeys 

applies to Drag, Multi Drag, Shapes, Sound Drag, Placing activities 
Possible Values areTrue / False
Effect: Change which objects are in front of other objects using F key
Note: only really applicable to Shapes since for other screens the objects will automatically come to the front when you click on them

  • snapBackIfWrong

applies to Placing, Cloze, Sequencing,Labelling, Grouping activities
Possible Values are True / False
Effect: Object snaps back to its original place if dragged to an incorrect position
Note: only applies to the last 3 Placing screens

  • centreIfCorrect

applies to Placing, Cloze, Sequencing, Labelling activities
Possible Values are True / False
Effect: Object automatically moves to the centre of its block, once dragged to the correct position
Note: only applies to the last 3 Placing screens

  • allowMultipleAnswers 

applies to Quiz 
Possible Values are True / False 
Effect: Allow multiple attempts to give the correct answer

  • showScoreAlways 

applies to Multi Choice activities 
Possible Values are True / False 
Effect: Display the score during the quiz

  • numFrames2Pause

applies to Pairs activity
Possible Values are 0 - 100
Effect: Once two cards have been flipped face up, choose how long to wait before flipping them back over again (default = 30 = 1 second)

  • hitDist 

applies to All Games 
Possible Values are 5 - 60
Effect: Change how sensitive 2DIY is when detecting a collision between the player and any other object. Low value = not sensitive

  • maxMovers 

applies to Catching activity
Possible Values are 1 - 24
Effect: Maximum number of falling objects on screen at any time

  • maxSpeed 

applies to Catching activity
Possible Values are 1 - 15 
Effect: Maximum speed of a falling object

  • carSteerDeg 

applies to Journey activity
Possible Values are 3 - 25 
Effect: Tightness of turning angle

  • maxCarSpeed 

applies to Journey activity
Possible Values are 1 - 30
Effect: Car speed on road surface
Note: A car’s road surface colour is defined as the surface colour directly under the car when the game starts.

  • maxCarOFRspeed 

applies to Journey activity
Possible Values are 1 - 30
Effect: Car speed off road
Note: A car’s road surface colour is defined as the surface colour directly under the car when the game starts.

  • maxFallingSpeed 

applies to Platform activity
Possible Values are 1 - 16 
Effect: Maximum player falling speed

  • jumpSpeed 

applies to Platform activity
Possible Values are -10 to -25 
Effect: Player jumping height

  • dx 

1. In Sound, Drag activites drag
Possible Values are 1 - 30 
Effect: Speed at which the sound slider moves


2. In a Platform activity
Possible Values are 2 - 20
Effect: Speed at which the player moves

  • dxy 

1. applies to Collecting, Maze activities
Possible Values are 2 - 20 
Effect: Speed at which the player moves

2. applies to Catching activity
Possible Values are 5 - 50 
Effect: Speed at which the player moves

3. applies to Snake activity 
Possible Values are 2,4,5,8,20,40 
Effect: Speed at which the snake moves




You can add code which retrieves information about the various objects on screen, and you can also set specific properties of these objects. The names of the different objects in 2DIY are listed in this section.


The numbers in the brackets below indicate that on some of the screens not all objects are applicable eg. In the 4th Drag screen there are 15 objects but in the first Drag screen there are only 6 objects and the background.

Some screens have multiple copies of the same object - for example in the 1st Multi Drag screen there appear to be only 5 objects on screen, but when you press play, each of the 5 objects has 6 copies of itself, for a total of 30 objects. The copies have the same picture, sound and animation properties but are still individual objects and are referred to with different names, eg the 6 copies of the first object in Multi Drag are named p1, p2… p6.
The background object is sometimes named “bear” and sometimes “bg”. “sc” refers to the score.

Activity: Drag 
Object Names: bear, p1 - p15 (6 / 8 / 10 / 15)

Activity: Multi Drag 
Object Names:bear, p1 - p156 (30 / 48 / 96 / 156 / 90) 6 copies of each object

Activity: Shapes 
Object Names:bg, p1 - p200 (100 / 200) 20 copies of each

Activity: Sound Drag 
Object Names:bg, p1 - p90 (30 / 48 / 90) 6 copies of each

Activity: Placing 
Object Names:bear, sc, p1 - p96 (30 / 48 / 96 / 5 / 8 / 16) 6 (or 1) copies of each

Activity: Sequencing 
Object Names:bg, sc, p1 - p8 (6 / 6 / 8 / 6)

Object numbers are according to the randomised order

Activity: Grouping 
Object Names:bg, sc, p1 - p24 (12 / 27 / 18 / 24) As Above

Activity: Labelling 
Object Names:bg, t1 - t12 (text) As Above

Activity: Collecting 
Object Names: bg, player, sc, s2-11 (monsters), s12-s21 (apples), s22-s31 (suns) Further objects added will be s32, s33 etc

Activity: Journey 
Object Names: Same as Collecting except “car” instead of player As Above

Activity: Platform 
Object Names: Same as Collecting except starts from s3 As Above

Activity: Snake 
Object Names: Same as Collecting except starts from s3 As Above

Activity: Maze 
Object Names: Same as Collecting except starts from s3 As Above



Object properties that can be used:
  • visible

Possible Values are true / false

  • rotation

Possible Values 0 - 360

  • x

Possible Values 0 - 640 (0 is the top left of the screen)

  • y

Possible Values 0 - 480 (0 is the top left of the screen)

  • width

Possible Values 0 - 640

  • height

Possible Values 0 - 480

  • xscale

Possible Values 100 indicates 100%, ie default scale. 200 will double the scale in the x direction. 50 will halve it.

  • yscale

Possible Values As above in y direction




Other advanced code tips for the technically minded:

  • _root.v is the variable which stores the current velocity of the car.
  • _root.resetTimer() will reset the clock to what it was at the start of the game.
  • _root.lives is the variable which stores the current number of lives the player has. If you change the number of lives you should also call 
  • _root.showLives() which updates the lives display on screen (it will not display more than the initial number of lives set).
  • loadMovie() allows you to load another swf (or jpg) file into any target object. For example, _root.p1.loadMovie(“other.swf”); will load a file named other.swf (which is located in the same folder as the swf file you are running) into object p1. This method is not recommended for loading other swf files created using 2DIY, though.
Create your own variables

For example in the initialisation section define a variable as follows: 

var myVariableName:Number=0;

You can then refer to this variable in other code sections of 2DIY.

Recent Posts

  • Coding with 2DIY - a 6 week unit of lessons
  • 2DIY and the New Computing Curriculum
  • 2DIY with Gifted and Talented groups
  • Making characters fly (and other effects)
  • High Lawn Primary Games
  • Creative Learning
  • Gallons of Games
  • Games Pod Creations
  • Kensington Avenue Primary 'Games Pod'
  • Actionscript Tutorial No.8

Categories

  • 2DIY Examples (175)
  • Actionscript Code Names (1)
  • Animation Actionscript (9)
  • Collision Actionscript (10)
  • General (10)
  • Lesson Plans & Ideas (15)
  • Start Button Actionscript (4)
  • Tutorials (43)
See More

Search

| The 2DIY script archive |

Maintained by the Digital Learning Coordinator, Porchester Junior School, Nottingham.

The actionscript codes that are used within this archive were provided by
Max Waineright and Dan Ziskind and reproduced with their permission.