Authentic voices. Remarkable stories. AOL On Originals showcase the passions that make the world a more interesting place.
Journey to the Draft is an organic, unscripted, docu-series that follows three college football players, all with promising professional careers. These young men attend different schools across the country and play a variety of positions on the field, but at the end of the day they share one goal:to play in the NFL. The AOL docu-series follows players Leonard Williams, Kevin White and Marcus Peters.
Connected features the personal stories of six New Yorkers woven together into one of the most intimate series ever. This groundbreaking show changes the nature of storytelling by giving each character a camera to document their lives. The result is a unique format revealing as different as everyone appears to be, we are all universally Connected.
Wake up to your world in 2 minutes.
Jews and Money. Asian Drivers. Polish IQ. CPT… that's racist! But where do these stereotypes come from? Comedian Mike Epps explores the backstories of this humor and how history and fact often distorts into a snide – but sometimes funny – shorthand.
"INSPIRED" features celebrities, visionaries and some of the biggest newsmakers of our generation, recounting the stories behind their biggest, life-changing moments of inspiration.
In a compelling series of verite encounters, Win Win provides unique access into the minds and lives of the world’s most-celebrated entrepreneurs and athletes.
Explore what it means to be human as we rush head first into the future through the eyes, creativity, and mind of Tiffany Shlain, acclaimed filmmaker and speaker, founder of The Webby Awards, mother, constant pusher of boundaries and one of Newsweek’s “women shaping the 21st Century.”
Nicole Richie brings her unfiltered sense of humor and unique perspective to life in a new series based on her irreverent twitter feed. The show follows the outspoken celebrity as she shares her perspective on style, parenting, relationships and her journey to adulthood.
Comedy is hard, but teaching comedy to children is hilariously difficult. Kevin Nealon is giving the challenge to some world-famous comedians. As these young minds meet with comedy’s best, get ready to learn some valuable comedy lessons, and to laugh!
James Franco loves movies. He loves watching them, acting in them, directing them, and even writing them. And now, he’s going to take some of his favorite movie scenes from the most famous films of all time, and re-imagine them in ways that only James can.
The story of punk rock singer Laura Jane Grace of Against Me! who came out as a woman in 2012, and other members of the trans community whose experiences are woefully underrepresented and misunderstood in the media.
Executive produced by Zoe Saldana (who will be the subject of one episode), a celebrity travels back to their hometown to pay tribute to the one person from their past (before they were famous) who helped change their life by giving them an over-the-top, heart-felt surprise.
Enter the graceful but competitive world of ballet through the eyes of executive producer, Sarah Jessica Parker. This behind-the-scenes docudrama reveals what it takes to perform on the ultimate stage, the New York City Ballet. Catch NYCB on stage at Lincoln Center.
Learn how to write object oriented drag and drop Actionscript 3 code in Adobe Flash. The video takes you through the entire ...
process from scratch, using a shopping trolley as an example. Covers external classes, event detection, drop target detection and much much more.
Tags:Drag and Drop in Flash Actionscript 3 Part 2/3,action script 3 code,action script 3 tutorial,adobe flash tutorial,drag and drop in flash,draga,flash actionscript 3 tutorial,flash actionscript lesson,programming tutorial
Grab video code:
Write an Object Oriented Drag and Drop in Flash Actionscript 3 Part 2/3
What we do is inside the down event handler, I am going to add another for the mouse up event. So this is the event handler that we’re interested in because that means that to user has release the mouse button again. They have let go of the white tshirt and we should stop dragging.
So what I do is I create another event handler for that called stageUp and define that here as another protected function called stageUp. And it also gets a single argument which is MouseEvent and it doesn’t return anything so that return type ends up as void.
Once to use hands released the mouse button, we don’t need to listen for the MouseEvent anymore. For the stageUp even anymore, so I can say stage.remove.EventListener, MouseEvent.MOUSE_UP, we’re not interested in that anymore. The mouse already been released. This is really nice to do that because it cleans up the memory and it releases those references from memory. So if you can always remove your EventListeners.
The second thing is we want to stop dragging, then we simply say stopDrag that’s the built in method and remember we are always inside the WhiteShirt class here so everything we do applies to the WhiteShirt itself. So this will stop dragging the WhiteShirt. Let’s publish that and see it in action.
I hover over the mouse. We get the hand cursor because it’s the button mode. I then press the mouse down and I can start dragging that white tshirt. Now if I release the mouse button it releases the tshirt again. Some really I can pick it again and drag it around to somewhere else. Nice!
Okay, this is a still a bit of work to do, so let’s have a look of how we can tell whether or not it’s been drop on top of the shopping trolley. Back in our code now, what do we do is we use a built in property called Drop Target that gets populated when you use the startDrag and stopDrag methods.
What I’m going to do in our stageUp function, I am simply going to trace dropTarget. So let’s have a look. So now, I’m going to drop it on top of the nowhere and the dropTarget is null. If I pick it up again and I’m going to drop it on top of the trolley, it actually has some service result here. It says, “Object Shape” which is a little bit difficult to decipher but we’ll figure that all in a sec.
Similarly if I drop it on top of the tshirt, we also get to trace and if I drop it again on empty space, we simply get null. So we can use this property to determine whether or not the tshirt has been dropped on something. The first thing we’re going to do is we’re going to go back into flash and we’re going to give our black tshirt an instance name, called “black.” Our white tshirt another instance name, called “white.” And our trolley another instance name called, “trolley” right? With this initial bit of preparation out of the way, we can go back into our code and finish off the drop attached.
The first thing to do is I’m going to create an IF statement that actually checks whether or not it was dropped on something. And we do that by simply saying if dropTarget. That means— if dropTarget is defined, if it’s not, No and that’s the case if the white shirt will drop on something so we say trace dropped on something. Always going to step by step with these things, so that you know where your errors are and else, otherwise – Well, otherwise dropTarget isn’t defined and that means that the white shirt wasn’t dropped on anything, dropped on nothing. Okay, let’s run this and see it in action.
So I pick up the white shirt and I dropped in on the empty space and we get the right trace, dropped on nothing. Let’s drop it on the black tshirt—dropped on something. Let’s dropped it on the trolley—drop on something again and again on white space dropped on nothing. So this if statement can deal with these different situations, that’s a good first step.
Now if it was dropped on something, we need check whether it was dropped on the trolley or not. Let’s have a quick at our trolley again. Here’s the movie clip. Inside it is a bitmap graphic of the trolley itself. The way the dropTarget logic works is that it will pick the lowest object in the chain. So in our case it’s actually going to return the bitmap graphic here. So the dropTarget is going to be this bitmap graphic but what do we want to compare it with is the trolley movie clip. So we will have to go up, one level to the paired. So what we do in our IF statement, we say if dropTarget.parent.name that’s instance name if that is equal to trolley, then that means that’s the white has landed on the trolley.
Remember if the dropTarget will be the bitmap inside, so going to the pair and it will go to the actual MovieClip and the name is instance name which we just assigned to be trolley. So now we can say trace dropped on the trolley and then finally, I’ll distribute to solve the trace taken here from before. If this is not the case, so we set else, we’ll it was dropped on the something but it wasn’t dropped on the trolley. Let’s run this now and whether we get the different cases.
So let’s drop it on nothing, drop on nothing. That’s great. Let’s drop it on the trolley actually. Drop on the trolley, fantastic! And let’s drop it on the tshirt. Drop on something but not on the trolley. So this is handling all of the cases correctly. Okay, and then as the final step, we implement those two different cases.
The first thing, I’m going to do is I’m return it to the initial position when the tshirt has been dropped anywhere except on the trolley. And I will do that by creating a new function. Protected function, returnToOriginalPosition and it’s this function that we’re going to call when it was dropped on nothing. So this trace statement here, dropped on nothing is replaced with returnToOriginalPosition. It’s not going to work here obviously because we haven’t written code. And similarly, if it was dropped on something but not on the trolley, we do the same thing. So this trace statement here, I’m going to replace with returnToOriginalPosition. Now, we actually have to implement that code. Nothing comes for free unfortunately so how do we do it?
The first thing is we have to record to the position when you pick it up. So actually we could record the position right at the very, very beginning because it’s already in the right position then. Let’s do that. So I create another variable, inside the class but outside the venue of the functions. Protected var originalPosition and define this as Point. The point class is a built in ActionScript Class and it will store an x and y value which is exactly what we need to keep track of the position and then inside the constructor function for the white shirt, we assign—we store the originalPosition, we say, originalPosition is a new Point and as you can see here by the code hind the Point class expects an x and a y coordinate in it’s constructor. So we simply store the x and the y of the white shirt itself. We’re using this new point class, so we have to actually import it into our class here. We have to tell flash where to find the Point class. Unfortunately, the flash doesn’t do that for us. So we go back our import statements outside of the class definition and we say, import flash.geom.Point, so it becomes part of the class definition.
Now what we storing the originalPosition in this variable down here in our new method returnToOriginalPosition, we can simply reset the x and the y values. So we go x = originalPosition.x and y = originalPosition.y and this has the effect of resetting the x and the y, resetting the position of the y chart so that it’s exactly where it started in the first place. Let’s run this and have a look to see whether it works.
So I pick up my white shirt, I drop it somewhere here and bang it snaps back to where it started. I drop it on the black tshirt and its snaps back. Fantastic! And I drop it somewhere over here in the empty space and its snaps back. But if I dropped it on the trolley, it stay where it is and I get the dropped on the trolley trace statement. So what do we do if we dropped it on the trolley? Of course we’d like to add it to some sort of shopping cart and some sort of list of items that we bought but that’s going a bit far for this particular video. We’re going to end up writing a whole online shopping application. So what I’m going to for now is to just to park it somewhere down in the corner.