Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Here Again

Status
Not open for further replies.

Tyekai

Programmer
Dec 2, 2008
14
US
Ok so our next project is to make a slide show
We need to have a button for each of the following things:
Next
Previous
Auto Play [plays through the show by itself based on a time delay]
Stop [stops the Auto Play]

Each slide is just supposed to be an image and I made my code a bit more basic because of it [I think]

So I went to my sketchbook and wrote in some code
I just want to know if there is anything wrong with it.
I can't type it into Flash cause I don't have the program outside of class.
Anyway, here's what I tried.

//Keep in mind I don't know how to declare variables



bool autoPlay = false; // or will this not work?
int frame = 1;
int delay = 100;


nextButton.addEventListener(MouseEvent.CLICK, nextFrame);

function nextFrame(event)
{
if(frame <= 9)
{
autoPlay = false;
delay = 100;
frame = frame + 1; //is there a ++ or -- thing like in java?
gotoAndStop(frame);
}
}


previousButton.addEventListener(Mouse.Event.CLICK, playPrev);

function playPrev(event)
{
if(frame >= 2)
{
autoPlay = false;
delay = 100;
frame = frame - 1;
gotoAndStop(frame);
}
}


autoButton.addEventListner(MouseEvent.CLICK, autoPlayFunc);

function autoPlayFunc(event)
{
autoPlay = true;
while(autoPlay == true)
{
while(delay > 0)
{
stop();
delay = delay - 1;
}
frame = frame + 1;
gotoAndStop(frame);
}
}


stopButton.addEventListener(MouseEvent.CLICK, stopAuto);

function stopAuto(event)
{
autoPlay = false;
delay = 100;
}
 
Grr... I missed this during my preview post...

After "gotoAndStop(frame);" in autoPlayFunc
I need to reset the delay

simply
delay = 100; //correct?
 
Ok so...
I put the code in and run it
Gave me this error
1024: Overriding a function that is not marked for override.

I googled it
And it told me this:
If a method in a class overrides a method in a base class, you must explicitly declare it by using the override attribute, as this example shows:

public override function foo():void{};



So I did that and it gave me yet another error...
1114: The public attribute can only be used inside a package.


Which really means nothing to me since I have no idea how the package and class system work in AS3

Any help is appreciated
 
It means the word "public" can only be used within a class document, not on the timeline.

By the way things like [tt]bool autoPlay = false;[/tt] are all wrong. It's [tt]var autoPlay:Boolean;[/tt]

You'd better read some AS3 documentations, or you'll waste a lot of time ;)

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top