Nov 20, 2009

Loading External Actionscript

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > ActionScript

Loading External Actionscript

demolaynyc
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]

Comment/Reply (w/o sign-up)

FeedBacker
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

Comment/Reply (w/o sign-up)

FeedBacker
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

Comment/Reply (w/o sign-up)

bcarasco
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.

Comment/Reply (w/o sign-up)

magiccode9
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

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


See Also,

*SIMILAR VIDEOS*
Searching Video's for loading, external, actionscript
advertisement



Loading External Actionscript

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com