Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Loading External Actionscript
demolaynyc
post Nov 14 2006, 01:28 AM
Post #1


Premium Member
Group Icon

Group: Members
Posts: 330
Joined: 2-February 06
Member No.: 11,040



My friend and I are trying to find a way to load an .as file in a similar way to loading xml. The idea is to store an actionscript inside an xml file but it doesn't seem to work. I tried making an .as file and importing it to flash document the way it imports it is that it just places all the script in the actions panel. This is a flowchart of what we want to do:

[make an external file which contains ACTIONSCRIPTS]
|
[make a script that loads external file w/o pasting code into panel]
|
[call a function from external file]
Go to the top of the page
 
+Quote Post
iGuest
post Nov 12 2007, 12:51 PM
Post #2


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



First of all, flash cant load external scripts dynamically, but can load at compile time. Just write the code AS in an external file (viz myScript.as) and load it by the code #include "myScript.as" (Flash simply replaces that line wwith the code frm file). Alternatively you can make an external swf which contains all ur functions in it, and call them at runtime, thus making a little dynamicity :).

-Samah
Go to the top of the page
 
+Quote Post
iGuest
post Apr 16 2008, 10:39 PM
Post #3


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



include external .as file
Loading External Actionscript

Just do this:



#include "externalfile.As"





Note: **NO** semicolon at the end. This is for ActionScript 2.



-reply by pogo
Go to the top of the page
 
+Quote Post
bcarasco
post Jul 3 2008, 06:19 PM
Post #4


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 7
Joined: 3-July 08
From: Portland, OR
Member No.: 31,268



But if you are using Actionscript 3 this is the way to do it
CODE
include "scripts/myscript.as"


There were many changes between Actionscript 2 to Actionscript three. One of them was getting rid of the "#" before the include directive. Including files is very useful say if you wanted to create a class in AS. It's much easier to interpert your code if you include it in a seperate AS file.
Go to the top of the page
 
+Quote Post
magiccode9
post Sep 2 2008, 02:06 PM
Post #5


Advanced Member
Group Icon

Group: [HOSTED]
Posts: 123
Joined: 7-November 05
Member No.: 9,489



But as a little reminder.
Actionscript 2.0's #include command can't include code file with class
If you do that it will generate an error on output panel.

For code file with class in it.
Just open the flash publish setting and configure the correct classpath.
And the class file will load automatically.

P.S This is only for flash 8 only. I haven't the newer version for testing. sad.gif

This post has been edited by magiccode9: Sep 2 2008, 02:09 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How Can I Bind Dynamic Text In Flash Animation?(3)


 



- Lo-Fi Version Time is now: 5th December 2008 - 12:08 AM