18 Replies Latest reply on Jun 6, 2007 2:54 PM by _gary_

    tutorials on AS3 outside of Adobe?

    funonmars Level 1
      I'm struggling with the video code in AS 3, and none too happy with tutorials I've found on the Adobe site, unless maybe I've missed the right ones. Is there a resource I don't know about that can get me comfortable with AS3 quickly?
        • 1. Re: tutorials on AS3 outside of Adobe?
          kglad Adobe Community Professional & MVP
          i haven't found any.

          there are some helpful things that can be found using google. but there's even more articles that seem to pertain to flex 2 and are not applicable to flash 9 even though they are listed as tutorials for actionscript 3.
          • 2. Re: tutorials on AS3 outside of Adobe?
            funonmars Level 1
            Wow, how discouraging is that! I tech edited the CS3 for Dummies book and urged them to put out an AS3 for Dummies book, (because I'd learn along the way) but they said there wasn't a big enough market for it...!!

            I'm trying to follow Adobe sample code but they never mention the includes/classes which I'm guessing are often required, since they are only offering snippets. So the sample code just throws errors, and new user of program throws fits.
            • 3. Re: tutorials on AS3 outside of Adobe?
              kglad Adobe Community Professional & MVP
              oh, i'm just learning a.s. 3, too. so, i'm very aware of the limitations of the flash 9 help files and flash 9 compiler.

              but i actually think the flash 9 help files are superior to the flash 8 help files and there are some things i like about the flash 9 error checking but there are some things that clearly need to be fixed in an update.

              i think like anything new to learn it takes a certain investment of time before you start to easily add knowledge. at first, it's a slow-go.

              i've found it helpful to read most of the "programming actionscript 3.0" in the help files. and i've found the a.s.3.0 all classes part of the help files to be very helpful. but they were only helpful after i read the "programming as 3" section.

              i was hopeful i could just open the class definitions and i'd be ready to learn all the new features. but the language is so different from a.s. 2 that i wasn't getting anywhere until i went to the more basic "programming" section because you often have to understand the class hierarchy to use those class files to their best advantage. that's where the "programming as 3" has been very helpful.

              i've also found it very helpful to use the appendix: actionscript 2.0 migration. i'm very comfortable with a.s 2. i know, for example, that if i want to open another html page in a new window to use getURL (in a.s. 2.0). but i can't remember what to use for 3.0 (though it was in that "programming a.s. 3" section). so, i check the migration and it says to check navigateToURL which is all i need and i'm off and running.
              • 4. Re: tutorials on AS3 outside of Adobe?
                funonmars Level 1
                I really appreciated your response above. When I was first using beta CS3 I remember reading those programming files. Then my version was ended/time out. When I bought the new version yesterday I tried to go right to examples and got so frustrated. I'd forgotten about the programming files, which seem much more comprehensible and follow a step by step pattern I can comprehend.

                For me, the easiest way to learn code in the past has been through examples where I switch out names and values until I see how it's working... because I don't have a computer science background. So the lack of complete examples and foreign-ness of this code is maddening.

                There used to be a great variety of responsive forums devoted to Flash, but they are few and far between these days. Flash is such an amazing software, but increasingly difficult to get comfortable with for the beginner. I notice many of the questions on this forum are still about on(press) issues. On the other end of the spectrum the names who used to participate in forums now seem to only surface for general public at expensive Flash seminars around the world.

                kglad, you've helped me out numerous times on this forum and I really appreciate it. By your post count I see you've helped out MANY! Thanks!
                • 5. Re: tutorials on AS3 outside of Adobe?
                  Level 7
                  funonmars,

                  > There used to be a great variety of responsive forums devoted
                  > to Flash, but they are few and far between these days.

                  Do you really think so? My main haunts are these Adobe forums and the
                  ones at Community MX, and the traffic looks about as heavy as ever.

                  > Flash is such an amazing software, but increasingly difficult to
                  > get comfortable with for the beginner.

                  This is a good point, for sure.

                  > I notice many of the questions on this forum are still about
                  > on(press) issues.

                  I notice that too, and it worries me a bit. My hunch is that these
                  questions are due to the countless tutorials/blogs/articles out there that
                  are, at this point, several years old. FlashKit, for example, has numerous
                  Flash 4 sample files.

                  > On the other end of the spectrum the names who used to
                  > participate in forums now seem to only surface for general
                  > public at expensive Flash seminars around the world.

                  Gosh, you think so? Really? I imagine people do get "burned out" after
                  years of developing and educating on the same software. I can think of a
                  few "Hall of Fame"-ers, some of them friends, who aren't nearly as active as
                  they used to be. For them, it tends to be due to booms in personal
                  business. They're still using Flash, but have little spare time, even for a
                  jog in the park. I would imagine that seminars provide a way keep in touch
                  with the community, but at a manageable three- to four-day stretch, rather
                  than a daily commitment.

                  > kglad, you've helped me out numerous times on this forum
                  > and I really appreciate it.

                  kglad is fantastic, and has been for years. He's an inspiration, for
                  sure!

                  In addition to forum support from the likes of kglad, you can find AS3
                  tutorials -- specific to Flash, that is -- starting to appear at sites like
                  www.kirupa.com/ (free) and www.communitymx.com (subscription, free trial),
                  as well as a handful of books to be published within the next couple months.


                  David Stiller
                  Adobe Community Expert
                  Dev blog, http://www.quip.net/blog/
                  "Luck is the residue of good design."


                  • 6. Re: tutorials on AS3 outside of Adobe?
                    Rothrock Level 5
                    Where is Jeckyl?
                    • 7. Re: tutorials on AS3 outside of Adobe?
                      kglad Adobe Community Professional & MVP
                      i don't know where jeckyl is. i hope he's just so successful and making so much money he has no time for the forums.

                      • 8. Re: tutorials on AS3 outside of Adobe?
                        funonmars Level 1
                        Hi David, A forum that charges a subscription is a long disconnect from the old were-here days when folks like Keith Peters and Guy Watson, to name only two, freely posted and shared code while we were all exploring the possibilities of Flash. I mean I will probably sign up for it, but it's a different pov. But we all move along, apparently even Jeckyl... (who he?)

                        I'm plunging into As 3 and thanks to tips from kglad it's not as awful as it first appears, but it sure chews up and spits out As 2 code in a hurry. And I have yet to see any documents that explain how to use cue points set as navigation in video to actually get to the cue point.

                        You can get the time code as you set the cue point, convert it to seconds, and with the appropriate extra code introducing it, do this:

                        function stop1(event:MouseEvent):void
                        {
                        ns.pause();
                        ns.seek(27);
                        }

                        But I can't find any mention of how you use the cue point itself except through onCuePoint. I wanted to go to the cue from a button. just rambling. I think it's a wonderful program, and am very glad for this forum.
                        • 9. Re: tutorials on AS3 outside of Adobe?
                          Level 7
                          funonmars,

                          > Hi David, A forum that charges a subscription is a long
                          > disconnect from the old were-here days when folks like
                          > Keith Peters and Guy Watson, to name only two, freely
                          > posted and shared code while we were all exploring the
                          > possibilities of Flash.

                          Sure, I agree with that, which is why I also recommended kirupa.com. It
                          may just be that I don't know what-all forums are the popular ones nowadays.
                          I believe UltraShock.com is still going strong, Flashcoders is still going
                          strong (though the climate has changed, some would say). There's a
                          Flexcoders list now. For the true gurus, I would guess it's more about time
                          than anything else. Take Keith Peters, for example. He's now a recognized
                          author, with a second edition of ActionScript Animation: Making Things Move!
                          (great book, btw) and a contributing author, with Joey Lott and Darron
                          Schall, of the ActionScript 3.0 Cookbook. I've been learning, the hard (but
                          fun! but hard!) way that book writing takes incredible volumes of energy and
                          time. A friend of mine invited me to co-author Foundation Flash CS3 for
                          Designers, back in October
                          or November, and we're finally done -- been working till midnight or 2AM
                          since about mid-December. My own contributions to these forums took a
                          whopping plunge during that time, and it was entirely due to exhaustion.

                          > I mean I will probably sign up for it, but it's a different pov.
                          > But we all move along, apparently even Jeckyl... (who he?)

                          If you do sign up -- no pressure -- I hope you find it worth your while.
                          I'm not a "pushy salesman" type, so I don't push it. I do earn bit of extra
                          income from that site, but not a whole lot. The real reason I'm a partner
                          has more to do with camaraderie -- virtual officemates -- now that I work
                          from home. But I'm rambling. :-p In any case, I can empathize with your
                          sense of "What happened to the good old days?" I'd give it a bit more time,
                          though. Let's see what some of the forthcoming books have to offer. I'm
                          personally looking forward to Colin Moock's Essential ActionScript 3.0.

                          > I'm plunging into As 3 and thanks to tips from kglad it's
                          > not as awful as it first appears,

                          Good! :)

                          > And I have yet to see any documents that explain how to use cue
                          > points set as navigation in video to actually get to the cue point.

                          I'll help you if I can. How is your video making its way into Flash?
                          Are you using the FLVPlayback component or a NetStream instance?

                          > But I can't find any mention of how you use the cue point
                          > itself except through onCuePoint.

                          I'm seeing some possibilities with onMetaData; it apparently gives you
                          the whole list of cuepoints, through which you could loop and look for cue
                          points by name. Seems like the documentation leans more toward the
                          FLVPlayback component than a component-less situation, but I'm interested in
                          this too, now, so holler back if you still have questions.


                          David Stiller
                          Adobe Community Expert
                          Dev blog, http://www.quip.net/blog/
                          "Luck is the residue of good design."


                          • 10. Re: tutorials on AS3 outside of Adobe?
                            funonmars Level 1
                            Hi David, Thanks for your thoughtful reply. I would love it if you could clarify the seekToNavCuePoint, and whether it is possible to use it outside of a component.

                            The following code brings this error output, though the flv plays:
                            Error #1006: seekToNavCuePoint is not a function.
                            at candiltest2_fla::MainTimeline/stop1()

                            with this code:

                            import fl.video.*;

                            var nc:NetConnection = new NetConnection();
                            nc.connect(null);

                            var ns:NetStream = new NetStream(nc);
                            ns.client = this;
                            ns.play("candilicious_43.flv");

                            var vid:Video = new Video();
                            vid.attachNetStream(ns);
                            this.addChild(vid);



                            function stop1(event:MouseEvent):void
                            {
                            this.seekToNavCuePoint("squish")

                            }

                            play1.addEventListener(MouseEvent.CLICK, stop1);

                            and two navigation cue points embedded, "squish" and "fruit."
                            • 11. Re: tutorials on AS3 outside of Adobe?
                              funonmars Level 1
                              I know that the cue points are there because this bit of code traces them, and the pause also works when uncommented.

                              function onCuePoint(infoObject:Object):void
                              {
                              //ns.pause();
                              var key:String;
                              for (key in infoObject)
                              {
                              trace(key + ": " + infoObject[key]);
                              }
                              }
                              • 12. Re: tutorials on AS3 outside of Adobe?
                                Level 7
                                funonmars,

                                > Hi David, Thanks for your thoughtful reply.

                                Sure thing!

                                > I would love it if you could clarify the seekToNavCuePoint, and
                                > whether it is possible to use it outside of a component.

                                I'll do my best. :) I apologize, too, for the several days' delay in
                                my response. I had a hunch on how to answer your questions, but I wasn't
                                going to write anything until I had had the chance to test my code samples.
                                For better or worse, it has taken me until tonight to make the time to do
                                that.

                                On the question of seekToNavCuePoint() -- Is it possible to use this
                                method outside the context of the FLVPlayback Component? -- it looks like
                                the answer is no; that is, no in the sense of what you're looking for. The
                                method in question is a first-generation method (not inherited) of the
                                FLVPlayback class, which means an FLVPlayback instance is required in order
                                to use it. Technically speaking, it is not necessary to manually drag a
                                copy of the FLVPlayback Component to the Stage, so it could be argued that
                                only an *instance* is needed, not the Component itself -- but that's
                                academic hairsplitting: any instance of the Component on the Stage *is* a
                                programmatic instance as far as ActionScript is concerned. You could
                                certainly extend that class in a subclass of your own, which means you'd be
                                using a custom class instead of the Component, but there too, I'm describing
                                a shuffle game of "Under which shell hides the pea?"

                                I believe what you're looking for is a simple way to load video into a
                                NetStream instance (not the FLVPlayback Component) and use a cue point's
                                name to seek to a location in the video. So here's one approach.

                                Create a new ActionScript 3.0 FLA document and enter the following code
                                into frame 1:

                                var cp:Array;
                                var v:Video = new Video(320, 240);
                                addChild(v);

                                So far, you have an Array instance named cp (just an arbitrary name, but
                                to me it stands for "cue points") and a new Video object named v (this is
                                the same as creating a new Video asset in the Library). The v object is
                                added to the display list of the Stage -- without that third line, the video
                                would load and play, but never be seen.

                                Next, add the following:

                                var nc:NetConnection = new NetConnection();
                                nc.connect(null);
                                var ns:NetStream = new NetStream(nc);
                                v.attachNetStream(ns);

                                Where, you're wiring up the video. First, a NetConnection instance, nc,
                                is connected to a null object -- which means the FLV file will be delivered
                                via HTTP rather than a streaming service. Next, a NetStream instance, ns,
                                is associated with nc. Finally, the Video.attachNetStream() method is
                                invoked against the v instance and associated with ns.

                                The path to actually displaying video is a bit tedious, but still fairly
                                straightforward. Now we'll listen for the NetStream.onMetaData event. This
                                part is key, because it carries with it an array of cue points embedded into
                                the FLV file. How? By way of the video import mechansim of Flash itself.

                                In my test case, I imported an AVI file and used the Cue Points tab in
                                Step 3 of the import wizard to specify a series of cue points. The
                                interface of that tab allows me (and you) to specify a cue point's Name,
                                Time, and Type (on the left side of the dialog) and then a Parameters
                                property that contains a Name and Value (on the right side of the dialog).
                                The easiest way to go, in my estimation, is to specify the "name" you'd like
                                to use -- "squish" and "fruit" in your sample -- in the Name field of this
                                dialog. The time is determined by the scrubber above the tabs, and the Type
                                should technically be Navigation, which you can choose from a drop-down
                                menu. The Parameters area really isn't needed, though you may certainly use
                                it if you want to embed yet further metadata about each cue point.

                                So, back to our onMetaData event handler:

                                var listener:Object = new Object();
                                listener.onMetaData = function(md:Object):void {
                                for (var i:Number = 0; i < md.cuePoints.length; i++) {
                                trace("name: " + md.cuePoints .name);
                                trace("type: " + md.cuePoints
                                .type);
                                trace("time: " + md.cuePoints .time);
                                for (var prop:String in md.cuePoints
                                .parameters) {
                                trace(prop + "," + md.cuePoints .parameters[prop]);
                                }
                                cp = md.cuePoints;
                                };
                                ns.client = listener;

                                Okay, this may look like a lot, but it's not actually so bad. This is
                                one of the few (possible the only) times in AS3 that events are handled in
                                the manner in which they were in AS2. An arbitrarily named variable,
                                listener, is declared and set to an instance of the Object class. This
                                listener will act as a liaison on behalf of events dispatched by the
                                NetStream class.

                                An onMetaData property is added to listener (I found this under the
                                Events listing for NetStream) and associated with a function literal. This
                                event carries with it an Object instance of its own, which is passed into
                                the function as the variable md (meta data). This part gets a teensy bit
                                dicey, because the metadeta object, itself, is a property of the VideoPlayer
                                class, not Video. I honestly don't remember how or why I thought to look up
                                the VideoPlayer class. Maybe it was luck. Maybe I just searched the term
                                "metadata"; in any case, I found that a metadeta object -- at least, as it
                                appears in relation to VideoPlayer -- carries with it a cuePoints property.
                                This property can be unearthed by way of the onMetaData event, and in this
                                context will be a property of the md variable, which is our representation
                                of the VideoPlayer.metadata property.

                                So ... a relatively simple for() loop steps through the cuePoints
                                property of the md object, and as long as your FLV file has cue points
                                embedded, you'll seem them all traced out to the Output panel, including the
                                parameters property. These correspond directly with the import wizard tab
                                as described earlier.

                                After the for() loop, which is really just there for sake of
                                illustration, you're setting the previously declared cp (cue points) array
                                to the md.cuePoints property. Finally, the NetStream.client property is set
                                to listener, as invoked against the ns instance. This is akin to AS2's
                                addListener() method for wiring up listeners.

                                At this point, you may start up the video itself:

                                ns.play("myVideo.flv");

                                Now, at any time, you may use the NetStream.seek() method to jump to a
                                cue point in the video. You'll have to test of it's possible to seek to
                                areas that haven't yet loaded. My hunch is that no, you can't -- but in any
                                case, you can experiment with local files, at least.

                                In order to summon a cue point by name, rather than a number, you could
                                write a custom function like this:


                                function findCuePointTime(cuePointList:Array, cuePointName:String):Number {
                                var i:uint, len:uint = cuePointList.length;
                                for (i = 0; i < len; i++) {
                                trace(cuePointList
                                );
                                if (cuePointName == cuePointList .name) {
                                return cuePointList
                                .time;
                                }
                                }
                                return 0;
                                }

                                ... which would allow you to supply the cue points array (here, cp) and a
                                cue point name in order to get back its number. You could put that into the
                                seek() method itself, like this:

                                ns.seek(findCuePointTime(cp, "squish"));

                                Just make sure not to call the seek() method until after the onMetaData
                                event has been handled, otherwise the cp array won't be populated.


                                David Stiller
                                Adobe Community Expert
                                Dev blog, http://www.quip.net/blog/
                                "Luck is the residue of good design."


                                • 13. Re: tutorials on AS3 outside of Adobe?
                                  kglad Adobe Community Professional & MVP
                                  (just an aside related to the original thread: senocular.com has lots of useful as3 info.)
                                  • 14. Re: tutorials on AS3 outside of Adobe?
                                    funonmars Level 1
                                    Hi David, Thanks so much for your extended reply to my question. I get so discouraged about AS 3. While I'm in the midst of a project, I can stumble along, but as soon as I'm done, when I look at the forum for instance, it all looks impenetrable. And I'm a person who really likes code.

                                    I really appreciate the time and thought which went into your response, and I've looked it over numerous times-- and sighed. brain fog. Anyway, I'm saving it to explore next time I attempt to explore AS 3. The thing is, aside from regular expressions, I don't see much in it for me, an artist who likes interactive animation, and I see major learning hurdles along the way.

                                    I've been meaning to respond for awhile, but I've just been so down on what's been done to Flash, and do wonder who they think the software is meant for these days.

                                    Sally
                                    ps kglad I have been exploring senocular's site, read the whole long essay.
                                    • 15. Re: tutorials on AS3 outside of Adobe?
                                      kglad Adobe Community Professional & MVP
                                      don't give up. sometimes it takes 3 or more readings to grasp somethings. and reading different explanations helps more than reading the same thing 3 or more times.

                                      i read senocular's tutorial ( http://www.senocular.com/flash/tutorials/as3withflashcs3/) and his tips ( http://www.kirupa.com/forum/showthread.php?t=223798) and the flash help files (programming actionscript 3.0) and am just now starting to understand many things that escaped me on first and second reading.

                                      i also read every trevor mccauley (=senocular) post that i see in this forum.
                                      • 16. Re: tutorials on AS3 outside of Adobe?
                                        funonmars Level 1
                                        Hi kglad, thanks for the encouragement. I have gotten back into it. I find I can wade through specific examples and create something off of them, but have yet to find a tutorial on classes that makes me get the big picture. I think senocular used to post on were here back in the days.
                                        • 17. Re: tutorials on AS3 outside of Adobe?
                                          kglad Adobe Community Professional & MVP
                                          he still does. he's trevor mccauley on this forum.
                                          • 18. Re: tutorials on AS3 outside of Adobe?
                                            _gary_
                                            for some basic building blocks stuff
                                            lynda.com has a few video tutorials
                                            1. cs3 flash
                                            2. as3 https://movielibrary.lynda.com/html/modPage.asp?ID=423
                                            3. as3 in flex