Go Back   kirupaForum > Flash > ActionScript 3

Reply
 
Thread Tools Display Modes
Old 06-30-2006, 05:24 PM   #46
Chaoswarp
Master of Toxic Monkeys
thanks that makes more sense.

NEW Question, and maybe I am just all together spacing out on this one.. but uhm where are the Tween Classes?

I attempted to do import mx.effects.Tween... but that doesnt work, nor do i think it should. I hunted through all the class files, and those still all look flash 8.

Can ya gimme a hint as to how to get going tweening things with AS3? I know i could make my own timers and do it myself, but I am looking to find out what happened to the Tween Class.

Also where does flash store the class files i am importing. for example where is flash.display.MovieClip. Does that class file exist on my computer? or is it in the flash player? can i use mx classes? if so where are those located for AS 3?

Any help would be appriciated, i am pretty much looking for a simple example like.. there is a circle movieclip made with a class, function called bounceIt. and in the bounceIt function it creates a new tween and bounces the ball up and down.

Sorry if these are all retarded, just trying to get a head start

__________________

//Insert Signature Here
Kirupa.chaosWarp.signature = 1

Last edited by Chaoswarp; 06-30-2006 at 06:05 PM..
Chaoswarp is offline   Reply With Quote
Old 07-01-2006, 12:30 AM   #47
senocular
On Vacation
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,426
All classes that you import from the flash packages (packages that begin with flash.) are internal to the Flash player. These are the fundamentals by which everything you program is based on. Other classes are external; these include the classes in the mx packages. You can find all of the source files for the mx classes in Flash's installation directory (or Flex's frameworks directory). The tweening classes are a part of these classes and they still exist for ActionScript 9.
mx.effects.Tween;

__________________
senocular is offline   Reply With Quote
Old 07-01-2006, 01:10 AM   #48
senocular
On Vacation
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,426
Detecting When the Mouse Leaves the Movie

One thing about previous versions of ActionScript was that you could never tell when the user no longer had his or her mouse over the Flash movie. This made it hard for people to know whether or not the user is still interacting with their movie or if they've given up and moved on to something more interesting. This was especially a problem for custom cursors where, if the user moved the cursor off the Flash movie, the custom cursor would still remain in the Flash movie not moving while the real cursor could be seen moving around every where else.

ActionScript 3 now allows you to detect when the mouse has left the flash movie using the stage's mouseLeave event. This event happens whenever the mouse exits the Flash movie. There is no mouseEnter event, but you can use mouseMove for that since mouseMove only occurs in Flash (for the stage, or really any, object) when the mouse is within the bounds of the movie.

Here's a simple example that uses a square as a custom cursor:
Code:
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;
	
	public class Test extends Sprite {
		
		private var cursor:Sprite = new Sprite();
		
		public function Test() {
			cursor.graphics.beginFill(0xFF);
			cursor.graphics.drawRect(0, 0, 25, 25);
			addChild(cursor);
			
			stage.addEventListener(Event.MOUSE_LEAVE, cursorHide);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, cursorFollow);
			Mouse.hide();
		}
		
		public function cursorHide(evt:Event):void {
			cursor.visible = false;
		}
		
		public function cursorFollow(evt:MouseEvent):void {
			if (!cursor.visible) cursor.visible = true;
			cursor.x = stage.mouseX;
			cursor.y = stage.mouseY;
			evt.updateAfterEvent();
		}
	}
}
As your mouse leaves the movie, the cursor sprite is hidden. When the mouse is brought back in the movie, the mouseMove event fires and the cursor is made visible again.

__________________
senocular is offline   Reply With Quote
Old 07-01-2006, 12:22 PM   #49
Chaoswarp
Master of Toxic Monkeys
Hmmmm well if the tween classes still exist, and should work the same. what am I doin wrong?

I got a movieclip mc on the timeline, ofcourse.

Code:
import mx.effects.Tween
var t = new Tween(mc, "_rotation", Elastic.easeOut, 0,360, 3, true)
this gives me a compiler error
Quote:
ReferenceError: Error #1065: Variable Tween is not defined.
at Timeline0_63425fcc21fc6e4194dfe8880df15cd/::frame1()
So what is the proper way to get access to the Tween class?

__________________

//Insert Signature Here
Kirupa.chaosWarp.signature = 1
Chaoswarp is offline   Reply With Quote
Old 07-01-2006, 12:28 PM   #50
senocular
On Vacation
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,426
for 1, _rotation is now rotation, but more importantly it looks like the AS3 preview didn't come with updated AS3 mx classes. You'll have to live without them (or use Flex or the Flex SDK)

__________________
senocular is offline   Reply With Quote
Old 07-01-2006, 12:48 PM   #51
icio
looks better in lowercase
 
icio's Avatar
Location Edinburgh, Scotland

Posts 3,794
You also haven't included the package with `Elastic` in it.
I think that package is mx.transitions.easing.*

Not that it matters if the package wasn't included for AS3.
icio is offline   Reply With Quote
Old 07-01-2006, 04:34 PM   #52
TheCanadian
Noo doot aboot it, eh?
 
TheCanadian's Avatar
Location Take a guess . . .

Posts 7,084
Actually it's in mx.effects.easing

__________________
Proud Montanadian
We tolerate living and breathing.

Name Brand Watches
TheCanadian is offline   Reply With Quote
Old 07-01-2006, 05:23 PM   #53
Chaoswarp
Master of Toxic Monkeys
hehe yah knew about the other classes, figured it was pointless if i couldnt find this one.

thanks though, saves me some headache. Also is it just me, or does the code Check in flash IDE not work on AS 3 classes?

senocular - Can I get the updated Class files from the SDK or some from flex somewhere? like just copy them over my other ones? Or do i need to develop in flex until they release a new flash 9, if i wanna use those features?

thanks

__________________

//Insert Signature Here
Kirupa.chaosWarp.signature = 1
Chaoswarp is offline   Reply With Quote
Old 07-01-2006, 05:40 PM   #54
senocular
On Vacation
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,426
You should be able to use the classes from the Flex SDK. Just download them somewhere on your computer and specify the location of the folder with the mx directory in your Flash preferences class path.

__________________
senocular is offline   Reply With Quote
Old 07-02-2006, 09:54 AM   #55
senocular
On Vacation
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,426
SimpleButton Instances

ActionScript 3 now supports a new class called SimpleButton (flash.display.SimpleButton). This class lets you create button symbols in ActionScript - something previously not possible older versions of ActionScript.
Code:
var myButton:SimpleButton = new SimpleButton();
The SimpleButton class contains 4 properties that relate to the various states of a button; upState, overState, downState, and hitAreaState. Create display objects for these states and assign them to those properties to create a fully functional button symbol using ActionScript 3.
Code:
myButton.upState = mySprite1;
myButton.overState = mySprite2;
myButton.downState = mySprite3;
myButton.hitAreaState = mySprite4;

__________________
senocular is offline   Reply With Quote
Old 07-02-2006, 12:40 PM   #56
senocular
On Vacation
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,426
Quote:
Originally Posted by senocular
You should be able to use the classes from the Flex SDK. Just download them somewhere on your computer and specify the location of the folder with the mx directory in your Flash preferences class path.
It looks like there's a lot of underlying complications in the mx framework provided with Flex that prevent this from being possible. So it looks like to use the Tween class in AS3, you'll have to rewrite it yourself

__________________
senocular is offline   Reply With Quote
Old 07-03-2006, 01:43 PM   #57
Enemу
Registered User
Quote:
Originally Posted by senocular
Here's a simple example that uses a square as a custom cursor:
Code:
 
...
public function cursorFollow(evt:MouseEvent):void {
            if (!cursor.visible) cursor.visible = true;
            cursor.x = stage.mouseX;
            cursor.y = stage.mouseY;
            evt.updateAfterEvent();
        }
Pls, comment on evt.updateAfterEvent(); , I know what updateAfterEvent() function does, but placing evt object before it confuses me.

It instructs player to refresh stage after event completes, right?

Why don't just write

Code:
updateAfterEvent();
?

I'll be thankfull if someone will point me on docs describing updateAfterEvent();
Enemу is offline   Reply With Quote
Old 07-03-2006, 02:06 PM   #58
Krilnon
≈ ≠ =
 
Krilnon's Avatar
Location Rochester, NY

Posts 7,697
updateAfterEvent() is a method of the MouseEvent class, not a global function, so you need to call it from an instance of the MouseEvent class, in this case, 'evt'.

It is also a method of the KeyboardEvent and TimerEvent classes.

Here is the link to the documentation: http://livedocs.macromedia.com/labs/...teAfterEvent()
Krilnon is offline   Reply With Quote
Old 07-04-2006, 11:00 AM   #59
senocular
On Vacation
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,426
Commas in Shorthand Array Definitions

When defining arrays in ActionScript 3 using the shorthand array access operator (brackets), you can now have a trailing comma following the last element without causing an error (like in PHP). This makes working with multi-line array definitions a little less error-prone when rearranging elements. Ex:
Code:
var myList:Array = [
	"The",
	"quick",
	"brown",
	"fox",
];
In ActionScript 1 and 2, the comma after "fox" would create an error. This is not the case in ActionScript 3.

Note: this does not work with Array() or new Array(), only [].

__________________
senocular is offline   Reply With Quote
Old 07-04-2006, 11:14 AM   #60
senocular
On Vacation
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,426
Package Block

Packages in ActionScript 3 are defined a little differently than they are in ActionScript 2. In ActionScript 3, the package path is no longer part of the class definition. Instead, it is part of a new block which contains your class, the package block defined with the package keyword. That gives you the following basic structure for AS3 files:
Code:
package my.package.path {
	class MyClass {
	}
}
In AS2, it would look like the following:
Code:
// ActionScript 2:
class my.package.path.MyClass {
}
In fact, in AS3, all class files require a package block, even if they are not in a package.
Code:
package {
	class NotInAPackageClass {
	}
}
Each package block can define a class or a function that is associated with the file. The class or function within the block should be defined with the same name as the file (minus the .as extension).
Code:
package com.kirupa.utils {
	function StripString(str:String):void {
		// ...
	}
}
The above would be saved as StripString.as in a com/kirupa/utils folder.

__________________
senocular is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 7 (0 members and 7 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:56 PM.

SHARE:

SUPPORTERS:

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com