Source code: com/anotherbigidea/flash/movie/Actions.java
1 /****************************************************************
2 * Copyright (c) 2001, David N. Main, All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or
5 * without modification, are permitted provided that the
6 * following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials
15 * provided with the distribution.
16 *
17 * 3. The name of the author may not be used to endorse or
18 * promote products derived from this software without specific
19 * prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ****************************************************************/
34 package com.anotherbigidea.flash.movie;
35
36 import java.io.ByteArrayOutputStream;
37 import java.io.IOException;
38 import java.util.Vector;
39
40 import com.anotherbigidea.flash.interfaces.SWFActions;
41 import com.anotherbigidea.flash.readers.ActionParser;
42 import com.anotherbigidea.flash.writers.ActionWriter;
43 import com.anotherbigidea.io.OutStream;
44
45 /**
46 * A set of actions
47 */
48 public class Actions extends ActionWriter
49 {
50 protected int conditions;
51 protected byte[] bytes;
52
53 public Actions( int conditions, int flashVersion )
54 {
55 super( null, flashVersion );
56
57 this.conditions = conditions;
58 count = 0;
59 bout = new ByteArrayOutputStream();
60 out = new OutStream( bout );
61 pushValues = new Vector();
62 labels = null;
63 jumps = null;
64 skips = null;
65 blocks = null;
66 blockStack = null;
67 }
68
69 public Actions( int flashVersion )
70 {
71 this( 0, flashVersion );
72 }
73
74 /**
75 * Parse the action contents and write them to the SWFActions interface
76 */
77 public void write( SWFActions swfactions ) throws IOException
78 {
79 ActionParser parser = new ActionParser( swfactions, flashVersion );
80 swfactions.start( conditions );
81 parser.parse( bytes );
82 swfactions.done();
83 }
84
85 /**
86 * The condition flags depend on context - frame, button or clip actions
87 */
88 public int getConditions() { return conditions; }
89
90 public void setConditions( int conds ) { this.conditions = conds; }
91
92 /**
93 * SWFActions interface
94 */
95 public void start( int conditions ) throws IOException
96 {
97 //do nothing
98 }
99
100 protected void writeBytes( byte[] bytes ) throws IOException
101 {
102 this.bytes = bytes;
103 }
104
105 /**
106 * SWFActions interface
107 */
108 public void done() throws IOException
109 {
110 //do nothing
111 }
112 }