SunQuest
           Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 15th, 2003, 11:54 PM
wyclef wyclef is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 7 wyclef User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
delete onEnterFrame

is this the correct use of delete onenterFrame?


a_mc.onEnterFrame = function(){
moveEm(a_mc, 55);
if(moveEm(a_mc, 55);{
delete (this.onEnterFrame);
};
b_mc.onEnterFrame = function() {
moveEm(b_mc, 60);
if(moveEm(a_mc, 55);{
delete (this.onEnterFrame);
};
c_mc.onEnterFrame = function() {
moveEm(c_mc, 70);
if(moveEm(a_mc, 55);{
delete (this.onEnterFrame);
};
d_mc.onEnterFrame = function() {
moveEm(d_mc, 75);
if(moveEm(a_mc, 55);{
delete (this.onEnterFrame);
};
function moveEm(who, howMuch) {
Xsquare = who._x;
Xdiff = who.Xpos-Xsquare;
Xmove = Xdiff/howMuch;
who._x = Xsquare+Xmove;
}

Reply With Quote
  #2  
Old May 18th, 2003, 12:42 PM
freddydoesphp freddydoesphp is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2000
Posts: 669 freddydoesphp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Well I think you should omit the () are you getting some kind of error or somethin, or just asking?

PHP Code:
 delete this.onEnterFrame

Reply With Quote
  #3  
Old May 18th, 2003, 01:00 PM
wyclef wyclef is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 7 wyclef User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well, i've actually updated the code since then, maybe you could take a look at the updated script and see if you think it can be made more efficient.



function moveEm(who, howMuch) {
Xsquare = who._x;
Xdiff = who.Xpos-Xsquare;
Xmove = Xdiff/howMuch;
who._x = Xsquare+Xmove;
if (Math.ceil(Xmove) == 0)
return 1;
}

a_mc.val = 9;
b_mc.val = 12;
c_mc.val = 15;


nav.btn_00.onRelease = function() {
_root.a_mc.Xpos = 0;
_root.b_mc.Xpos = 0;
_root.c_mc.Xpos = 0;
_root.a_mc.onEnterFrame = moveA;
_root.b_mc.onEnterFrame = moveB;
_root.c_mc.onEnterFrame = moveC;
loadMovie("xx.swf", "_root.movieclip");
};
nav.btn_01.onRelease = function() {
_root.a_mc.Xpos = -764;
_root.b_mc.Xpos = -484;
_root.c_mc.Xpos = -240;
_root.a_mc.onEnterFrame = moveA;
_root.b_mc.onEnterFrame = moveB;
_root.c_mc.onEnterFrame = moveC;
loadMovie("xx.swf", "_root.movieclip");
};
nav.btn_02.onRelease = function() {
_root.a_mc.Xpos = -1527;
_root.b_mc.Xpos = -968;
_root.c_mc.Xpos = -480;
_root.a_mc.onEnterFrame = moveA;
_root.b_mc.onEnterFrame = moveB;
_root.c_mc.onEnterFrame = moveC;
loadMovie("xx.swf", "_root.movieclip");
};
nav.btn_03.onRelease = function() {
_root.a_mc.Xpos = -2290;
_root.b_mc.Xpos = -1452;
_root.c_mc.Xpos = -720;
_root.a_mc.onEnterFrame = moveA;
_root.b_mc.onEnterFrame = moveB;
_root.c_mc.onEnterFrame = moveC;
loadMovie("xx.swf", "_root.movieclip");
};
nav.btn_04.onRelease = function() {
_root.a_mc.Xpos = -3053;
_root.b_mc.Xpos = -1936;
_root.c_mc.Xpos = -960;
_root.a_mc.onEnterFrame = moveA;
_root.b_mc.onEnterFrame = moveB;
_root.c_mc.onEnterFrame = moveC;
loadMovie("xx", "_root.movieclip");
};
nav.btn_05.onRelease = function() {
_root.a_mc.Xpos = -3816;
_root.b_mc.Xpos = -2420;
_root.c_mc.Xpos = -1200;
_root.a_mc.onEnterFrame = moveA;
_root.b_mc.onEnterFrame = moveB;
_root.c_mc.onEnterFrame = moveC;
loadMovie("xx", "_root.movieclip");
};

function moveA()
{
rtnValue = _root.moveEm(_root.a_mc, _root.a_mc.val);
if (rtnValue == 1)
{
trace("Deleting this.onEnterFrame " + this._name);
delete this.onEnterFrame;
}
}

function moveB()
{
rtnValue = _root.moveEm(_root.b_mc, _root.b_mc.val);
if (rtnValue == 1)
{
trace("Deleting this.onEnterFrame " + this._name);
delete this.onEnterFrame;
}
}

function moveC()
{
rtnValue = _root.moveEm(_root.c_mc, _root.c_mc.val);
if (rtnValue == 1)
{
trace("Deleting this.onEnterFrame " + this._name);
delete this.onEnterFrame;
}
}

Reply With Quote
  #4  
Old May 18th, 2003, 01:04 PM
freddydoesphp freddydoesphp is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2000
Posts: 669 freddydoesphp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Could you give me some background on what the code does? Its hard to tell because there are no comments or sample .fla.

Reply With Quote
  #5  
Old May 18th, 2003, 01:20 PM
wyclef wyclef is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 7 wyclef User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Basically,

there are 3 super long bitmap files a_mc, b_mc, and c_mc and when you click on btn_00, btn_01, btn_02, btn_03, btn_04, and btn_05 these bitmaps move to a designated _x position at different speeds. On slower computers this kills the processor so i've been trying to figure out how to one. delete onEnterframe in the most efficient manner, and just see if there is a way to help the script work better.

Reply With Quote
  #6  
Old May 19th, 2003, 10:18 AM
wyclef wyclef is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 7 wyclef User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
any ideas? i'd really like to make this script as efficient as possible and I suspect this is a very inefficient script.

Reply With Quote
  #7  
Old June 11th, 2003, 04:23 PM
mbritton72 mbritton72 is offline
Shrill Digital God
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Raleigh, NC
Posts: 64 mbritton72 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m
Reputation Power: 8
Maybe this will help

Based on your code, I created something that should give you a few ideas. It isn't necessarily the ideal scenario, but it will give you ideas for more reusable code.

Also, I recommend Robert Penner's easing equations for actionscript-based movement.

hth,

Mike Britton

On Stage (instance names):
mc0, mc1, mc2
btn0, btn1, btn2

Code:
var mcVals = ["9", "12", "15"];

this.moveEm = function(mc, howMuch) {
	trace("movEm hit.");
	Xsquare = _root[mc]._x;
	_root[mc].Xpos = getXpos(mc);
	Xdiff = _root[mc].Xpos-Xsquare;
	Xmove = Xdiff/howMuch;
	_root[mc]._x = Xsquare+Xmove;
	if (Math.ceil(Xmove) == 0)
		return 1;
};

this.buttonCommands = function(mc, btn, pos) {
	_root[btn].onRelease = function() {
		var pos = getXPos(pos);
		_root[mc].onEnterFrame = function() {
			var rtnValue = moveEm(mc, pos);
			if (rtnValue == 1) {
				delete _root[mc].onEnterFrame;
			}		
		}
	};
};

this.getXPos = function(p) {
	if (p == 0) {
		Xpos = 20;
	} else if (p == 1) {
		Xpos = 10*p;
	} else if (p == 2) {
		Xpos = 5*p;
	} else {
		Xpos = 0;
	}
	return Xpos;	
};

// Usage:
for (i=0; i<mcVals.length; i++) {
	var mc = "mc"+i;
	var btn = "btn"+i;
	var pos = i;
	buttonCommands(mc, btn, pos);
}
__________________
I'm not impatient, I just have a low tolerance for boredom.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > delete onEnterFrame


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway