Screens. Where best to put actionScript

Ask a Question related to Macromedia Flash Actionscript, Design and Development.

  1. #1

    Default Screens. Where best to put actionScript

    Hello I'm having a play with screens both form and slide based and so far these
    are my concerns

    1. There is very little documentation around which actualy looks at best
    practices when building applications using forms. All the tutorials on the
    macromedia site seem to delve streight into data binding using 1 or 2
    components and don't really look at larger applications which may contain both
    interactivity and animation

    2. One of my main concerns is where to put actionscript when developing form
    based applications. For example macromedia reccomended not putting any large
    actionscripts on the time line and suggest using external scripts. Why is this?
    I've also noticed that developers using screens are attaching actionscript to
    buttons etc throughout their applications rather than compiling all their code
    on the first frame of the timeline. This seems to be a step backwards as I
    assumed good coding practice was to use call back functions etc on the 1st
    frame of the movie or movie clip which gives the code a central location

    3. I recently did a quick presentation using 35 slides each containing an
    image. On one of the slides I needed to rotate the image which i did using
    actionscript. However when I click on the image nothing happens for about 5
    seconds then the image rotates. The code for this is on the first frame of the
    timeline for that slide and uses an onEnterFrame function. Its not a big script
    about 5 lines and it works fine in a normal timeline flash file

    So I guess my question is how (or if) placing actionScript on the timeline of
    a screen affects the performance of a screens based application. Particularly
    when using loops and processor intensive onEnterFrame events for repetative code

    Any Ideas



    Spen Guest

  2. Similar Questions and Discussions

    1. navagating screens
      I'm trying to get a button in slide1 go to a certain frame(61) in a slide 8, HOW???? Thanks...
    2. Working with Screens
      Hello I'm doing a Web site using screens (Flash 2004 Pro) where each slide has a little animation which should play only when the screen is...
    3. Screens HELP
      I don't know what is wrong I have a few screens. On one of them I have a button to which I add a behavour to hide this same screen. It doesn't...
    4. Screens for a picture
      I work at a print shop and I was wondering if anybody has ever heard of screening a picture? It is were you lay dots over the screen and I understand...
    5. screens
      Cees wrote: Don't worry about it. In my experience the X Window System installed by Woody does that about half the time. That's one reason...
  3. #2

    Default Re: Screens. Where best to put actionScript

    The issue of best practices of where to put code is a thorny one and somewhat subjective.

    A major motivating factor in building the screens feature, was in response to those users
    for whom developing large applications using the timeline was cumbersome because doing so,
    as you know, often results in "spaghetti" code that is hard to follow and hard to
    maintain. Thus, we're generally recommending that folks put code in separate .as files
    associated with a screen subclass. This encapsulation is more object oriented and puts
    code in centralized locations, and seems to resonate more with folks who come from a more
    traditional programming background (e.g. C++ or VB).

    If you feel comfortable putting code on the timeline, or mixing screens and timeline
    coding styles, that's entirely up to you. It really depends on who you expect to be
    building and maintaining your code and what kind of app you're building.

    As for the performance issues. There's nothing I can think of that would cause the delay
    you're seeing. If you want to post it or a pared down example, I could take a look at it.
    However, an easier way to do what you want might be to use the built in Transition
    behavior for Rotate, attached to your slide triggered by an on(reveal) (or on(<whatever>)
    you want.

    --
    Ed Skwarecki
    Principal Architect
    eLearning
    Macromedia
    Ed Skwarecki Guest

  4. #3

    Default Re: Screens. Where best to put actionScript

    Thanks for your time Ed

    It's good to be pointed in the right direction, especially when your about to
    completly change the way you approach Flash application development

    With regard to the performance issues. I've uploaded the presentation I did to
    the URL below

    [url]http://www.smashingmedia.com/whatisdesig[/url]

    On the 7th screen you are prompted to click on the image and rotate it. I
    realize that this task could be acheived more easily using screen behaviours
    however for future reference it would be handy to know if placing an
    onEnterFrame event on the timeline of a screen causes performance problems in
    large applications

    Justi

    Spen Guest

  5. #4

    Default Re: Screens. Where best to put actionScript

    I took a look at your sample. I saw that slide 7 has a noticeable lag before the rotation
    begins. I tried recreating the same thing from scratch and my version starts immediately,
    using onEnterFrame() to do the rotation. So I'm not sure why your example is showing the
    delay, but it is not onEnterFrame in and of itself. Something else is interacting with
    that to cause the delay. But without having the source .fla, it's hard to say what the
    problem is.

    --
    Ed Skwarecki
    Principal Architect
    eLearning
    Macromedia
    Ed Skwarecki Guest

  6. #5

    Default Re: Screens. Where best to put actionScript

    I've done some more tests and it seems when the application gets too big it
    becomes unresponsive. I've done a cut down version of the presentation (URL
    shown below) which only uses 1 screen. The onEnterFrame works fine. As soon as
    I add more screens with large images on them it slows down. Other than screen
    behaviours for the transitions there is no other script in the original
    presentation. I've attached the original source code for the cut down fla
    showing the onEnterFrame code. The original presentation has 34 screens each
    containing 1 image

    cut down presentation: [url]http://www.smashingmedia.com/whatisdesign/wid.htm[/url]

    original presentation: [url]http://www.smashingmedia.com/whatisdesign[/url]

    Justi

    Spen Guest

  7. #6

    Default Re: Screens. Where best to put actionScript

    I'm sort of stumped. When I try to recreate a movie with 35 large images, and use the
    onEnterFrame() to rotate the image as you are doing, I don't see a delay.

    Is it possible your preloader is somehow getting in the way? If you remove just the
    preloader do you still see this latency?

    Is it possible that some of your other slides have non-empty timelines? Remember, unless
    the playHidden flag of a screen is set to false, all the slides will play at the same time
    even if the slide is not showing.

    --
    Ed Skwarecki
    Principal Architect
    eLearning
    Macromedia
    Ed Skwarecki Guest

  8. #7

    Default Re: Screens. Where best to put actionScript

    It's not the preloader as this is contained in a seperate swf which loads the
    presentation using attachMovie and removeMovieClip when the load is complete.
    In any case I have the same problem when I test only the presentation movie in
    flash.

    The playHidden flag was set to true. However setting this to false on all the
    screens had no effect. I also copeid and pasted all the screens into a new
    document incase the file was damaged. This also had no effect.

    I've uploaded the original presentation fla (13MB). If your interested, have a
    look.

    203.30.72.46/justin


    Thanks for all your help on this. It's not that important that I fix this
    problem as I've already done my presentation. I'm just curious to see if there
    is a problem or if I'm doing something wrong so I can avoid it in future. I'd
    really like to get my head around developing with screens however there is
    little documentation which covers screens in detail. For example I recently
    bought "Flash MX 2004 actionscript / training from the source". Its a very good
    book however not a single mention of screens.

    Justin

    Spen Guest

  9. #8

    Default Re: Screens. Where best to put actionScript

    I took a look at the file. The lag is in the processing of the onRelease, not the
    onEnterFrame. I have a pretty fast machine and there is a small but noticeable delay in
    the response to the click when the other slides are present.

    I suspect this has to do with how the player is doing mouse hit detection. I suspect it
    has to sift through and "ignore" all the other slides which are there but invisible. I
    don't have a good workaround for you. I'll keep poking around and let you know if I come
    up with a better answer.

    --
    Ed Skwarecki
    Principal Architect
    eLearning
    Macromedia
    Ed Skwarecki Guest

  10. #9

    Default Re: Screens. Where best to put actionScript

    Thanks again for your time.

    Can you recommend any books or tutorials which cover screens in detail?

    Justin
    Spen Guest

  11. #10

    Default Re: Screens. Where best to put actionScript

    For screens tutorials, etc, check out the Macromedia Dev Net section on screens:

    [url]http://www.macromedia.com/devnet/mx/flash/screens.html[/url]




    --
    Ed Skwarecki
    Principal Architect
    eLearning
    Macromedia
    Ed Skwarecki Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139