#endif
}
-static void as3_parse_file_or_array(int pass, const char*name, const char*filename, void*mem, int length)
+static void as3_parse_file_or_array(int pass, const char*name, const char*filename, const void*mem, int length)
{
if(!registry_initialized) {
registry_initialized = 1;
} else {
DEBUG printf("[pass %d] parse bytearray %s (%d bytes)\n", pass, name, length);
enter_file(name, name, 0);
- as3_buffer_input(mem, length);
+ as3_buffer_input((void*)mem, length);
}
as3_tokencount=0;
scheduled = f;
}
-void as3_parse_bytearray(const char*name, void*mem, int length)
+void as3_parse_bytearray(const char*name, const void*mem, int length)
{
as3_parse_file_or_array(1, name, 0, mem, length);
as3_parse_scheduled(1);
void as3_add_include_dir(char*dir);
void as3_parse_file(const char*filename);
-void as3_parse_bytearray(const char*name, void*mem, int length);
+void as3_parse_bytearray(const char*name, const void*mem, int length);
void as3_parse_directory(const char*dir);
char as3_schedule_directory(const char*dir);
return c;
}
-void as3_import_code(abc_file_t*abc)
+void as3_import_code(void*_abc)
{
+ abc_file_t*abc = _abc;
int t;
for(t=0;t<abc->classes->num;t++) {
abc_class_t*cls = array_getvalue(abc->classes, t);
#ifndef __as3_import_h__
#define __as3_import_h__
-#include "abc.h"
-
void as3_import_file(char*filename);
void as3_import_swf(char*filename);
void as3_import_abc(char*filename);
-void as3_import_code(abc_file_t*f);
+void as3_import_code(void*f);
+
#endif
void swf_AddButtonLinks(SWF*swf, char stop_each_frame, char events);
TAG*swf_AddAS3FontDefine(TAG*tag, U16 id, char*fontname);
#include "as3/compiler.h"
+#include "as3/import.h"
// swfaction.c
static double height = 300;
static int flashversion = 9;
static int verbose = 1;
+static char local_with_networking = 0;
+static char local_with_filesystem = 0;
static struct options_t options[] = {
{"h", "help"},
as3_add_include_dir(val);
return 1;
}
+ else if (!strcmp(name, "N"))
+ {
+ local_with_networking = 1;
+ return 0;
+ }
+ else if (!strcmp(name, "L"))
+ {
+ local_with_filesystem = 1;
+ return 0;
+ }
else {
printf("Unknown option: -%s\n", name);
exit(1);
tag = swf_InsertTag(tag, ST_END);
swf_FreeABC(code);
+
+ if(local_with_filesystem)
+ swf.fileAttributes &= ~FILEATTRIBUTE_USENETWORK;
+ if(local_with_networking)
+ swf.fileAttributes |= FILEATTRIBUTE_USENETWORK;
writeSWF(&swf);
swf_FreeTags(&swf);
Include library file <file>
-I, --include <dir>
Add include dir <dir>
+-N, --local-with-network
+ Make output file "local with networking"
+-L, --local-with-filesystem
+ Make output file "local with filesystem"
-T, --flashversion <num>
Set target SWF flash version to <num>.
<num> must be >= 9.
}
#define MAX_INCLUDE_DEPTH 16
-YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
-int line_stack[MAX_INCLUDE_DEPTH];
-int column_stack[MAX_INCLUDE_DEPTH];
-int include_stack_ptr = 0;
+static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
+static int line_stack[MAX_INCLUDE_DEPTH];
+static int column_stack[MAX_INCLUDE_DEPTH];
+static int include_stack_ptr = 0;
-void handleInclude(char*text, int len)
+static void handleInclude(char*text, int len)
{
text+=9;len-=9;
while(len >=1 && (text[0] == ' ' || text[0] == '\t')) {
}
#define MAX_INCLUDE_DEPTH 16
-YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
-int line_stack[MAX_INCLUDE_DEPTH];
-int column_stack[MAX_INCLUDE_DEPTH];
-int include_stack_ptr = 0;
+static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
+static int line_stack[MAX_INCLUDE_DEPTH];
+static int column_stack[MAX_INCLUDE_DEPTH];
+static int include_stack_ptr = 0;
-void handleInclude(char*text, int len)
+static void handleInclude(char*text, int len)
{
text+=9;len-=9;
while(len >=1 && (text[0] == ' ' || text[0] == '\t')) {
/* for swf (0): */
SWF*swf;
char*filename;
+ char as3;
/* for sprites (1): */
TAG*tag;
// tag = swf_InsertTag(tag, ST_SHOWFRAME);
tag = swf_InsertTag(tag, ST_SHOWFRAME);
+ if(stack[0].as3) {
+ TAG*tag = swf->firstTag;
+ tag = swf_InsertTag(tag, ST_DOABC);
+ void*code = as3_getcode();
+ swf_WriteABC(tag, code);
+ if(as3_getglobalclass()) {
+ tag = swf_InsertTag(tag, ST_SYMBOLCLASS);
+ swf_SetU16(tag, 1);
+ swf_SetU16(tag, 0);
+ swf_SetString(tag, as3_getglobalclass());
+ } else {
+ warning("no global public MovieClip subclass");
+ }
+ as3_destroy();
+ }
+
tag = swf_InsertTag(tag, ST_END);
swf_OptimizeTagOrder(swf);
void s_action(const char*text)
{
- ActionTAG* a = 0;
- a = swf_ActionCompile(text, stack[0].swf->fileVersion);
- if(!a)
- {
+ if(stack[0].swf->fileVersion < 9) {
+ ActionTAG* a = 0;
+ a = swf_ActionCompile(text, stack[0].swf->fileVersion);
+ if(!a) {
+ swf_ActionFree(a);
+ syntaxerror("Couldn't compile ActionScript");
+ }
+ tag = swf_InsertTag(tag, ST_DOACTION);
+ swf_ActionSet(tag, a);
swf_ActionFree(a);
- syntaxerror("Couldn't compile ActionScript");
+ } else {
+ as3_parse_bytearray(stack[0].filename, text, strlen(text));
+ stack[0].as3 = 1;
}
-
- tag = swf_InsertTag(tag, ST_DOACTION);
-
- swf_ActionSet(tag, a);
-
- swf_ActionFree(a);
}
void s_initaction(const char*character, const char*text)