# Load dynamic AS at runtime

**URL:** <https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259>\
**Category:** flash\
**Created:** [August 11, 2003, 10:16pm UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259 "2003-08-11T22:16:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ascii\_null](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ascii\_null](https://forum.kirupa.com/u/ascii_null)\
**Post date:** [August 11, 2003, 10:16pm UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/1 "2003-08-11T22:16:43Z")

</div>

Hi Forum,

anyone have any suggestions on how to dynamically load an external block of code (e.g. a txt file) at runtime - i.e. a runtime equivalent of #include

thanks

ascii\_null

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2003, 10:26pm UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/2 "2003-08-11T22:26:11Z")

</div>

It’s not possible just like that. There are a few code parsers that could do the job though (check [www.flashcomponents.net](http://www.flashcomponents.net) for instance).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2003, 10:51pm UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/3 "2003-08-11T22:51:36Z")

</div>

Thanks Ilyas Masa,

I had a look around and didn’t see anything that really matched what I wanted - had you a particular component in mind? I’ve looked at parsers before and played around a bit with wddx and other soap protocols but I’ve yet to find one that supports dynamic function declaration.

thanks,

ascii\_null

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2003, 11:07pm UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/4 "2003-08-11T23:07:20Z")

</div>

You’re probably better off waiting for Sen to give you a more precise answer 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2003, 11:50pm UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/5 "2003-08-11T23:50:03Z")

</div>

I really have no clue if you can, but out of curiousity…

Would it work if you loaded in the actions via an external .swf file? I can’t test it right now and this probably wouldn’t be the most efficient way anyway, but I wonder if it would work out.

Also: Why must these actions be imported during runtime instead of called in using #include or even included in the movie itself from the start.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 12, 2003, 12:09am UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/6 "2003-08-12T00:09:10Z")

</div>

Hi lostinbeta,

embedding functions in external swfs will work fine (you just need to be careful with scoping) but unless you create the swfs dynamically using a server ext like Ming then you are still relying on a static source. I would like to define functions on-the-fly at runtime.

In JavaScript/ECMA 262 it’s straightforward enough using evaluate() but the AS eval() is far more limited in it’s scope.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 12, 2003, 3:00am UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/7 "2003-08-12T03:00:35Z")

</div>

Oh, I gotcha.

As Ilyas said, if anyone has your answer it is Sen[ocular], but as far as I know I don’t believe it is possible.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 12, 2003, 10:39am UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/8 "2003-08-12T10:39:25Z")

</div>

the component at flashcomponents is:

**[http://www.flashcomponents.net/component.cfm?nav=2&id=118](http://www.flashcomponents.net/component.cfm?nav=2&id=118)**

This is not perfect though. The results it IS able to achieve is very impressive nonetheless. Still, it needs to parse the text through actionscript and interpret it through actionscript making it a chore and depending on the code, quite slow.

The big solution is loading in a movie with the actionscript embedded within it. This would still, however, require you to create and compile a new swf with that code, but you wouldnt need to touch the original file. You can compile server-side with something like **ming** however

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 12, 2003, 3:18pm UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/9 "2003-08-12T15:18:45Z")

</div>

Thanks, senocular ,

that’s just what I’m looking for.

ascii\_null

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 12, 2003, 4:02pm UTC](https://forum.kirupa.com/t/load-dynamic-as-at-runtime/28259/10 "2003-08-12T16:02:25Z")

</div>

Now that is very cool =)
