A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: accessing assets on stage using Document class

  1. #1
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508

    accessing assets on stage using Document class

    ok, if an asset is on stage (design time) and it has an instance name AND it's on frame 1, I can access it BUT if it's frame 2 or beyond, I get errors....any ideas on how to refer to assets on stage frame 2 and beyond within your Document class? thanks!

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Your document class is executing on frame 1 so things on subsequent frames don't yet exist (so you cant target them)...There is a little secret called addFrameScript that might help you - here's a good writeup on it.

  3. #3
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    what real good is a Document class if you are limited to frame 1 for everything you have to do? that's very constricting! I read that article and it's poorly written, needs more simple "nuts & bolts" examples to illustrate the point. So what is the explanation for "addFrameScript"? what's its main purpose?

    thanks!

  4. #4
    Senior Member
    Join Date
    Jul 2005
    Posts
    126

    Use gskinners FrameScript class...

    I would recommend using the FrameScript class created by gSkinner. Read about it here: gSkinner blog>>

    You can also download the class & there are some sample files included... Has been very useful for me.

    Niklas

  5. #5
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    so what's the idea exactly? you put all your code in functions in Doc class and tell the FrameScriptManager which frame can access them? if that's the case, how do I reference different classes (not just individual functions) from a frame beyond frame 1? is there a way to make ALL your functions in ALL your classes accessible from frame 2 & beyond without manually doing it with "setFrameScript" or whatever?

  6. #6
    Senior Member
    Join Date
    Jul 2005
    Posts
    126

    Well...

    ...I'm kind of new to AS3 so I'm learning all this stuff myself as well so I might be totally of here but my guess is you do an import of your class into the documentClass and then you will have access to the functions everywhere. But the functions that you want to run from another class must be set to public...

    Niklas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center