Problem with this.onRelease = function()

  • Flerd
  • Newbie
  • Newbie
  • Flerd
  • Posts: 7
  • Loc: Sweden, Skåne

Post 3+ Months Ago

Hello every1 =)

As to start i'm quite new into actionscripts and i hope i'll get some help here!

To simplify things, i have scene 1 where i have 4 images as buttons(MC).
Inside every MC, I have converted the image to a graphic. There are 3 layers inside too, 1 that changes the alpha in a tween and 1 named actions.

Button 1, Action layer, frame 1:

stop ();

this.onEnterFrame = function(){
if(rewind == true){
prevFrame();
}
}

this.onRollOver = function(){
rewind = false;
play();
}


this.onRollOut = function(){
rewind = true;
}

this.onRelease = function(){
gotoAndPlay( 2 );
}

Button 2, Action Layer, Frame 1:

stop ();

this.onEnterFrame = function(){
if(rewind == true){
prevFrame();
}
}

this.onRollOver = function(){
rewind = false;
play();
}


this.onRollOut = function(){
rewind = true;
}

this.onRelease = function(){
gotoAndPlay( "2", 2 );
}



What i want is button two(MC) to take me to scene 2, where i have the same layout of layers and frames, MCs and so on, but another content, and play that.
What it does is running the content on scene 1, like it never goes too scene 2.
The content is a movieclip with text upon that also is converted into movieclip.

Try clicking the two last buttons instead of the second, the second won't describe my problem atm =) http://www.freewebs.com/flerd/main.html



and plx dont steal design :P took some time to do it :wink:


I'm thankful for any help at all,

BG Flerd
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

stop using scenes ... use movieclips instead.
click me
btw, i'm gonna steal your design ... it's awesome :P
  • Flerd
  • Newbie
  • Newbie
  • Flerd
  • Posts: 7
  • Loc: Sweden, Skåne

Post 3+ Months Ago

Thanks for the help but now I have encountered another problem =)

My intention is to reverse what happened on frame 2-50 if frame is on 50 and load 51(next buttons motion starts here) when i click on the next button. Also if i click on the same button again i want it to reverse what happened in frame 2-50, by that i mean go from 50 and load till 1.
What happends now is that frame 50 is still there when i press another button and just loads 51 as an overlay of 50.

The script i made for the button to just rewind is:

this.onRelease = function() {
_root.gotoAndPlay(2);
}
if(frame == "50") {
rewind = true;
};

this didnt work, and whats the script for it to rewind and load frame 51?

Any help is grateful!

I used frames instead of loading MCs.
If someone could help me understand how to load multiply MC in this.onRelease it would help alot or just tell me the solution to frames.

I added the above script to button1 and the follwing to button2:

this.onRelease = function() {
if (frame == 50)
rewind = true, _root.gotoAndPlay(51);
};


Now I'm still really a noob in ActionScript but i do my best =)

BR Flerd
  • Flerd
  • Newbie
  • Newbie
  • Flerd
  • Posts: 7
  • Loc: Sweden, Skåne

Post 3+ Months Ago

edited the scripts to:

this.onRelease = function() {
_root.gotoAndPlay(2);
}
if(frame == "50") {
rewind = true;
};

and

this.onRelease = function() {
_root.gotoAndPlay(51);
};


Now i was really stupid not to realize that i had to remove the frames on button1 layer under button2 to remove the overlay of button2 :P

And i think i just realized what i had to do. After frame 50, make 49 frames that does the "rewind" and then put button two after those.
Will it work?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

well, here you go.
for playing forward is simple:
Code: [ Select ]
this.onRelease = function()
{
  _root.gotoAndPlay(2);
}
  1. this.onRelease = function()
  2. {
  3.   _root.gotoAndPlay(2);
  4. }

what about the reverse? it sounds complicated. it sounds terrible. How could one reverse a movieclip? He cant :D
ah, just kidding, it's very possible.
so, in the button code:
Code: [ Select ]
var bForward = false;
this.onRelease = function()
{
    bForward = !bForward;
    if (bForward)
        _root.gotoAndPlay(2);
}

this.onEnterFrame = function()
{
  if (_root._currentframe >= 50 && bForward)
      bForward = false;

  if (!bForward && _root._currentframe!=1)
  {
    nPrevFrame = _root._currentframe - 1;
    _root.gotoAndStop(nPrevFrame);
    if (nPrevFrame < 1)
      bForward = true;
  }
}
stop();
  1. var bForward = false;
  2. this.onRelease = function()
  3. {
  4.     bForward = !bForward;
  5.     if (bForward)
  6.         _root.gotoAndPlay(2);
  7. }
  8. this.onEnterFrame = function()
  9. {
  10.   if (_root._currentframe >= 50 && bForward)
  11.       bForward = false;
  12.   if (!bForward && _root._currentframe!=1)
  13.   {
  14.     nPrevFrame = _root._currentframe - 1;
  15.     _root.gotoAndStop(nPrevFrame);
  16.     if (nPrevFrame < 1)
  17.       bForward = true;
  18.   }
  19. }
  20. stop();
  • Flerd
  • Newbie
  • Newbie
  • Flerd
  • Posts: 7
  • Loc: Sweden, Skåne

Post 3+ Months Ago

haha scared me the for a second ;P

well i got another sequence at onEnterFrame, it's for the mouseover thingy. Might complicate things a bit.. =(

this.onEnterFrame = function() {
if (rewind == true) {
prevFrame();
}


Otherwise, thanks for the help again =)
  • Flerd
  • Newbie
  • Newbie
  • Flerd
  • Posts: 7
  • Loc: Sweden, Skåne

Post 3+ Months Ago

http://www.freewebs.com/flerd/main.html

might help to see it all..

and 1 more thing.
the "buttons" im talking about are movieclips as i explain in my first post. thats why the code must be in the same frame(of what i know).
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

what do you mean by: code must be in the same frame?
same frame with what?

about the other onEnerFrame ... just copy paste the code from it inside my onEnterFrame and delete the second one.
  • Flerd
  • Newbie
  • Newbie
  • Flerd
  • Posts: 7
  • Loc: Sweden, Skåne

Post 3+ Months Ago

I could send you the .fla file, i think it's quite complicated to explain in words. That is if you have time ofcourse, don't want to waste your time =)
I'm at msn!

BR Flerd

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 4 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.