-
[RESOLVED] Flash 8 AS2 deleting a function possible?
Hey!
I'm working on a game where once i have all my moviClips set, I want to jump to the game playing frame, but I can't come up with a way to delete the function that places them in the startup frame.
My code is included in a function that enables dragging the players named placePlayers(), but when I manage to get to the game frame, the movieClips are still draggable which is what I need to avoid before trying to program the real game.
this is the code to place the players in first frame:
for (i=0; i<6; i++) {
this.attachMovie("botoBarça", "botoBarça"+i, this.getNextHighestDepth());
this.attachMovie("botoValencia", "botoValencia"+i, this.getNextHighestDepth());
this["botoBarça"+i]._x = 100+i*56;
this["botoBarça"+i]._y = 28;
this["botoValencia"+i]._x = 450+i*56;
this["botoValencia"+i]._y = 28;
_root["botoBarça"+i].onPress = function() {
dragging = true;
startDrag(this);
};
_root["botoBarça"+i].onRelease = _root["botoBarça"+i].onReleaseOutside=function () {
dragging = false;
stopDrag();
if (eval(this._droptarget) == areaPetitaN || camp) {
positionPlayersBarça++;
if (positionPlayersBarça>=7) {
localReady_btn._visible = true;
}
}
};
this is the code on clicking the ready button:
this.visitorReady_btn.onPress = function(){
visitorReady = true;
if(localReady == true && visitorReady == true){
dragging = false;
delete placePlayers(); // this is what I thought worked.
gotoAndStop("game");
}
}
this.localReady_btn.onPress = function(){
localReady = true;
if(localReady == true && visitorReady == true){
dragging = false;
delete placePlayers(); // this is what I thought worked. gotoAndStop("game");
}
}
I include the swf for better explanation... drag all the players to their respective side of the field before jumping to the game frame.
Last edited by capdetrons; 02-21-2012 at 01:46 PM.
Reason: poor post
-
ism
try;
Code:
delete placePlayers
instead of;
Code:
delete placePlayers()
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
thanks, but it doesn't work
Thanks for the reply, Blink.
I managed to rename the movieclips on the game frame and that way it works for me but I have the feeling there has to be a cleaner way to achieve the same result. A class perhaps, if deleting the function can't be done.
Thanks anyway...
-
ism
an explanation;
when you code the statement like this;
Code:
delete placePlayers();
what you are asking the compiler to do is first execute the function, then delete the return value of the function (which in this case is probably nothing).
when you code the statement like this;
Code:
delete placePlayers;
you are asking the compiler to delete the function.
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Thanks, BlinkOk,
will have to try again... That's what I had read in the AS Bible, but it doesn't work. My players are still draggable in the game frame and the drag function is embedded in the placePlayers function. Shouldn't it all be deleted?I'm attaching the fla, this time.
You need to drag the players onto your respective fields as well as the goalies before the ready button pops up.
-
ism
thats not how it works. you have to disable all the onPress/OnRelease functions as well.
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
How would that be done? A mouse listener event?
-
Pumpkin Carving 2008
Rather than defining the function in-line at the onPress/onRelease level, I think it would make more sense to var onPressFunc = function(){ } and onReleaseFunc = function() {}.
Then simply assign to the onPress/release as btn.onPress = onPressFunc. When you want to stop using the function, onPressFunc = null or delete onPressFunc. Should do what you're after.
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|