PhotoDune

The Switch

1954 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Netherlands
  • Referred between 10 and 49 users
  • Sold between 5 000 and 10 000 dollars
Emroni says

After saying “ill be doing it soon” for about a year, Ive finally started to learn AS3 ! Must say Im very pleased with the way it works, how it made things more clear and easier to code. And man oh man does it run smooth :D

What I wanted to ask though, how did you guys make the switch from AS2 to AS3 ? As in, did you read books, just gave it a shot with the help files, did tutorials (and where), etc. I for one am the kind of person that reads small bits here and there, and then tries to replicate things Ive seen on the net. Now Im curious about how others have done it :)

Another question I have is related to the previously known onEnterFrame function in AS2 . Ive been using that for scrolling stuff, as for example in this item: Advanced XML Image Gallery by DS. As you can see, at the bottom, there are these thumbs that scroll left and right when hovering over. I know how to do it with Event.ENTER_FRAME, but would like to know a more efficient way of doing this. My code right now is as follows:

function navScroll(e:Event) {
        nav.ratio = nav.bg.mouseX / nav.bg.width;
        nav.items= -nav.ratio * (nav.items.width - nav.bg.width);
    }
}
nav.addEventListener(Event.ENTER_FRAME,navScroll);

Anyone know of a better way of doing this? Ive tried to do MouseEvent.MOUSE_MOVE plus tweening engine, but that didnt seem to work any smoother. Would like to improve this bit, if possible :)

Since Ive started to go to the more advanced stuff in AS3 and dont want to use AS2 anymore, I can say this now: AS3 .0 rocks! :D

260 posts
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
  • United Kingdom
ravenwill says

Hi Emroni,

Try doing it on an enter frame event like you have done but using a tween engine. Normally gives a smooth result. :)

4132 posts
  • Bought between 1 and 9 items
  • Brazil
  • Community Superstar
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
tsafi says

Welcome to the club its about time, but don’t forget AS2 there is still lots of use .

Many that start AS3 they start trash AS2 :so don’t forget it (:, but feel free to trash Msfx in any given time it’s a mandatory must :p

///From the top of my head 
private var _mouseX :Number;
private var ThumArr :MovieClip = new MovieClip();//or mc
private var speed     :Number=0.01;
private var Tw          :Number;
private var Th           :Number;
 ThumArr.addEventListener(Event.ENTER_FRAME, ScrollThumb, false, 0, true);
private function ScrollThumb(e:Event):void {   learn class private public
_mouseX= (hitTestPoint.mouseX - stage.stageWidth / 2) * speed ;//or use /60 speed
 if (ThumArr.width > stage.stageWidth){
 ThumArr.x = ThumArr.x + _mouseX * -1;
}
if (ThumArr.x > _PointScroll.x + Tw/2+groupspace){//point scroll is mc target 
ThumArr.x = _PointScroll.x +Tw/2+groupspace;////groupspace in a number
}
if (ThumArr.x < -(scrollerWidth + ThumArr.width - stage.stageWidth)){
ThumArr.x = -(scrollerWidth + ThumArr.width - stage.stageWidth);
                }
}            

Many like to use Tween instead of ENTER _FRAME since when you remove the ENTER _FRAME you want to ease it, so you need to add any way ease function
7466 posts
  • Attended a Community Meetup
  • Community Moderator
  • Has been a member for 5-6 years
  • United Kingdom
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Contributed a Blog Post
  • Beta Tester
  • Bought between 50 and 99 items
+4 more
MSFX moderator says
but don’t forget AS2 there is still lots of use .

hahahahah, you’re very funny :D

Try doing it on an enter frame event like you have done but using a tween engine. Normally gives a smooth result. :)

Sorry but I really dont get people who use Tween engines for scrollers rather than an ENTER _FRAME…

Tweening Engines already use an Enterframe!

Why have another EF? You’re just wasting resources! So many authors do that here :(
You’ll get far more optimised performance using your own easing functions…

If you’re after an easing effect such as that within the file by DS then you’ll have to use an EF as
MOUSE _MOVE will only update when the mouse moves, as soon as you stop the mouse the transition will stop… if you have no easing or set it to 1 then you can get away with using MOUSE _MOVE… :)

Glad to see you’ve made the switch and seeing the sunny side of it :)

Just keep trying to recreate stuff that you did in AS2 and get reading all the blogs if you dont already :)

1954 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Netherlands
  • Referred between 10 and 49 users
  • Sold between 5 000 and 10 000 dollars
Emroni says

Im not forgetting AS2 at all! Im using the things I know from it in AS3 . Ill take a look at your example soon tsafi, thanks :)

And Matt, I left out the easing function in the code I wrote above, already have a way to make it ease :) I didnt want to use a tweening engine cause indeed, it already uses an EF. I didnt want to share the full code I wrote just yet, wanted to see what others have first. Cause if I do, ill be giving away info that others should buy on the marketplace (like scrollers or image viewers), guess youll understand that ;)

Im currently working on perfecting templates, with xml nav, modular pages, swfadress, etc etc. After that, when Im convinced I know enough, Ill get my hands dirty with some PV3D :D Cant wait!

7466 posts
  • Attended a Community Meetup
  • Community Moderator
  • Has been a member for 5-6 years
  • United Kingdom
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Contributed a Blog Post
  • Beta Tester
  • Bought between 50 and 99 items
+4 more
MSFX moderator says

You should also set the livedocs as your homepage and make sure you have a decent code editor ... :)

Are you using OOP or Document or Timeline?

146 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
  • Sweden
nicolasdelfino says

the switch….

the switch, just reading about gives me stomach ache….

I´ve been avoiding the switch for so long, I really hate the switch, wish I could hit it and humiliate it in public :)

no seriously I´m happy for you and hope I´ll be joining the rest of you soon! the hardest part for me I think is finding the amount of time needed to switch properly…

Btw. To prevent insanity I´m taking the easy way out working through the lynda.com AS series – really good and well made imo, a reliable and free alternative is flash evangelist lee brimelow´s blog at www.theflashblog.com, he has alot of tutorials at www.gotoandlearn.com, im sure you already heard of him but I believe he´s one of those people in the flash community you can never mention too often.

switching out /n

1628 posts fueledweb.com
  • Envato Staff
  • Reviewer
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
+4 more
RimmonTrieu staff says

it’s not really that hard at all actually I remember I didn’t have any difficulty. You should have some basic understand of OOP , event model, display list and some AS3 syntax then you can code AS3 on the fly ;)

Here’s a useful document:

AS3 migration cook book

happy coding 8)

146 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
  • Sweden
nicolasdelfino says

that book looks really helpfull, thanks rimV!

5041 posts The Dude Abides
  • United States
  • Elite Author
  • Has been a member for 4-5 years
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Contributed a Tutorial to a Tuts+ Site
  • Author had a Free File of the Month
+4 more
CodingJack says

I was building a website for a magician and wanted to use PV3D . And since all the PV3D help on the web seemed to be AS3 , I took the challenge of building a site with virtually no AS3 knowledge.

It took forever. Every time I wanted to do something, I researched on the web how it could be done. From that point on all my new sites were AS3 (which probably wasn’t a great idea because I didn’t understand GC for a while :D )

I’m still learning something new just about every day which is why I think it’s good to make the switch because there really is a lot to learn.

Good luck Emre. Looking forward to seeing your PV3D stuff :)

by
by
by
by
by