AS3 and Insanity

I am having the worst problems. I am working on my final project for class and I thought it would be a great idea to add a Flash slideshow… Notsomuch. I have managed to get the code to where it actually stops the .swf from looping, but I have a whole new error when I click on my back and next buttons to nav through the images. The new error is:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@293d4089 to flash.display.MovieClip.
at Untitled_fla::MainTimeline/clickHandler2()

So, now that I want to curl up in the fetal position and die, can someone help me with this code?

[B]import flash.events.MouseEvent;
import flash.events.Event;

stop();
next_btn.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:Event):void
{
MovieClip(parent).nextFrame();
}

last_btn.addEventListener(MouseEvent.CLICK, clickHandler2);
function clickHandler2(event:MouseEvent):void
{
MovieClip(parent).prevFrame();
}[/B]

I have a single file and in that is all of the images. I haven’t ever coded anything like this before and I am feeling quite stupid not being able to figure it out.

I would appreciate any help at all. I have 24 hours to get this stupid thing done and I still have so much work to do…and a job. Over my head, here.

I will give that a shot… I work an hour from my house and that’s where I am now (lucky me), so I have to wait till tonight. do I put that right into my code or at the end? I appreciate the help…I definitely am in need.

Do a trace on MovieClip(parent) and see what it comes back as.


trace(MovieClip(parent))

For testing purpose’s replace your code with that below


import flash.events.MouseEvent;
import flash.events.Event;

stop();
next_btn.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:Event):void
{
 //MovieClip(parent).nextFrame();
trace(MovieClip(parent))
}
 

last_btn.addEventListener(MouseEvent.CLICK, clickHandler2);
function clickHandler2(event:MouseEvent):void
{
    //MovieClip(parent).prevFrame();
trace(MovieClip(parent))
}

OK…I will definitely give that a shot and see what happens. When I did the thing to start with, the instructions had me create my first symbol (after the background was complete) and then double click on that, opening the edit thing, then I added more frames with more images… I believe the instructions were in AS2 instead of AS3, so that got me jacked up to start with. Then I did a little research to find the right code for AS3. So I have the main part, then all of the images are inside that other area (forgive me for not knowing the best way to put this…terminology wise) and that other area is called content_mc… So I figured that I would have to put that somewhere, but when I tried, it still didn’t work, so I am assuming that I put it in wrong. I will try your code when I get home and see what happens.

Thinking I need to get out of here early today…Boss-man may not be happy. :slight_smile:

I did it and am still getting the same error. Too weird. Maybe I need to find another tutorial for this? LOL

Can you post the fla?

have you tried removing MovieClip(parent) and just calling nextFrame?

it looks like you are trying to cast the Stage as a MovieClip which doesn’t seem to be working so well… also, you might have a scope issue.

in AS2, the actionscript would be in the clicked button’s scope but in AS3 it applies to the main timeline (stage). tryjust doing:

Code:

import flash.events.MouseEvent;
import flash.events.Event;

stop();
next_btn.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:Event):void
{
nextFrame();
}

last_btn.addEventListener(MouseEvent.CLICK, clickHandler2);
function clickHandler2(event:MouseEvent):void
{
prevFrame();
}