Skip to content

Commit a8810ff

Browse files
committed
core: Add test for refreshed frame scripts
1 parent c4742da commit a8810ff

File tree

8 files changed

+278
-0
lines changed

8 files changed

+278
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Main constructor
2+
Container constructor
3+
Child constructor
4+
GrandChild constructor
5+
GrandChild addFrameScript
6+
Child addFrameScript
7+
LeafChild constructor
8+
LeafChild addFrameScript
9+
Container addFrameScript
10+
Main addFrameScript
11+
Main frame1
12+
Container frame1
13+
Child frame1
14+
GrandChild frame1
15+
LeafChild frame1
16+
entered frame 2
17+
calling goto on grandchild
18+
Main frame2
19+
Container frame2
20+
Child frame2
21+
GrandChild frame1
22+
LeafChild frame2
23+
calling goto on child
24+
Child frame1
25+
adding frame-script to grandchild
26+
secret reached!
27+
entered frame 1
28+
Container frame1
29+
Child frame2
30+
LeafChild frame1
31+
entered frame 2
32+
Main frame1
33+
Container frame2
34+
LeafChild frame2
35+
Main frame2
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package
2+
{
3+
import flash.display.MovieClip;
4+
5+
public class Main extends MovieClip
6+
{
7+
public var child:*;
8+
9+
public var repeats:uint = 0;
10+
11+
public var descendant_names:Array = ["Container","Child","GrandChild","LeafChild"];
12+
13+
public var descendant_order:Array = [0,0,0,0];
14+
15+
public function Main()
16+
{
17+
trace("Main constructor");
18+
super();
19+
this.addScripts();
20+
}
21+
22+
public function collectDescendants() : Array
23+
{
24+
return [this.child].concat(this.child.collectDescendants());
25+
}
26+
27+
public function addScripts() : *
28+
{
29+
trace("Main addFrameScript");
30+
addFrameScript(0,this.frame1,1,this.frame2);
31+
}
32+
33+
internal function frame1() : *
34+
{
35+
trace("Main frame1");
36+
}
37+
38+
internal function frame2() : *
39+
{
40+
trace("Main frame2");
41+
if(this.repeats > 0)
42+
{
43+
stop();
44+
}
45+
else
46+
{
47+
this.repeats += 1;
48+
}
49+
}
50+
}
51+
}
52+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package
2+
{
3+
import flash.display.MovieClip;
4+
5+
public class MyChild extends MovieClip
6+
{
7+
public static var counter:uint = 1;
8+
9+
public var grandchild:*;
10+
11+
public var id:uint = counter;
12+
13+
public var repeats:uint = 0;
14+
15+
public var name:String = "Child";
16+
17+
public function MyChild()
18+
{
19+
counter += 1;
20+
trace(this.name + " constructor");
21+
super();
22+
this.addScripts();
23+
}
24+
25+
public function collectDescendants() : Array
26+
{
27+
return [this.grandchild].concat(this.grandchild.collectDescendants());
28+
}
29+
30+
public function addScripts() : *
31+
{
32+
trace(this.name + " addFrameScript");
33+
addFrameScript(0,this.frame1,1,this.frame2);
34+
}
35+
36+
internal function frame1() : *
37+
{
38+
trace(this.name + " frame1");
39+
}
40+
41+
internal function frame2() : *
42+
{
43+
trace(this.name + " frame2");
44+
if(this.repeats > 0)
45+
{
46+
stop();
47+
}
48+
else
49+
{
50+
this.repeats += 1;
51+
}
52+
}
53+
}
54+
}
55+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package
2+
{
3+
import flash.display.MovieClip;
4+
import flash.events.*;
5+
6+
public class MyContainer extends MovieClip
7+
{
8+
public var myChild1:*;
9+
10+
public var myChild2:*;
11+
12+
public var went_once:Boolean = false;
13+
14+
public var repeats:uint = 0;
15+
16+
public function MyContainer()
17+
{
18+
trace("Container constructor");
19+
super();
20+
this.addScripts()
21+
addEventListener(Event.ENTER_FRAME,this.enter_frame);
22+
}
23+
24+
public function collectDescendants() : Array
25+
{
26+
return [this.myChild1].concat(this.myChild1.collectDescendants()).concat([this.myChild2]).concat(this.myChild2.collectDescendants());
27+
}
28+
29+
public function addScripts() : *
30+
{
31+
trace("Container addFrameScript");
32+
addFrameScript(0,this.frame1,1,this.frame2);
33+
}
34+
35+
internal function enter_frame(param1:Event = null) : *
36+
{
37+
trace("entered frame", this.currentFrame);
38+
if (!went_once) {
39+
went_once = true;
40+
trace("calling goto on grandchild");
41+
myChild1.grandchild.gotoAndStop(1);
42+
trace("calling goto on child");
43+
myChild1.gotoAndPlay(1);
44+
trace("adding frame-script to grandchild");
45+
myChild1.addFrameScript(0,this.secret_frame);
46+
}
47+
}
48+
49+
internal function secret_frame() : *
50+
{
51+
trace("secret reached!");
52+
}
53+
54+
internal function frame1() : *
55+
{
56+
trace("Container frame1");
57+
}
58+
59+
internal function frame2() : *
60+
{
61+
trace("Container frame2");
62+
if(this.repeats > 0)
63+
{
64+
removeEventListener(Event.ENTER_FRAME,this.enter_frame);
65+
stop();
66+
}
67+
else
68+
{
69+
this.repeats += 1;
70+
}
71+
}
72+
}
73+
}
74+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package
2+
{
3+
import flash.display.MovieClip;
4+
5+
public class MyLeaf extends MovieClip
6+
{
7+
public static var counter:uint = 1;
8+
9+
public var id:uint = counter;
10+
11+
public var repeats:uint = 0;
12+
13+
public var name:String = "";
14+
15+
public function MyLeaf()
16+
{
17+
if(this.id == 1)
18+
{
19+
this.name = "GrandChild";
20+
}
21+
else
22+
{
23+
this.name = "LeafChild";
24+
}
25+
counter += 1;
26+
trace(this.name + " constructor");
27+
super();
28+
this.addScripts();
29+
}
30+
31+
public function collectDescendants() : Array
32+
{
33+
return [];
34+
}
35+
36+
public function addScripts() : *
37+
{
38+
trace(this.name + " addFrameScript");
39+
addFrameScript(0,this.frame1,1,this.frame2);
40+
}
41+
42+
internal function frame1() : *
43+
{
44+
trace(this.name + " frame1");
45+
}
46+
47+
internal function frame2() : *
48+
{
49+
trace(this.name + " frame2");
50+
if(this.repeats > 0)
51+
{
52+
stop();
53+
}
54+
else
55+
{
56+
this.repeats += 1;
57+
}
58+
}
59+
}
60+
}
61+
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
num_ticks = 5

0 commit comments

Comments
 (0)