Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Problem With OnRollOver And Multiple Tween In A Class



I am kind of a newbie and I am having trouble with an onRollOver function that includes a scripted tween in a class file. When you roll over the movieclip it seems to detect an onRollOver evertime it starts the tween. Is this a problem with the hitArea? Any help would be apprectiated.

here are the files: http://www.wiseguysink.com/test_files.zip



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 04-30-2006, 09:31 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Tween Class - Multiple Instances
Hey everyone,

This is a novice question, but please bare with me...thanks in advance(!)

I've built a simple tween class animation which drops a card (on a slight angle, randomized) onto the screen.

my code:

import mx.transitions.Tween;
import mx.transitions.easing.*;

var random_num:Number = Math.round(Math.random()*80) + (-40);
//trace(random_num);

var xScaleT:Tween = new Tween(badge_mc, "_x", Strong.easeOut, 100, 150, .7, true);
var xScaleT:Tween = new Tween(badge_mc, "_y", Strong.easeOut, 100, 60, .7, true);
var xScaleT:Tween = new Tween(badge_mc, "_height", Strong.easeOut, 2000, 123, .7, true);
var xScaleT:Tween = new Tween(badge_mc, "_width", Strong.easeOut, 2000, 133.6, .7, true);
var xScaleT:Tween = new Tween(badge_mc, "_rotation", Strong.easeOut, 0, random_num, 1.2, true);


Right now one single card is animated in, then disappears and another animates in.

I wish to have each card remain on the screen.... to have one animate in and remain on screen, then another animate down on top of the first and remain, etc until I have perhaps 15 cards on screen at once.

I think the listener object is my route, but I don't understand the syntax.. I've tried a ton of different code attempts with little success.

my source: block_tweenClass_test.fla

any help would be greatly, greatly appreciated. Cheers!!

Tween Class - Multiple Instances
Hey everyone,

I've built a simple tween class animation which drops a card (on a slight angle which is randomized) onto the screen.

my code:

import mx.transitions.Tween;
import mx.transitions.easing.*;

var random_num:Number = Math.round(Math.random()*80) + (-40);
//trace(random_num);

var xScaleT:Tween = new Tween(badge_mc, "_x", Strong.easeOut, 100, 150, .7, true);
var xScaleT:Tween = new Tween(badge_mc, "_y", Strong.easeOut, 100, 60, .7, true);
var xScaleT:Tween = new Tween(badge_mc, "_height", Strong.easeOut, 2000, 123, .7, true);
var xScaleT:Tween = new Tween(badge_mc, "_width", Strong.easeOut, 2000, 133.6, .7, true);
var xScaleT:Tween = new Tween(badge_mc, "_rotation", Strong.easeOut, 0, random_num, 1.2, true);



Right now one single card is animated in, then disappears and another animates in.

I wish to have each card remain on the screen. have one animate in and remain on screen, then another animate down on top of the first and remain, etc until I have perhaps 15 cards on screen at once.

I think the listener object is my route, but I don't understand the syntax.. I've tried a ton of different code attempts with no success.

you can see my source here: block_tweenClass_test.fla

any help would be greatly appreciated. Cheers.

Import Tween Class Once Or Multiple Times?
Hello everyone. I am using the tween class on my first key frame of my mc. It looks like this;


Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var myTween:Tween = new Tween(main_mc, "_x", mx.transitions.easing.Elastic.easeOut,590, 0, 3, true);
However my question is if I have multiple mcs that will use the same code how do i reference it? Currently I have the above code duplicated on two key frames, one of the first and another after a stop keyframe.

I am thinking I should put this in a global function or maybe some other way but not sure how. Any help is appreciated.

Tween Class Fading Loop, Acting Up With Multiple Clicks
Hello all,
I have a thumbnail gallery that I am working on. The gallery works fine and when you click the thumbnails it loads the respective swf into the container.picture movieclip.

I have used the tween class to fade a set of clips in a single swf in a loop infinitely.

The problem lies in that when you click the thumbnail, the swf loads fine and everything plays great (THE FIRST TIME) then if you repeatedly click the same thumbnail the tween class acts up and the fading gets strange, the timing messed up and it starts to almost layer the clicks on each other.

The problem seems VERY similar to when you use a setInterval and don't clear the interval and it starts to overlay them upon multiple clicks.

Is there a way to clear the tween class, delete it at run time, etc? This problem is driving me up the wall.

I have provided my code below (just for the tween class, not for the navigation) to hopefully spark an idea.


Thanks!
Neil











Attach Code

import mx.transitions.Tween;
import mx.transitions.easing.*;

//array that pulls in all movieclips and turns to array
var mcArray:Array = new Array(content1, content2);
for (var k in mcArray) {
mcArray[k]._alpha = 0;
}

var n:Number = 0;

function playFades() {
if (n<mcArray.length) {

var tween_handler1:Object = new Tween(mcArray[n], "_alpha", Strong.easeIn, 0, 100, 1, true);
tween_handler1.onMotionFinished = function() {
//trace("motion finished by "+mcArray[n]);
//n++;

var tween_handler2:Object = new Tween(mcArray[n], "_alpha", Strong.easeIn, 100, 0, 3.5, true);
tween_handler2.onMotionFinished = function() {
//trace("motion finished by "+mcArray[n]);
n++;
playFades();
};
};
} else {
n = 0;
playFades();
}
}
playFades();

























Edited: 02/19/2007 at 10:46:10 AM by Visionology

[tween Class] Creating Multiple Tweens And Assign Variable Names
Hi there:

I'm trying to create various tween for various movies, comething like this:


Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;

function fade_anim(mc, max, min, tempo) {
var bot_alpha:Tween = new Tween(eval(mc), "_alpha", Regular.easeIn, max, min, tempo, true);
bot_alpha.onMotionFinished = function() {
fade_anim(mc, min, max, tempo);
};
}

fade_anim("barra3",90,20,1);
fade_anim("barra4",30,80,1);
this code works without problem.

My problem is how to call a specific tween to stop it, for example: onrollover stop the tween assigned to "barra3" mc for example

I can't use bot_alpha.stop() it doesn't work. I think it's because i have multiple "bot_alpha" tweens, i need something to dynamic create bot_alpha1; bot_alpha2; ... ...

Thanks for the help!

How To Delay OnRollOver Tween?
I coded a website menu to xscale each navigation item for 1.5 seconds when you rollover it. The problem is if you place the cursor on the edge of the item it repeats the xscale tween over and over again. You can view the nav at http://www.revolutionnyc.com. Is there a way to set a delay between tweens so it diesn't start the next tween until the previous is finished? I tried adding a delay but it only performs the tween once. Here is my code:

bannerservice_mc.onRollOver = function () {
if (tweenDelay != true) {
var scaleBannerRolloverService:Tween = new Tween(bannerservice_mc, "_xscale", Elastic.easeOut, 50, 100, 1.5, true);
tweenDelay = true;
} else {
delayServiceInt = setInterval(serviceDelay, 1500);
function serviceDelay () {
var scaleBannerRolloverService:Tween = new Tween(bannerservice_mc, "_xscale", Elastic.easeOut, 50, 100, 1.5, true);
tweenDelay = false;
clearInterval (delayServiceInt);
}
}
}

Need Tween And Ease OnRollOver
Grey hair appearing on my head...



I have tried to make a simple 3 block navigation --> http://www.plusidentity.dk/TEST/3blocks.swf

.fla here (MX2004) http://www.plusidentity.dk/TEST/3blocks.fla

Now the blocks should expand with ease when U roll the mouse over, but my brain is temporary fried... can't figure it out.

my AS looks like this... very simple, but crappy


ActionScript Code:
stop();
//
main_mc.top_mc.onRollOver = function() {
 //this.swapDepths(highest);
 //highest = this;
 //
 this._y = main_mc._y;
 this._height = 200;
 main_mc.middle_mc._y = main_mc._y+200;
 main_mc.middle_mc._height = 50;
 main_mc.bottom_mc._y = main_mc._y+250;
 main_mc.bottom_mc._height = 50;
};
main_mc.middle_mc.onRollOver = function() {
 //this.swapDepths(highest);
 //highest = this;
 //
 this._y = main_mc._y+50;
 this._height = 200;
 main_mc.top_mc._y = main_mc._y;
 main_mc.top_mc._height = 50;
 main_mc.bottom_mc._y = main_mc._y+250;
 main_mc.bottom_mc._height = 50;
};
main_mc.bottom_mc.onRollOver = function() {
 //this.swapDepths(highest);
 //highest = this;
 //
 this._y = main_mc._y+100;
 this._height = 200;
 main_mc.top_mc._y = main_mc._y;
 main_mc.top_mc._height = 50;
 main_mc.middle_mc._y = main_mc._y+50;
 main_mc.middle_mc._height = 50;
};
//
function reset(target) {
 target.onRollOut = function() {
  main_mc.top_mc._y = main_mc._y;
  main_mc.top_mc._height = 100;
  main_mc.middle_mc._y = main_mc._y+100;
  main_mc.middle_mc._height = 100;
  main_mc.bottom_mc._y = main_mc._y+200;
  main_mc.bottom_mc._height = 100;
 };
}
reset(main_mc.top_mc);
reset(main_mc.middle_mc);
reset(main_mc.bottom_mc);
//

Really could use a hand here... thanx

OnRollOver Tween Glitch
Hello. I've got a problem using navigation that implements the tween class when rolled over. What happens is when you roll over the nav very quickly, the buttons go immediately to the end of the onRollOver tween and stay there. Is there something wrong with the code or something I can do to stop this? I've already tried putting on a short timer, but that only delays the problem.

Here's the example: http://www.isograft.com/temp/

Here's my Nav class (please note that I have deleted irrelevant code):


Code:
class Nav {
public var $mcRef:MovieClip;

private function initStates():Void {
this.$mcRef.parent = this;
this.$mcRef.onRollOver = function():Void {
this.parent.easeSq("_height", 70, .6, "out");
}
this.$mcRef.onRollOut = function():Void {
this.parent.easeSq("_height", 30, .5, "in");
}
}

private function easeSq(sProp:String, nEnd:Number, nTime:Number, sType:String):Void {
if(sProp == "_x") { var nStart:Number = this.$mcRef._x; }
else if(sProp == "_y") { var nStart:Number = this.$mcRef._y; }
else if(sProp == "_height") { var nStart:Number = this.$mcRef._height; }
if(sType == "out") { var type = mx.transitions.easing.Bounce.easeOut; }
else if(sType == "in") { var type = mx.transitions.easing.Strong.easeOut; }
var navTween:Tween = new Tween(this.$mcRef, sProp, type, nStart, nEnd, nTime, true);
this.$mcRef.onEnterFrame = function():Void {
if(navTween.isPlaying == true) {
var nDepth:Number = _root.getNextHighestDepth();
this.$mcRef = _root.createEmptyMovieClip("mc"+nDepth, nDepth);
this.$mcRef._x = this.$nXpos;
this.$mcRef._y = this.$nYpos;
this.$mcRef.beginFill(this.$nColor);
this.$mcRef.moveTo(0, 0);
this.$mcRef.lineTo(this.$nWidth, 0);
this.$mcRef.lineTo(this.$nWidth, this.$nHeight);
this.$mcRef.lineTo(0, this.$nHeight);
this.$mcRef.lineTo(0, 0);
this.$mcRef.endFill();
this.$mcRef._alpha = this.$nAlpha;
}
else if(navTween.isPlaying == false) {
delete this.onEnterFrame;
}
}
}
}
Any insights are much appreciated.

OnRollOver , Tween And Performance
I created a row of little blueboxes, each box does a few same transitions for onRollOver and onRollOut. The little flash application ate over 30% CPU when moving mouse fast over blueboxes. Any idea to twist?

Thanks in advance


Code:
var wOver;
var hOver;
var xOver;
var yOver;

var ox = 20;
var oy = 50;

for (var i = 0; i < 20; i ++) {
var itest = this.createEmptyMovieClip("itest"+i, i+1);
itest.attachMovie("mc_test", "imc", 1);

itest._x = ox;
itest._y = oy;
ox+=itest._width+5;

itest.ox = itest._x;
itest.oy = itest._y;
itest.ow = itest._width;
itest.oh = itest._height;
itest.sw = itest._width+6;

itest.onRollOver = function() {
_root.wOver.stop();
_root.hOver.stop();
_root.xOver.stop();
_root.yOver.stop();
_root.wOver = new mx.transitions.Tween(this, "_width", Regular.easein, this.ow, this.sw, 0.3, true);
_root.hOver = new mx.transitions.Tween(this, "_height", Regular.easein, this.oh, this.oh+4, 0.3, true);
_root.xOver = new mx.transitions.Tween(this, "_x", Regular.easein, this.ox, this.ox-(this.sw-this.ow)/2, 0.3, true);
_root.yOver = new mx.transitions.Tween(this, "_y", Regular.easein, this.oy, this.oy-2, 0.3, true);
};

itest.onRollOut = function() {
wOut = new mx.transitions.Tween(this, "_width", Regular.easeOut, this._width, this.ow, 0.5, true);
hOut = new mx.transitions.Tween(this, "_height", Regular.easeOut, this._height, this.oh, 0.5, true);
xOut = new mx.transitions.Tween(this, "_x", Regular.easeOut, this._x, this.ox, 0.5, true);
yOut = new mx.transitions.Tween(this, "_y", Regular.easeOut, this._y, this.oy, 0.5, true);
};
}

stop();

Dynamic OnRollOver & Out Using Lmc Tween. Help
Ok I am trying to apply some easing movement to a MC when you rollover a button. I am using lmc tween prototype and It's not working properly (when you run over the button fast it ignores onrollover action and so on)
I was using gotoAndPlay rollover but didn't like that stiff movement.
Could anybody help on this on? Thank you.

How To Delay OnRollOver Tween?
I coded a website menu to xscale each navigation item for 1.5 seconds when you rollover it. The problem is if you place the cursor on the edge of the item it repeats the xscale tween over and over again. You can view the nav at http://www.revolutionnyc.com. Is there a way to set a delay between tweens so it diesn't start the next tween until the previous is finished? I tried adding a delay but it only performs the tween once. Here is my code:

bannerservice_mc.onRollOver = function () {
if (tweenDelay != true) {
var scaleBannerRolloverService:Tween = new Tween(bannerservice_mc, "_xscale", Elastic.easeOut, 50, 100, 1.5, true);
tweenDelay = true;
} else {
delayServiceInt = setInterval(serviceDelay, 1500);
function serviceDelay () {
var scaleBannerRolloverService:Tween = new Tween(bannerservice_mc, "_xscale", Elastic.easeOut, 50, 100, 1.5, true);
tweenDelay = false;
clearInterval (delayServiceInt);
}
}
}

Tween Alpha OnRollOver
I want to tween the alpha of a text from 50 to 100 onRollover. onRollOut the alpha is to tween back to 50.

Is there a good way to do this with action script? I don't want to animate it...

AAAARGH - Need Tween And Ease OnRollOver
Grey hair appearing on my head...

I have tried to make a simple 3 block navigation --> http://www.plusidentity.dk/TEST/3blocks.swf

.fla here (MX2004) http://www.plusidentity.dk/TEST/3blocks.fla

Now the blocks should expand with ease when U roll the mouse over, but my brain is temporary fried... can't figure it out.

my AS looks like this... very simple, but crappy


ActionScript Code:
stop();//main_mc.top_mc.onRollOver = function() { //this.swapDepths(highest); //highest = this; // this._y = main_mc._y; this._height = 200; main_mc.middle_mc._y = main_mc._y+200; main_mc.middle_mc._height = 50; main_mc.bottom_mc._y = main_mc._y+250; main_mc.bottom_mc._height = 50;};main_mc.middle_mc.onRollOver = function() { //this.swapDepths(highest); //highest = this; // this._y = main_mc._y+50; this._height = 200; main_mc.top_mc._y = main_mc._y; main_mc.top_mc._height = 50; main_mc.bottom_mc._y = main_mc._y+250; main_mc.bottom_mc._height = 50;};main_mc.bottom_mc.onRollOver = function() { //this.swapDepths(highest); //highest = this; // this._y = main_mc._y+100; this._height = 200; main_mc.top_mc._y = main_mc._y; main_mc.top_mc._height = 50; main_mc.middle_mc._y = main_mc._y+50; main_mc.middle_mc._height = 50;};//function reset(target) { target.onRollOut = function() {  main_mc.top_mc._y = main_mc._y;  main_mc.top_mc._height = 100;  main_mc.middle_mc._y = main_mc._y+100;  main_mc.middle_mc._height = 100;  main_mc.bottom_mc._y = main_mc._y+200;  main_mc.bottom_mc._height = 100; };}reset(main_mc.top_mc);reset(main_mc.middle_mc);reset(main_mc.bottom_mc);//  


Really could use a hand here... thanx

/JBOY

Actionscripted Easing Tween Triggered By Onrollover
Hi,

Just wanted to know if someone could help me out on this one. I have been trying to get a ease tween of a clips _alpha property to fade in when rolled over, and then fade out when rolled out. In the first frame of the main timeline, I have these two functions:

ActionScript Code:
this.fadeIn = function(clip) {    et = 0;    ed = 10;    clip.onEnterFrame = function() {        et++;        if(et<ed) {            clip._alpha = Sine.easeIn(et, 0, 100, ed);        }    }}this.fadeOut = function(clip) {    // the opposite, etc...}

then within the movieclip that I use as a rollover, I put the following script:

ActionScript Code:
this.onRollOver = function() {      _root.fadeIn(this.faderClip);}this.onRollOut = function() {     _root.fadeOut(this.faderClip);}

Now, the fading in/out works just fine, but the trigerring is not isolated, and random clips fade in and out regardless of what clip I am moving on or off of. How do I isolate this? These are dynamically attached clips, just as a note. Any help would be greatly appreciated.

CJ

Actionscripted Easing Tween Triggered By Onrollover
Hi,

Just wanted to know if someone could help me out on this one. I have been trying to get a ease tween of a clips _alpha property to fade in when rolled over, and then fade out when rolled out. In the first frame of the main timeline, I have these two functions:

ActionScript Code:
this.fadeIn = function(clip) {    et = 0;    ed = 10;    clip.onEnterFrame = function() {        et++;        if(et<ed) {            clip._alpha = Sine.easeIn(et, 0, 100, ed);        }    }}this.fadeOut = function(clip) {    // the opposite, etc...}

then within the movieclip that I use as a rollover, I put the following script:

ActionScript Code:
this.onRollOver = function() {      _root.fadeIn(this.faderClip);}this.onRollOut = function() {     _root.fadeOut(this.faderClip);}

Now, the fading in/out works just fine, but the trigerring is not isolated, and random clips fade in and out regardless of what clip I am moving on or off of. How do I isolate this? These are dynamically attached clips, just as a note. Any help would be greatly appreciated.

CJ

Tween Transitions, Movieclips & OnRollOver Flicker
Hi, I'm using actionscript to make a button out of a movieclip that use's an elastic mx.transitions class for onRollOver and onRollOut. My problem is if you hold the mouse cursor near the edge of the movieclip it keeps restarting the elastic tween which results in an ugly flickering effect (closer to the center of the mc is fine, you don't get the restarting/flicker) .

Is there anyway I could stop this from happening so that the tween plays right through even if the mouse cursor is held on the edge of the mc?

Tween Class If Moved Mc Passed Point Start Another Tween
Hey Actionscript Gurus

Now I am using the Tween Class to move some boxes in my movie, now I can move the first mc and then another mc after the first tween has finished with onMotionFinished but I was hoping someone could help with how do I start the second tween when the first mc has passed a certain _x coordinate.

ie starting the second mc moving while the first tween is still moving.

I am trying to do a intro loader for my front page controlling around 7 boxes. So I need to repeat this a few times.

Regs,
Jacko

Tween Class If Moved Mc Passed Point Start Another Tween
Hey Kirupa Flash Gurus

Now I am using the Tween Class to move some boxes in my movie, now I can move the first mc and then another mc after the first tween has finished with onMotionFinished but I was hoping someone could help with how do I start the second tween when the first mc has passed a certain _x coordinate.

ie starting the second mc moving while the first tween is still moving.

Regs,
Jacko

Tween Class Scaling Breaks Motion Tween?
I have a movie clip which uses a motion guide to animate the entry (and eventually the exit) of a bunch of other movie clips. These smaller clips contain buttons, and animate on rollOver and rollOut using the following code:


Code:
on(rollOver) {
this.swapDepths(2);
ParentxScale = new mx.transitions.Tween(this, "_xscale", mx.transitions.easing.Back.easeOut, this._xscale, 100/.6, .5, true);
ParentyScale = new mx.transitions.Tween(this, "_yscale", mx.transitions.easing.Back.easeOut, this._yscale, 100/.6, .5, true);
play();
}
on(rollOut) {
ParentxScale = new mx.transitions.Tween(this, "_xscale", mx.transitions.easing.Bounce.easeOut, this._xscale, 100, .5, true);
ParentyScale = new mx.transitions.Tween(this, "_yscale", mx.transitions.easing.Bounce.easeOut, this._yscale, 100, .5, true);
stop();
}
However, once an object has been moused over, it doesn't exit with the others. Any ideas why it seems to "fall off the track" of the motion guide?

OnRollOver Help In Custom Class
semi-new to oop, and I'm about to start banging my head against my monitor.

I have a custom class called slide.as. It loads a jpg and places it in a movie clip created on the parent timeline. The class holds a property called slideRef which references the movieclip that the jpg was loaded into. With this.slideRef I have no problem changing the scale or x and y positions of the clips. What I can't do is set an onRollOver function for them. Here's there relavent code...


Code:
class slide{
var slideDir:String;
var slideRef:MovieClip;
var slideNum:Number;
var slideScale:Number;
var centerX:Number;
var distance:Number;
var cl_mc_loader:MovieClipLoader;
var cl_mc_listener:Object;


function slide(slideDir:String, slideRef:MovieClip, slideNum:Number){
this.slideDir = slideDir;
this.slideRef = slideRef;
this.slideNum = slideNum;
this.cl_mc_loader = new MovieClipLoader();
this.cl_mc_listener = new Object();
}

function addSlide(){
this.slideRef._xscale = this.slideRef._yscale = 40; // works fine

this.cl_mc_loader.addListener(this.cl_mc_listener);
this.cl_mc_loader.loadClip(this.slideDir, this.slideRef);
this.cl_mc_listener.onLoadInit = this.onClipLoad();
}
function onClipLoad(){
trace(this.slideRef); // traces _level0.stories.strip.slide0 and .slide1 etc...
this.slideRef._rotation = 45; // rotates all slides 45 degrees
this.slideRef.onRollOver = function(){ // does nothing!!
trace("rolling over");
}
}

etc...
any thoughts would be greatly appreciated.

OnRollOver Help In Custom Class
semi-new to oop, and I'm about to start banging my head against my monitor.

I have a custom class called slide.as. It loads a jpg and places it in a movie clip created on the parent timeline. The class holds a property called slideRef which references the movieclip that the jpg was loaded into. With this.slideRef I have no problem changing the scale or x and y positions of the clips. What I can't do is set an onRollOver function for them. Here's there relavent code...


Code:
class Slide{
var slideDir:String;
var slideRef:MovieClip;
var slideNum:Number;
var slideScale:Number;
var centerX:Number;
var distance:Number;
var cl_mc_loader:MovieClipLoader;
var cl_mc_listener:Object;


function slide(slideDir:String, slideRef:MovieClip, slideNum:Number){
this.slideDir = slideDir;
this.slideRef = slideRef;
this.slideNum = slideNum;
this.cl_mc_loader = new MovieClipLoader();
this.cl_mc_listener = new Object();
}

function addSlide(){
this.slideRef._xscale = this.slideRef._yscale = 40; // works fine

this.cl_mc_loader.addListener(this.cl_mc_listener);
this.cl_mc_loader.loadClip(this.slideDir, this.slideRef);
this.cl_mc_listener.onLoadInit = this.onClipLoad();
}
function onClipLoad(){
trace(this.slideRef); // traces _level0.stories.strip.slide0 and .slide1 etc...
this.slideRef._rotation = 45; // rotates all slides 45 degrees
this.slideRef.onRollOver = function(){ // does nothing!!
trace("rolling over");
}
}

etc...
any thoughts would be greatly appreciated.

HELP : OnRollOver : CreateEmptyMovieClip : Class
Hey all,

Why doesn't the trace "over" work on the below code? Anyone have any ideas?

class custom.myprojectname.load_photos {
public function load_photos(){
var num_img:Number = 8;
var i:Number = 1;
while (i <= num_img) {
_level0.createEmptyMovieClip("MyMC"+i, _level0.getNextHighestDepth());
eval("_level0.MyMC"+i).onRollOver = function() {
trace("over");
}
i += 1;
}
}
}

Thanks
Adam

Multiple OnRollOver Areas
-----------synopisis------------------------

I have 468x400 banner.
When i drag the mouse over the banner, the banner goes to frame 2.

On frame 2, a movieclip textanimation is activated.

When i drag the mouse off the banner, it goes to frame 3, where another textanimation is activated.

All good so far. There is a animation when you "enter" the flash, and when you "leave" it.

-----------problem------------------------

The trouble starts when i want to add some interactivity on frame 2 (the mouse is somewhere ON the banner).

In the centre of the banner, i have a small icon. When i drag the mouse over that icon, i want to display some text.

But when i drag the mouse over that icon, flash thinks that i am leaving the stage, and the movie goes to frame 3. I want to display that text, not leaving frame 2.

Does anyone know how to solve this?

Custom Class Won't Recognize OnRollOver
I created a custom Class for my menu items so I can manage them easily. The only problem is I want to use, among other things, the onRollOver clip event, but it won't work! I know there is a way to sort of duplicate the MovieClip class (basically copying movie's prototype into my class's, which would allow my class access to the onRollOver event) but I can't for the life of me figure out how. I also think there is a way to make my class a subclass of the movieclip class, but, once again, my memory fails me. I seem to remember something about __proto__ but all my efforts have ended in failure. Can someone help me out?

[help] Custom Class Oop OnRollOver Method
I have a client that I am building an image gallery. There are thumbs and then a custom viewer windo that the thumbs are to send the image location too when they are rolledOVer. The problem is that I do a loader for the fullsize image to load it into cash for each thumb, then scale down the image. Then he wanted it to be black and white images that would go to color when rolled over too.
So I basically have a class that creates a new mc inside of a defined mc. Then inside of that mc I create layers, the lowest is the full sized image that gets scaled down to the black and white image size, the next is a mask layer for it, then after that is the black and white image that doesn't scale down but centers, then there is a mask layer above that.

I can invoke the target_mc.onRollOver = function method, and if I do a trace it will display the info. But if I try to set the thumb movies _visible to false it does not do anything. If i set the _visible to false outside of the onRollover method it makes the black and white photo not visible.

So for some reason when I put the _visible in the target_mc.onRollOver = function method it is not making the black and white image invisible.

Can anyone look at my ImageViewerThumb.as and see what is wrong, it's super script is ImageViewer.as which I will include. Maybe I need to have it extend MovieClip too?


opps, can't attach .as so I will post in in next post

Problem With OnRollOver In Class File
I am working with a class object and am having a problem with the onRollOver event triggering. My code in the class file is as follows:


Code:
class ScrollItem extends MovieClip{
function ScrollItem(){
trace("test");
this.onRollOver = function () {
trace ("onRollOver called");
};
}
}
"test" fires, but "onRollOver called" does not when I mouse over the movie clip. I have also noticed that the mouse cursor for the entire movie is a text selector icon and not the pointer or hand icon. To my knowledge, there are no text boxes behind or in front of the movie clips. This is a single frame flash movie where the class-linked movie clips are scrolled by an onEnterFrame event from the main time line.

Any ideas on where this problem could be coming from or places to start looking? Let me know if this is not enough information.

Thanks,

[AS2] Using MovieClip OnRollOver For MyButton Class
I'm creating MyButton class using the MovieClip class. The problem is getting onRollOver to reDraw MyButton. The scope appears to be wrong, please help. This is a simplified version to represent the problem.

// Menu.fla
//Create an Instance of MyButton

var b:MyButton = new MyButton();

//MyButton.as Class

class MyButton{
private var mc:MovieClip;
public var xPosition:Number;
public var yPosition:Number;
public var width:Number;
public var height:Number;
public var fill;

//Construct MyButton
public function MyButton(){
create();
drawRect(0, 0, 100, 22, 0xccddaa);
drawOver();
}

//Create MovieClip Instance
private function create():Void {
mc = _root.createEmptyMovieClip("buttonx", 0);
}

//draw MyButton Shape
private function drawRect(xPosition, yPosition, width, height, fill) {
var ax = xPosition+width;
var ay = yPosition;
var bx = xPosition;
var by = yPosition+height;
mc.clear();
mc.beginFill(fill, 90);
mc.lineStyle(1, 0xccddee);
mc.moveTo(xPosition, yPosition);
mc.lineTo(ax, ay);
mc.lineStyle(1, 0xccddee);
mc.lineTo(ax, by);
mc.lineStyle(1, 0xccddee);
mc.lineTo(bx, by);
mc.lineStyle(1, 0xccddee);
mc.lineTo(bx, ay);
mc.endFill();
}

//reDraw MyButton onRollOver
private function drawOver(){
mc.onRollOver = function(){
drawRect(0, 0, 100, 22, 0x000000);
}
}
}

[AS2] Using MovieClip OnRollOver For MyButton Class
I'm creating MyButton class using the MovieClip class. The problem is getting onRollOver to reDraw MyButton. The scope appears to be wrong, please help. This is a simplified version to represent the problem.

// Menu.fla
//Create an Instance of MyButton

var b:MyButton = new MyButton();

//MyButton.as Class

class MyButton{
private var mc:MovieClip;
public var xPosition:Number;
public var yPosition:Number;
public var width:Number;
public var height:Number;
public var fill;

//Construct MyButton
public function MyButton(){
create();
drawRect(0, 0, 100, 22, 0xccddaa);
drawOver();
}

//Create MovieClip Instance
private function create():Void {
mc = _root.createEmptyMovieClip("buttonx", 0);
}

//draw MyButton Shape
private function drawRect(xPosition, yPosition, width, height, fill) {
var ax = xPosition+width;
var ay = yPosition;
var bx = xPosition;
var by = yPosition+height;
mc.clear();
mc.beginFill(fill, 90);
mc.lineStyle(1, 0xccddee);
mc.moveTo(xPosition, yPosition);
mc.lineTo(ax, ay);
mc.lineStyle(1, 0xccddee);
mc.lineTo(ax, by);
mc.lineStyle(1, 0xccddee);
mc.lineTo(bx, by);
mc.lineStyle(1, 0xccddee);
mc.lineTo(bx, ay);
mc.endFill();
}

//reDraw MyButton onRollOver
private function drawOver(){
mc.onRollOver = function(){
drawRect(0, 0, 100, 22, 0x000000);
}
}
}

As2.0 OnRollOver In Class Func Cant Access Var
Hi i have a simple class with a private property bgColor and a function that renders a small box on a empty movie clip. I am trying to change the color via onRollOver but whenever i try to pass the bgColor in the onRollOver function i get 0. I am not sure if a defined onRollOver function in a method can access class properties, can anyone take a look. thanks.


ActionScript Code:
//.... container_mc, cellWidth and cellHeight already defined as
//class properties...
private var bgColor:Number = 0x0023cc;
private function createBG():Void{
    container_mc.createEmptyMovieClip("bgBox",bgDepth);
    container_mc.bgBox.moveTo(0,0);
    container_mc.bgBox.beginFill(bgColor);
    container_mc.bgBox.lineTo(cellWidth,0);
    container_mc.bgBox.lineTo(cellWidth,cellHeight);
    container_mc.bgBox.lineTo(0,cellHeight);
    container_mc.bgBox.lineTo(0,0);
    container_mc.bgBox.endFill();
   
    container_mc.bgBox.onRollOver = function(){
                    var cellColorObject = new Color(this);
        cellColorObject.setRGB(bgColor);
        trace(cellColorObject.getRGB());
        delete cellColorObject;
    }
}
 
 
//trace = 0
 

Tween Class: Can One Tween More Than One Property Using The Same Tween
I want to scale both the _xscale and the _yscale properties of a clip, using a single execution of the Tween Class. See example below:


Code:
import mx.transitions.Tween;
var myTween:Tween = new Tween(myMovieClip_mc, "_xscale", Strong.easeOut, myMovieClip_mc._xscale, 300, 5, false);

Since one property at a time must be passed as a string to the constructor, I tried the following code, but it does not work quite as flawless as I expected:


Code:
myTween.onMotionChanged = function() {
//trace( this.position );
myMovieClip_mc._yscale += (300 - myMovieClip_mc._yscale)/12;
};
Any suggestions?

After Tween, Jump To New Frame (using Tween Class)
I need some help with using the tween class (among other things).

See my attached test file. It's clearer than my description.

You're supposed to be able to click the "next" or "prev" buttons and see the movie clip move forwards or backwards. It works, but only on the first click of the button. After the initial click I need the timeline to jump to frame label "2", and after the second click I need the timeline to jump to frame label "3", and so on, so that I can implement a new set of perameters. Is that clear? I'm so annoyed with this. Please help!

Thanks.

Tween Class Problem. Tween Freeze?
I am using the tween class to do an alpha tween on some jpgs that get loaded into a movieclip. Everything thing works great until the user rapidly clicks on the 'next' arrow to jump forward to a new picture. If the user clicks too quickly something happens and the tween function stops working.

Here is the tween code:

Code:
//set up tweening
import mx.transitions.easing.*;
import mx.transitions.Tween;
var tweenAlpha:Tween;
function alphaTween(object,duration){
easeType = mx.transitions.easing.Regular.easeIn;
tweenAlpha = new mx.transitions.Tween(object, "_alpha", easeType, 0, 100, duration, true);
}
http://12dogsofchristmas.com/12_dogs_menu2.swf

You'll notice that if you click slowly on the arrows the pictures load correctly with the story. However, if you click fast they stop tweening.

thanks for the help.

Tween.stop(). Part Of The Tween Class?
I need to know if tween.stop() is part of the Tween class in Flash 8 or if it's related to an extension I installed (ie. TweenExtended).

Tween Class Not Always Fulling Complete Tween
I have a switch statement that is a part of the tween effects found on the header of http://gfxcomplex.com/blog.

the problem is this case will change the rotation of a sprite and then tween it to zero. The funny thing is some times ("not all the time") some of the tween stop in the middle and do not complete leaving the sprite with a rotation somewhere in the middle of 180 to 0. My question is, is there something in my code that could be the reason for this or is this a bug??

You may have to watch the header for a long time to see this bug happen as it seems to be more a fluke then a true code bug.


PHP Code:



case 7 :            var u:uint = 0;            test1.getChildAt(0).rotation = 180;            test1.getChildAt(1).rotation = 180;            test1.getChildAt(2).rotation = 180;            test1.getChildAt(3).rotation = 180;            test1.getChildAt(4).rotation = 180;               intervalId = setInterval(function myFunction(){                                                          myTween1 = new Tween(test1.getChildAt(u), "rotation", Bounce.easeOut, 180, 0, 3, true);                                                          u++;                                                          if(u == 5){                                                                                                                      clearInterval(intervalId);                                                                                                                        }                                                          },                                                          150);break; 

Reposition Multiple Movieclips Onrollover
hmmm, this i s toughy, at least for me.

i have a grid of duplicated movieclips, which when you rollover they enlarge. is there anyway that you could have it so that when you rollover one of the clips, the others moved out the way, because at the moment they would be covered up by the enlarged clip, but i was wondering if there was anyway you could sort of move the ones that would be covered to a new position where they would not be covered up? if you see what i mean. hmmm

the more i thin about it he harder i think this is... is anyone able to help?

filehere -> http://www.ctranter.co.uk/flashkit/jaja.fla

OnRollOver() Applied To Multiple MCs Using For Loop
i have dynamically created text fields inside a movie clip.

i want to apply onRollOver and onRollOut events to all of them using a for loop.

here is the code:

Code:

for (var c = current; c<=total; c++) {
this["item"+c].onRollOver = function() {
this["item"+c+"Txt"].backgroundColor = 0x000000;
this["item"+c+"Txt"].textColor = 0xffffff;
this["item"+c+"Txt"].borderColor = 0xffffff;
};
this["item"+c].onRollOut = function() {
this["item"+c+"Txt"].backgroundColor = 0x0099ff;
this["item"+c+"Txt"].textColor = 0x000000;
this["item"+c+"Txt"].borderColor = 0x000000;
};
}



for some reason, everything in my file works except for the above code.

i have attached the file so it can be seen in context with the rest of the file. it's in flash mx format.

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'.

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?

Button.onRollover Work With Multiple Levels?
I can get the button.onRollover script to work just fine when I drab my movieclip onto the _root stage, but doesn't work when I try to jump down levels in to other MC's. This example works perfect:


Code:
mc_name.onRollOver = function () {
trace ("onRollOver called");
};
But the following doesn't work:


Code:
mc_name.another_mc_name.onRollOver = function () {
trace ("onRollOver called");
};
Does this method not work with MC's inside of MC's?

Multiple OnRollOver-onRollOut On Nested MovieClips
As we now, u cant have multiple onRollOver-onRollOut on nested MovieClips becouse they comflict each other, and the use of the hitTest is very unpredictible and give some surprising results
This apply also for behavoirs as buttons inside of MovieClips.

So here is a prototype to manage this problem(Flash MX).

If u find a better code/way, or can improve this code I want to know. Also if somebody translate to AS2, please post the result.

Tween Class Vs Custom Tween?
I have searched for info on the Tween class, gave up when I found little to nothing on it, so here I am with some questions.

1 - Can I use this class in MX 2004 or is it in 8 only? If so, what is the invocation script?

2 - How flexible is the easing of the Tween class? Can it do more than just fast/slow in/out (fully customizable time curves)?

3 - Can you specify a finite amount of time in which the current invocation of Tween must be completed, or do you have to calculate and apply values to enforce this?

Thanks,
+Q__

Tween Class - Tween Lines
I have 5 seperate movie clips that each contain 5 lines, which are contained within their own individual movieclips, each with their own instance name.

I have written a function, included below, that uses the tween class to make one set of lines move/morph to the location of the second set, contained within the other movieclip.

It's basically a transition.. it's for the navigation of a site I'm working on. When you click a different navigation link, the lines that the nav & content are based around morph/change.

The problem I'm having is not all the lines tween to the right location/position. I've attached a 2 screenshots to show..

I've tried the function with the addition of the _xscale, _yscale, and _rotation properties, but they don't change anything.

Heres the function:


Code:
function moveLines(begin, end) {
//this moves the MC that holds the 5 lines to the x/y pos of the other MC.
var x_container:Tween = new Tween(_root[begin], "_x", Regular.easeOut, _root[begin]._x, _root[end]._x, 10, false);
var y_container:Tween = new Tween(_root[begin], "_y", Regular.easeOut, _root[begin]._y, _root[end]._y, 10, false);


//this is the loop that gets the start/end variables and creates the tweens
for (i=1; i<=5; i++) {
x_begin = _root[begin]["l" + i]._x;
x_end = _root[end]["l" + i]._x;

y_begin = _root[begin]["l" + i]._y;
y_end = _root[end]["l" + i]._y;

height_begin = _root[begin]["l" + i]._height;
height_end = _root[end]["l" + i]._height;

width_begin = _root[begin]["l" + i]._width;
width_end = _root[end]["l" + i]._width;

var x_tween:Tween = new Tween(_root[begin]["l" + i], "_x", Regular.easeOut, x_begin, x_end, 15, false);
var y_tween:Tween = new Tween(_root[begin]["l" + i], "_y", Regular.easeOut, y_begin, y_end, 15, false);
var height_tween:Tween = new Tween(_root[begin]["l" + i], "_height", Regular.easeOut, height_begin, height_end, 15, false);
var width_tween:Tween = new Tween(_root[begin]["l" + i], "_width", Regular.easeOut, width_begin, width_end, 15, false);
}
}
Now here are the screenshots. The first is before the tween occurs, and the second is after. As you can see, some of the lines don't fall into the right position. Any help is greatly appreciated! I have a deadline for this this week and I'm freaking out!

before tween:
http://sagebrown.com/before.jpg

after tween:
http://sagebrown.com/after.jpg

How To STOP A Tween With The Tween Class?
here's my code....


Code:
function generalTween(mc, attr, begin, end, time, func, easeType)
{
if (easeType == undefined) easeType = mx.transitions.easing.Bounce.easeOut;
var myTween = new mx.transitions.Tween(mc, attr, easeType, begin, end, time, true);
if (func != undefined) myTween.onMotionStopped = func;
}
function onReleaseFunc()
{
myBall.stopDrag();
generalTween(myBall, "_x", myBall._x, (Stage.width / 2), 2, undefined, mx.transitions.easing.Elastic.easeOut);
generalTween(myBall, "_y", myBall._y, (Stage.height / 2), 2, undefined, mx.transitions.easing.Elastic.easeOut);
}
myBall.onPress = function()
{
myBall.startDrag();
}
myBall.onRelease = function()
{
onReleaseFunc();
}
myBall.onReleaseOutside = function()
{
onReleaseFunc();
}
To test this just make a movieclip on your stage and give it an instance name of "myBall"

you'll notice that the problem is, if you try to click and drag the movieclip again before the tween is completed finished, then it doesn't work.

How can you force a stop on a tween?

thank you so very much in advance!!!!

Tween Multiple MovieClips- Some Tween, Some Don't
Hello Kirupa,

here's the class i use:


Code:
package com.fornicode.tween {

import gs.TweenLite;
import flash.text.TextField;
import com.fornicode.utils.*;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.Event;

public class MultiTween {

var $objList:Array = new Array();

public function MultiTween($target, $duration, $vars:Object)
{
for each ( var $obj:MovieClip in $target ) {
var $props:Array= new Array();
$props["x"] = $obj.x;
$props["y"] = $obj.y;
$props["alpha"] = $obj.alpha;
$props["scaleX"] = $obj.scaleX;
$props["scaleY"] = $obj.scaleY;
$props["rotation"] = $obj.rotation;
$props["width"] = $obj.width;
$props["height"] = $obj.height;
$props["obj"] = $obj;
$objList[$obj.name] = $props;
$vars.onComplete =this.tracer;
$vars.onCompleteParams = new Array($props["obj"]);
$vars.persist = true;
TweenLite.killTweensOf($props["obj"], true);
}

for each (var $obj_t in $objList)
{
TweenLite.to($obj_t["obj"] , $duration, $vars);
}
}
public function backToOrigin($duration, $ease)
{
for each ( var $obj_r:Object in $objList ) {
TweenLite.to($obj_r["obj"], $duration, { ease: $ease });
}
}
}
}
all i do is pass an array of movieClips and some tweenLite vars to it, and it should do a mass-tweenLite move to all clips. the problem is only two of eight clips actually "mass-move" the others do nothing. I've exhausted my scope of actionscript. I've tested all sorts of angles: linkage-all the same; "export to first frame" - all the same; tweenlite vars ( killTweensOf all clips before running, persist=true to all). All mc's are place on the stage.

any ideas whatsoever? Thank you in advance to whomever answers!

Tween Class & Button Class
Sorry I accidently made two threads.. can this be deleted please??

OnRollOver Event Of Parent MC Preventing OnRollOver Of Child
I have a movieClip, which in turn has a nested movieClip. I need each of these to have thier own onRollOver events, the parent movieClip is OK, but the event never fires for the nested movieClip. Can anyone think of a workaround?

My code goes something like this:


Code:

attachMovie("mcOne", "mcOne", 100);
mcOne._x = 20;
mcOne._y = 20;
mcOne.onRollOver = function(){
trace("hi");
};
mcOne.attachMovie("mcTwo", "mcTwo", 100);
mcOne.mcTwo.onRollOver = function(){
trace("bye");
};
"hi" is output when mcOne is rolled over, as it should, but nothing is output when mcTwo is moused over.

Tween Class
for some reason i can not get the alpha to fade out a dynamic text box

attached it the .fla

just run, and click the box in the centre (bottom left is simple for test purposes)

[f8]Using The Tween Class
Hi everyone


I have this script

PHP Code:



import mx.transitions.Tween;
import mx.transitions.easing.*;

var myRan:Number = (Math.random()*15000)+10000;
var firstRandom:Number = 290;
var secondRandom:Number = (Math.random()*370)+50 ;

setInterval(movePlayer,myRan);
movePlayer = function(){
    var yScaleT:Tween = new Tween("musicPlayer", "_y", Elastic.easeOut , firstRandom, secondRandom, 1.5, true);
    firstRandom = secondRandom;
    secondRandom = (Math.random()*370)+50 ;
    myRan = (Math.random()*15000)+10000;
    setInterval(this,myRan);
}




Basically what I want it to do is:
after [10 + random amount]seconds it should call up the function movePlayer
this function tweens the _y of the instance musicPlayer.
At first, the _y should start at 290(firstRandom) and move to a random number between 50 and 420(secondRandom). Then, firstRandom gets the value of where it is right now, and another secondRandom is being defined.
Then, the function does a setInterval on itself, again with [10 + random amount]seconds.

Now, what am I doing wrong? Any sort of syntax error? Logic error?
Please help
Thanks

[AS3] Tween Class Bug?
I have a problem with the Tween Class that I do not understand.

If I put several tweens in a loop - rewind and start them again -
they suddenly stop(!!) after a while (about 10 sec).
http://www.coldminer.com/nwf/test/test1.php

But when I put the code in an extended Sprite Class with the
DisplayObject everything works as expected.
http://www.coldminer.com/nwf/test/test2.php

Ok, "problem solved", but why is this? I don't understand.
Is it a bug, or am I doing it wrong?
It works in AS2 (Test 3).
http://www.coldminer.com/nwf/test/test3.php

Code is available on the examples

Anyone?

Copyright © 2005-08 www.BigResource.com, All rights reserved