[Any] Custom Easing Class, What Am I Doing Wrong?
This is actually AS3 code but the question is more in my implementation, i doubt its a AS3 issue. But if you run the code and get different results, i'll know its the difference in the code.
Note that these are the rpenner easing equations.
Here is 20 lines of code, 10 running in sequence for both a linear ease, and a cubic ease. The reason i did this as aposed to a loop is just for sheer simplicity, i understand it would be easier to read & write a loop, but the problem was so odd i wanted to eliminate ANY possible problems i could think of.
Code: trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(0, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(1, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(2, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(3, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(4, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(5, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(6, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(7, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(8, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(9, 0, 100, 10) ); trace( "Cubic: "+ Tweening.EaseFuncs.CubicEase.easeIn(10, 0, 100, 10) );
trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(0, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(1, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(2, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(3, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(4, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(5, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(6, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(7, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(8, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(9, 0, 100, 10) ); trace( "Linear: "+ Tweening.EaseFuncs.LinearEase.easeIn(10, 0, 100, 10) ); And the output is as follows:
Code: Cubic: 0 Cubic: 0 Cubic: 0 Cubic: 0 Cubic: 0 Cubic: 0 Cubic: 0 Cubic: 0 Cubic: 0 Cubic: 0 Cubic: 100 Linear: 0 Linear: 10 Linear: 20 Linear: 30 Linear: 40 Linear: 50 Linear: 60 Linear: 70 Linear: 80 Linear: 90 Linear: 100 Now notice how the linear works, it splits it up into even chunks. However the cubic equation is acting very weird. It is not doing a thing until the last line of code? Now this does fit the cubic equation.. partially. It should be acting more and more as time follow, for a gentle slope. However this is acting instantly, on the end.
Now you might say, well its only 10 lines, the function must look more defined on higher number of equations, and that was my thought too. So i ran a simple 1000 line loop:
Code: for( var i:int = 0; i <= 1000; i++ ){ trace( "Cubic Loop #"+i+": "+ Tweening.EaseFuncs.CubicEase.easeIn(i, 0, 100, 1000) ); } Output (last 6 lines):
Code: Cubic Loop #995: 0 Cubic Loop #996: 0 Cubic Loop #997: 0 Cubic Loop #998: 0 Cubic Loop #999: 0 Cubic Loop #1000: 100
Any ideas? I'm stumped.
It would help of you tried the code too and see if you got it to work. These are just the standard Robert Penner equations (with slight data typing modifications for AS3 converting), so it should work the same everywhere..
FlashKit > Flash Help > Flash ActionScript
Posted on: 10-09-2006, 04:04 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[F8] Problem With Using A Custom Class Inside A Custom Class
I'm getting this error:
Line 19: A function call on a non-function was attempted.
var a:Meter = new Meter(32,34,0x0000ff,0,0);
when I am trying to call a custom class (Meter) inside of another custom class, which I initialize in the main timeline. I can do this exact same line I copied above in the main timeline and it will work just fine, but not if it is used in the constructor of another custom class as I am trying to do. Any ideas on why this isn't working? Only thing I can come up with is that the class isn't imported at the time of the second class calling it but I've tried fixing that already.
Custom Easing In F8
Hi.
I might be missing something here, but is there any way to save your custom easing settings in Flash 8.
I'm using a custom ease for a menu and want to duplicate the effect on all sections.
Any ideas??
Marv.
Custom Easing
hey i was wondering if theres any free custom easing tools to download out there cos well i want to get a really smooth effect, but yeah i dont know the number of frames to use etc can anyone help me?
Easing Trouble Whats Wrong ?
hi all...
i dont understand why the easing effect doesnt work on my movieclip_mc ? I see so much fantastic effects we can do but tutorials are not really clear about easing : too much theory and not so much practical demos
I m sure something like a basis position and an end position are missing?... if u can help it would be wonderful... thanx all
A.M.
Quote:
movieclip_mc.onEnterFrame = function(){
Ease.bounce = function (t, b, r, m, e) { // t, b for number of bounces, r for reduction of bounce (between 0-1), m for ease method, e for ease type
if (!b) b = 1;
if (!r) r = 0;
if (!m) m = Ease.exponential;
if (!e) e = Ease.inUsing;
var es = b*2 + 1; // number of eases
b = Math.floor(t*es); // which bounce
var et = t*es - b; // ease t
var rt = 1-Math.pow(1-t, 2);
var rf = 1 - r*rt;
return ((b + 1)%2) ? r*rt + e(m, et)*rf : r*rt + e(m, 1 - et)*rf;
}
};
Custom Easing Tools
Hi all.
Does anyone know where I can download these for flash? All the websites I found for these no longer exist.
A Custom Easing Equation
Does anyone know of the formula to get an EaseInOut movement?
I need to control the movement 'manually' onEnterFrame, I'm avoiding using any tween classes (both in-built and custom ones like zigo).
for example if I want an EaseOut movement, I just divide the distance between currentValue and targetValue.
e.g.
HTML Code:
xs= (_x-xTarget)/10
_x+=xs
how do i go about creating an easeInOut?
Custom Easing On Some Objects
Hi,
If you look at www.ostari.com/ronnie/portfolio/ and attempt to resize the window, you can see the music tab at the top right and the poles on the bottom right both move as you resize the window. Now I have the movie clip tweening extension from http://laco.wz.cz/tween/ installed. The following code I use to keep the elements movie like that is as follows:
ActionScript Code:
onResize();
function onResize() {
pole._x = originalWidth + (Stage.width - originalWidth) - pole._width;
pole._y = originalHeight + (Stage.height - originalHeight) - pole._height;
mPlayer._x = originalWidth + (Stage.width - originalWidth) - mPlayer._width;
navbar._x = originalWidth + (Stage.width - originalWidth) - navbar._width;
contentbg.contentbg1._xscale = Stage.width;
contentbg.contentbg2._xscale = Stage.width;
contentbg._y = Stage.height / 2;
};
Now I want to include some of those easing tweens on the pole MC and the mPlayer MC, but I have no idea how to add those in. So far to incorporate the http://laco.wz.cz/tween/ AS file, I added:
#include "lmc_tween.as"
to the top of the AS, but thats the extent I know of working with extensions.
I know this a somewhat popular extension, so could somebody maybe give me an example with one of the tweens built into what I have already. If thats not possible, any other help would be great.
-Ronnie
Custom Scrollbar With Easing
can someone point me in the direction of a good tute or info on creating a scroller mc with easing? The scrollbar type NOT the up and down buttons that require a mouseclick.
I want to be able to scroll mc's based on the vertical or horiz. position of a custom scrollbar made in photoshop.
not interested in skinning pre-built flash components quite yet...
I'm interested in figuring out how to set up the scrolling function based on the height of my content and all that good stuff...
i've been trying to dissect several posted .fla's but can't quite figure out how to get the code working with my specific graphics/objects...
any pointing in the right direction is appreciated!
Custom Easing Tool Help
Hi,
i´m trying to use the custom easing tool using the code generated by it but it´s not working.
Could someone please point some tutorials or write me some importants points I may be missing?
thanks
Custom Easing On Some Objects
Hi,
If you look at www.ostari.com/ronnie/portfolio/ and attempt to resize the window, you can see the music tab at the top right and the poles on the bottom right both move as you resize the window. Now I have the movie clip tweening extension from http://laco.wz.cz/tween/ installed. The following code I use to keep the elements movie like that is as follows:
ActionScript Code:
onResize();function onResize() { pole._x = originalWidth + (Stage.width - originalWidth) - pole._width; pole._y = originalHeight + (Stage.height - originalHeight) - pole._height; mPlayer._x = originalWidth + (Stage.width - originalWidth) - mPlayer._width; navbar._x = originalWidth + (Stage.width - originalWidth) - navbar._width; contentbg.contentbg1._xscale = Stage.width; contentbg.contentbg2._xscale = Stage.width; contentbg._y = Stage.height / 2;};
Now I want to include some of those easing tweens on the pole MC and the mPlayer MC, but I have no idea how to add those in. So far to incorporate the http://laco.wz.cz/tween/ AS file, I added:
#include "lmc_tween.as"
to the top of the AS, but thats the extent I know of working with extensions.
I know this a somewhat popular extension, so could somebody maybe give me an example with one of the tweens built into what I have already. If thats not possible, any other help would be great.
-Ronnie
Custom Easing Tool Help
Hi,
i´m trying to use the custom easing tool using the code generated by it but it´s not working.
Could someone please point some tutorials or write me some importants points I may be missing?
thanks
Custom Easing Tool
Hello,
I've got an issue and thought maybe this would be the place to get help!
I am trying to download the free extension tool "Custom Easing Tool" for Flash MX from this site www.laco.wz.cz/tween/ However when I try downlaoding Version 1.2.0 (MX 2004 Transitions) it reads as an unknown file type.....? I followed the directions from the gotoandlearn.com site under the Custom Easing tool tutorial. I do have the Extension Manager 1.6 for Flash MX but no luck.
Could anyone please let me know what I'm missing here. Your help would be invaluable.
Regards,
Farouq
Custom Easing Tool
hi everybody
i went through the tutorial Custom easing tool- great one!!!!
but what to do if i work in Flash8, there is an extension manager for FLash 8-version 1.7, but when i try to install it, it gives me an error, besides there is no extension for Flash 8 on http://laco.wz.cz/tween/, only for Flash MX
whats the solution to this, does someone solve this????
tnx
Custom Easing Tutorial
The tutorial that Lee did, does this plugin work with Flash 8? I know flash 8 does come with its own curve editor but this plugin looks really easy to use.
Also does anyone know any where else I can download the extension? I can't see to get it from laco.wz.cz the download starts but then fails before cmpletion.
Thanks
Ricky55
What's Wrong? - Center Full Flash With Easing
hi guys, just wondering what is wrong with these code:
ActionScript Code:
import flash.display.BitmapData;
cover.onEnterFrame = coverPosition();
function coverPosition(x,y){
ratio = .45
cover_y = Stage.height / 2
o_y_pos = cover_y;
cover._y = y_pos;
y_pos = y_pos-(n_y_pos*ratio);
n_y_pos = y_pos-o_y_pos;
cover_x = Stage.width / 2
o_x_pos = cover_x;
cover._x = x_pos;
x_pos = x_pos-(n_x_pos*ratio);
n_x_pos = x_pos-o_x_pos;
}
var tile:BitmapData = BitmapData.loadBitmap ("tile");
function fillBG(){
this.beginBitmapFill(tile);
this.moveTo(0,0);
this.lineTo(Stage.width,0);
this.lineTo(Stage.width,Stage.height);
this.lineTo(0,Stage.height);
this.lineTo(0,0);
this.endFill();
}
fillBG();
var stageL:Object = new Object();
stageL.onResize = function(){
fillBG();
cover.onEnterFrame = coverPosition();
coverPosition();
}
Stage.addListener(stageL);
Custom Easing Function Woes
here is my code:
tween = function (object, origin, destination, speed) {
object.onEnterFrame = function() {
object._x += (destination-origin)/speed;
if (object._x>=destination) {
delete object.onEnterFrame;
}
};
};
//
testbutton.onRelease = function() {
tween(ball, 100, 500, 10);
};
my problem is that i get a motion, but i don't get a tween. i don't know if it's something as simple as moving a line of code to a different spot or if it might be something more complicated. i also tried it this way:
getTweenValue = function (origin, destination, speed) {
difference = destination-origin;
return difference/speed;
};
//
tween = function (object, origin, destination, speed) {
object.onEnterFrame = function() {
object._x += getTweenValue(origin, destination, speed);
if (object._x>=destination) {
delete this.onEnterFrame;
}
};
};
//
testbutton.onRelease = function() {
tween(ball, 100, 500, 10);
};
and still no luck. Any help would be appreciated. i would also like to know how i can adapt it to tween any property, if i can ever actually get it to tween .
Custom Easing Elastic Motion?
Hi, just a quick question, is there a way to create an elastic movement using the custom easing tool in Flash 8. When I click 'edit' I get the graph which lets me play with the easing, but I can't move the curve beyond 100% which I need to do to simulate elastic motion. Is there a way round this or is it just back to adding keyframes?
This Is Driving Me Nuts -- Custom Easing
Well, I was using flash on someone else's machine, and I created a custom motion tween ease between two keyframes, and when I added a new keyframe halfway in between the keyframes it automatically adjusted the easing on both tweens so that the motion of the object remained the same.
My home computer does NOT do this automatic adjustment for me, and it's driving me nuts. I can't figure out how to enable it.
If anyone out there knows what this option is called or how to turn it on, I would really appreciate it.
Thanks!
Migrating Custom AS 2 Easing Formula To AS 3
hey all,
i've got an AS 2 easing formula that targets a clip above it. but i can't figure out how to make it work in AS 3. flash says that _parent doesn't work anymore? is this script capable of being re-written for AS 3 or do i have to start from scratch?
thanks for your help!
var baseRate:Number = 3.5
var difference:Number = _parent.targetx - _parent.panel._x;
var rate:Number = difference / baseRate
_parent.panel._x += rate;
Making A Custom Scrollbar With Easing?
hey was just wondering if anyone could give me a kickstart with any tutorials or anything? i was hoping to make one like the flashloaded one etc..
aiming to make it work with dynamic text though
Custom Easing Tool By Laco
I am using this tool but I don't completely understand.
I am trying to move a mc to a position and after that move it to a second position after a few seconds. The first works:
my_mc.tween("_x",400,1,"easeOutElastic");
But then? Something like onTweenEnd or something?
Can someone please help me with this?
TIA
Custom Easing Tool For MX 2004
I thought it might be helpful to post this tutorial for the custom easing tool for MX 2004
tutorial is here
link for tween instructions
Calling SetTimeout Within Custom Class And Cannot Access The Class' Variables
Hi All,
I'm creating an user interface with Flash 8, I'm new to Flash, my background is Java therefore I decided to use ActionScript to create a custom component that is reference within an external file.
My problem I believe is scope related. I have a status bar (label component), once I update the status bar I want to call the
"setTimeout" function to wait a couple of seconds before clearing my status bar. The "setTimeout" function is executing, but for some reason my status bar is not being cleared (accessed).
Below is a snippet of my code. Any help appreciated. Thanks.
/*
External File
*/
import mx.controls.Button;
import mx.controls.Label;
class MyApp
{
//private properties
private var mc_container:MovieClip;
private var btn:Button;
private var lbl_status:Label;
private var str:String = "do see me";
//constructor
public function MyApp(target:MovieClip)
{
trace("-- MyApp --");
mc_container = target.createEmptyMovieClip("mc_container", 100);
}
//public methods
public function init(width:Number, height: Number, xPos:Number, yPos:Number):Void
{
var my_app:MyApp = this;
btn = mc_container.createClassObject(Button, "btn", 1, {label:"click me"});
btn.setSize(100, 25);
btn.move(10, 10);
btn.clickHandler = function():Void
{
trace("btn clicked");
setTimeout(my_app.clearStatus, 2400);
//correct if I call directly
//my_app.clearStatus();
trace(str);
}
lbl_status = mc_container.createClassObject(Label, "lbl_status", 2, {text:"status bar message"});
lbl_status.setSize(200, 25);
lbl_status.move(0, 50);
}
public function clearStatus():Void
{
trace("calling clearStatus");
lbl_status.text = "";
}
}
/*
Called for Flash IDE
*/
var app:MyApp = new MyApp(this);
app.init(200, 200, 0, 0);
[AS3] Making An Auto-generated Class Inherit From Custom Class?
hi, just wondering if this is possible
i was hoping to find a way to get a bunch of objects in my library to inherit from (or even be) one class that i have made, but without having to make .as files for every single one
is this possible, or is there any other way to give objects another classes functionality in an auto-generated class?
cheers
Timeing Custom Easing Tool By Laco
how can I make one of these tweens go off at a certian frame ? so I can run one after the other and such?? instead of slowing it down with the time it takes to run the tween,
[Flash 8] Custom Easing Tool 1.1 Question
Hi all,
i wanted to use the tool for tweening an mc. But i get a error message probably because i use filters (it works without). I can't generate the keframes for this movieclip but the code.
Code:
customEasing = {};
customEasing.pts = [{Mx:0,My:0,Nx:18,Ny:-236,Px:2,Py:-19},{Mx:20,My:-255,Nx:16,Ny:-96,Px:2,Py:119},{Mx:38,My:-232,Nx:30,Ny:186,Px:3,Py:-148},{Mx:71,My:-194,Nx:22,Ny:-46,Px:8,Py:37},{Mx:101,My:-203,Nx:30,Ny:24,Px:1,Py:-21},{Mx:132,My:-200,Nx:28,Ny:-6,Px:4,Py:6},{Mx:164,My:-200,Nx:40,Ny:2,Px:-4,Py:-2},{Mx:200, My:-200}];
customEasing.ease = function(t,b,c,d,pl){
var i,r;
r = 200 * t/d;
for(i = 0;r>pl[i+1].Mx;i++){
}
i=pl[i];
if(i.Px != 0){
r=(-i.Nx+Math.sqrt(i.Nx*i.Nx-4*i.Px*(i.Mx-r)))/(2*i.Px);
}else{
r=-(i.Mx-r)/i.Nx;
}
return b-c*((i.My+i.Ny*r+i.Py*r*r)/200);
}
but where or how do i put this code in? What i tried didn't work...
Regards,
J
Custom Easing Extension Work With Flash 8
The extension used in Lee's tutorial, I 've managed to download it now from laco.wz.cz but extension manager won't install it, is there a way around this to get it to work with flash 8 or is there an alternative that still works in a dialogue box rather than with action script.
Thanks
Ricky55
Tween Class Applied In Custom Class Not Working
var sizerW:Object = new Tween(pda_mc,"_xscale",mx.transitions.Tween.None.e aseNone,pdaOrigW,pdaSmallW,3,true);
this code produces and error when applied in a custom class but not in a fla?
the error = There is no property with the name 'None'.
Custom Transitionmanager Class Problem/class Scope?
I'm writing a class that fades from one scene to another in a video game. A custom transitionManager object is created, and a listener is attached. Once the fade out from one scene is complete, the listener is triggered, the scene switches, and the new scene fades in.
This is the error I'm getting: "There is no method with the name 'myTransitionManager'.
myTransitionManager.addEventListener("allTransitio nsOutDone", fadeListener);". It is given everytime myTransitionManager is accessed by any of the class functions.
I assume this is a class scope issue. How can I create a custom transitionManager object accessable to the entire class? I need it to be accessed by at least three separate class functions.
Here's the source, starting with the constructor for the GameSection class:
Code:
public function GameSection(clip_to_fade:MovieClip){
var myTransitionManager:TransitionManager = new TransitionManager();
}
//class methods
function switch_section(clip_to_fade:MovieClip, fade_in_scene:String) {
// Define a listener object to use with the Tween objects.
var fadeListener:Object = new Object();
//create event listener for transitions being complete
fadeListener.allTransitionsOutDone = function(eventObj:Object) {
trace("allTransitionsOutDone event occurred.");
gotoAndPlay(fade_in_scene);
fadeIn(clip_to_fade);
};
myTransitionManager.addEventListener("allTransitionsOutDone", fadeListener);
fadeOut(clip_to_fade);
}
function fadeIn(in_mc:MovieClip) {
myTransitionManager.start(in_mc, {type:Fade, direction:Transition.IN, duration:1, easing:None.easeNone});
}
function fadeOut(out_mc:MovieClip) {
myTransitionManager.start(out_mc, {type:Fade, direction:Transition.OUT, duration:1, easing:None.easeNone});
}
Thanks!
How Do You Listen In One Class For A Custom Event Dispatched From Another Class?
I am not sure how to word this, so here is what I would like to happen:
MyDocumentClass contains an instance of MyItem and MyItemManager. MyItem will fire an ItemEvent.ITEM_CHANGED event. I want MyItemManager to listen and react to that event. Possible? Here's my code:
ItemEvent.as:
ActionScript Code:
package
{
import flash.events.Event;
public class ItemEvent extends Event
{
public static const ITEM_EVENT:String = "itemEvent";
public function ItemEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false)
{
super(type, true);
}
public override function clone():Event
{
return new ItemEvent(type);
}
public override function toString():String
{
return formatToString("ItemEvent", "type", "bubbles", "cancelable");
}
}
}
MyDocumentClass.as:
ActionScript Code:
package {
import flash.display.Sprite;
import MyItem;
import MyItemManager;
public class MyDocumentClass extends Sprite
{
public var item:MyItem;
public var manager:MyItemManager;
public function MyDocumentClass()
{
item = new MyItem();
manager = new MyItemManager();
item.dispatchCustomEvent();
}
}
}
MyItem.as:
ActionScript Code:
package
{
import flash.display.Sprite;
import flash.events.EventDispatcher;
import ItemEvent;
public class MyItem extends Sprite
{
public function MyItem()
{
}
public function dispatchCustomEvent():void
{
dispatchEvent(new ItemEvent(ItemEvent.ITEM_EVENT));
}
}
}
MyItemManager.as:
ActionScript Code:
package
{
import flash.display.Sprite;
import ItemEvent;
import flash.events.EventDispatcher;
public class MyItemManager extends Sprite
{
public function MyItemManager()
{
addEventListener(ItemEvent.ITEM_EVENT, handleItemEvent);
}
public function handleItemEvent(e:ItemEvent):void
{
// do something here
}
}
}
Applying A Custom Class To An Object In The Document Class...
How's it going guys. I just started learning Actionscript 3.0 and so far not bad. However, I'm having trouble applying custom created classes to objects in the main document class. I'm using Flash as the application, however there is no timeline scripting involved. I loaded the document class called Main.as:
ActionScript Code:
package
{
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.display.Loader;
public class Main extends MovieClip
{
private var _redBox:Loader = new Loader();
private var _redBoxLink:URLRequest = new URLRequest("images/redbox.jpg");
public var buttonScaleHover:ButtonScaleHover = new ButtonScaleHover();
public function Main()
{
_redBox.x = 100;
_redBox.y = 100;
_redBox.load(_redBoxLink);
addChild(_redBox);
}
}
}
Now, what I'm trying to do is apply this class named ButtonScaleHover.as to the _redBox in the document class. Here is the code for ButtonScaleHover:
ActionScript Code:
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class ButtonScaleHover extends Sprite
{
private var _xScale:Number;
private var _yScale:Number;
public function ButtonScaleHover()
{
trace("The ButtonScaleHover Class is being loaded");
_xScale = this.scaleX
_yScale = this.scaleY
this.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
this.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
public function onRollOver(event:MouseEvent):void
{
this.scaleX *= 2;
this.scaleY *= 2;
}
private function onRollOut(event:MouseEvent):void
{
this.scaleX = _xScale;
this.scaleY = _yScale;
}
}
}
I tried using
ActionScript Code:
_redBox.ButtonScaleHover();
in the document class after i added it to the display object list. However, it didn't work. Basically, I'm just trying to apply a custom class to an object(in this case the loader). Thank you guys very much in advance.
Tween Class In Custom Extend MovieClip Class
I want to use the tween prototype in a custom class that extends MovieClip. I am already including "lmc_tween.as" in my root and I have already replaced the "MovieClip.as" file in my flash directory with the one from the shared/Zigo directory. However, I still get compiler errors if I try to include "lmc_tween.as" in the class file, or without the include in the class it will compile but the tween prototype will not work in the custom class. Does anyone know how to fix this?
Applying A Custom Class To An Object In The Document Class...
How's it going guys. I just started learning Actionscript 3.0 and so far not bad. However, I'm having trouble applying custom created classes to objects in the main document class. I'm using Flash as the application, however there is no timeline scripting involved. I loaded the document class called Main.as:
package
{
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.display.Loader;
public class Main extends MovieClip
{
private var _redBox:Loader = new Loader();
private var _redBoxLink:URLRequest = new URLRequest("images/redbox.jpg");
public var buttonScaleHover:ButtonScaleHover = new ButtonScaleHover();
public function Main()
{
_redBox.x = 100;
_redBox.y = 100;
_redBox.load(_redBoxLink);
addChild(_redBox);
}
}
}
Now, what I'm trying to do is apply this class named ButtonScaleHover.as to the _redBox in the document class. Here is the code for ButtonScaleHover:
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class ButtonScaleHover extends Sprite
{
private var _xScale:Number;
private var _yScale:Number;
public function ButtonScaleHover()
{
trace("The ButtonScaleHover Class is being loaded");
_xScale = this.scaleX
_yScale = this.scaleY
this.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
this.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
public function onRollOver(event:MouseEvent):void
{
this.scaleX *= 2;
this.scaleY *= 2;
}
private function onRollOut(event:MouseEvent):void
{
this.scaleX = _xScale;
this.scaleY = _yScale;
}
}
}
I tried using
_redBox.ButtonScaleHover();in the document class after i added it to the display object list. However, it didn't work. Basically, I'm just trying to apply a custom class to an object(in this case the loader). Thank you guys very much in advance.
Easing Applied To A Custom Cursor And Random MC Generation
I'm needing help for something.
First thing: I have a custom cursor (instance name cursor_mc) and when you move it, like any other cursor, when you stop, it stops. What I'd like to do is applye slight easing to the cursor, like in particle blaster. Any help on that one?
Second: I have a small movieclip (instance name pickup) and I would like to be able to generate random numbers of them that fall down the screen until they dissappear off it, and my character has to pick them up in the air to raise his score.
Any code I could have for that?
Doc Class Talks To Custom Class Problems
Hello all,
I am trying to get a Doc class to initiate a function in custom class, but I cant get it to work. I am still very new to working with classes and hope any of you can shine some light onto this problem.
I have 2 MovieClips, one is animating across the the stage via its custom class, and the other is a button control through the Doc class. I want to button to stop the stage.event from animating the first movie across the stage and to rotate the movieclip a value of 20.
So far the movie clip just keeps on going and does not stop.
Here is my Doc Class Code.
Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import mcSquare;
import Movesq;
public class MasterMain extends MovieClip
{
private var _square:Movesq;
public function MasterMain ()
{
_square = new mcSquare;
btn.addEventListener(MouseEvent.CLICK, stopBlackSquare, false, 0, true);
btn.buttonMode = true;
}
private function stopBlackSquare():void
{
_square.stopLoop();
}
}
}
Here is the Custom class code ( class name is Movesq)
Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.*;
public class Movesq extends MovieClip
{
public function Movesq ()
{
this.addEventListener (Event.ENTER_FRAME, onLoop, false, 0, true);
}
private function onLoop (evt:Event):void
{
this.x +=5;
}
public function stopLoop ():void
{
this.rotation = 20;
this.removeEventListener (Event.ENTER_FRAME, onLoop);
}
}
thank you for your help in advance.
Pending Class OnResult In Custom Class.
Ok,
I have a custom class with private field:
private var test:Stringint the constructor I load the web service:
pws = new WebService(Constants.getWsURL() + "?WSDL");
then I call a method on the WS:
var pcLoadModel = pws.LoadModel();
pcLoadModel.onResult = pcLoadModel_Succ;
pcLoadModel.onFault = pcLoadModel_Fail;
where:
public function pcLoadModel_Succ(result){
//some code.
}
The problem is that where it says "some code", I cant access the members of my class! Why not? in the debugger I clearly see that I have left the scope of the instance of the class I was working from. I dont understand why this happens.
Anyone has an answer to this?
Thanks you :)
Jp
Dynamic Class Reference In Custom Class
I've created a custom class that I want to be able to dynamically insert a movie clip from the library. I'm running into trouble because I want to access the clip as a property of the custom class object (ie: so it can be swapped out for another library clip after instantiation, among other things). I'm using getDefinitionByName() but I can't use it outside my addDiagram() function (see attached code) because the string variable that stores the name of the library clip isn't defined until after the custom class constructor function. Any help is appreciated!
Thanks,
-Erik
Attach Code
public function Panel(panelTitle:String,
panelWidth:Number,
panelHeight:Number,
panelX:Number,
panelY:Number,
panelType:String = "",
panelDisplay:String = ""):void {
this.panelTitle = panelTitle;
this.panelWidth = panelWidth;
this.panelHeight = panelHeight;
this.panelX = panelX;
this.panelY = panelY;
this.panelType = panelType;
this.panelDisplay = panelDisplay;
...
//if panel is to display a diagram, add the diagram clip
protected function addDiagram():void {
var diagramClass:Class = getDefinitionByName(panelDisplay) as Class;
var panelDiagram:* = new diagramClass();
panelDiagram.x = getPanelX() + 5;
panelDiagram.y = getPanelY() + 20;
panelDiagram.scaleX = .95;
panelDiagram.scaleY = .65;
addChild(panelDiagram);
}
[F8] Tween And Easing Class Help
I have been using the following actionscript to animate different mc's.
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
new Tween(b6, "_xscale", Strong.easeOut, 0, 70, 15, false);
new Tween(b6, "_yscale", Strong.easeOut, 0, 70, 15, false);
new Tween(b6, "_alpha", Strong.easeOut, 0, 100, 30, false);
I can't seem to get the above code to work for more than one mc at a time, so i've put this actionscript on a keyframe each time i use it. Is there a way to apply this actionscript to more than one mc on the same frame? something like the code below is what i'm looking for, but the code below doesn't work. It animates the first mc but not the second or any following.
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
new Tween(myClip_mc, "_xscale", Strong.easeOut, 0, 70, 15, false);
new Tween(myClip_mc, "_yscale", Strong.easeOut, 0, 70, 15, false);
new Tween(myClip_mc, "_alpha", Strong.easeOut, 0, 100, 30, false);
new Tween(myClip2_mc, "_xscale", Strong.easeOut, 0, 70, 15, false);
new Tween(myClip2_mc, "_yscale", Strong.easeOut, 0, 70, 15, false);
new Tween(myClip2_mc, "_alpha", Strong.easeOut, 0, 100, 30, false);
thanks in advance for any assistance.
Jay
Easing As A Property In A Class
I'm curious how I would be able to use easing as a property.
As it stands I have:
Code:
public var transType = Strong.easeOut
I was thinking that I would be able to access it with:
Code:
someVar.transType = Elastic.easeIn;
Unfortunately I get the error "1120: Access of undefined property Elastic."
The idea is that if I choose to use a different easing method, I just change the transType rather than rewriting or changing the class.
Easing Class Blur Help
Hello-
Newblack, if you see this, you could prob help out the best. attached is a tween class file Newblack created for me (which is working out very well and I appreciate it greatly). Right now it is set up so that when you use the Tween class, you specify which property to do it to. (_x, _y, _alpha). I want to know how I would use this class to apply blur (using BlurFilter), so when in movement, it blurs; amount of blur dependent on the easing math; i.e. so the faster its going, the more it blurs. Any help appreciated for I am pulling my hair out. Thanks! Eric
Easing As A Property In A Class
I'm curious how I would be able to use easing as a property.
As it stands I have:
Code:
public var transType = Strong.easeOut
I was thinking that I would be able to access it with:
Code:
someVar.transType = Elastic.easeIn;
unfortunately I get the error "1120: Access of undefined property Elastic."
Problem With Easing Class
I'm having an issue and am not finding any solutions. The easing animation is jumping around a bit, and it seems somewhat random when it jumps. It's like the tween classes are conflicting?
Here's the code I'm using:
var widthTween:Tween = new Tween(slide_mc, "_width", mx.transitions.easing.Strong.easeOut, largeTotalWidth, totalWidth, tweenTime, true);
var heightTween:Tween = new Tween(slide_mc, "_height", mx.transitions.easing.Strong.easeOut, largeTotalHeight, totalHeight, tweenTime, true);
var xTween:Tween = new Tween(slide_mc, "_x", mx.transitions.easing.Strong.easeOut, slide_mc._x, targetX, tweenTime, true);
var yTweenbject = new Tween(slide_mc, "_y", mx.transitions.easing.Strong.easeOut, slide_mc._y, targetY, tweenTime, true);
Anybody run into problems doing something like this?
Easing As A Property In A Class
I'm curious how I would be able to use easing as a property.
As it stands I have:
Code:
public var transType = Strong.easeOut
I was thinking that I would be able to access it with:
Code:
someVar.transType = Elastic.easeIn;
Unfortunately I get the error "1120: Access of undefined property Elastic."
The idea is that if I choose to use a different easing method, I just change the transType rather than rewriting or changing the class.
Problem With Easing Class
I'm having an issue and am not finding any solutions. The easing animation is jumping around a bit, and it seems somewhat random when it jumps. It's like the tween classes are conflicting?
Here's the code I'm using:
ActionScript Code:
var widthTween:Tween = new Tween(slide_mc, "_width", mx.transitions.easing.Strong.easeOut, largeTotalWidth, totalWidth, tweenTime, true);
var heightTween:Tween = new Tween(slide_mc, "_height", mx.transitions.easing.Strong.easeOut, largeTotalHeight, totalHeight, tweenTime, true);
var xTween:Tween = new Tween(slide_mc, "_x", mx.transitions.easing.Strong.easeOut, slide_mc._x, targetX, tweenTime, true);
var yTween:Object = new Tween(slide_mc, "_y", mx.transitions.easing.Strong.easeOut, slide_mc._y, targetY, tweenTime, true);
Anybody run into problems doing something like this?
|