Copy link to clipboard
Copied
I am at my wits end! I have tried everything to get this code to work, I bought this book because it had a very good review, and have done everything I can to get the code and content to match whats in the book. I have only made two major modifications and even when I remove them the code fails. I will go over the code and my changes, as well as the few actual reported errors, mostly it just fails to work and doesn't report why...
Opening code:
Class code: the book is meant for use with photoshop and flash builder, I am using Animate, but at this point I am trying everything to get the code flawless. I have the three embed files checked export for runtime sharing, and the url matches. The difference here is the symbol code is not in my book, as the import is from a direct image, also a big change is I change BetterScrolling extends Sprite, to extends MovieClip. This is because I need the Character image to change position when the player moves. right and left.
next section: this defines the locations of the objects. IDK if its needed other than the Inner Boundaries and event listeners... I'd love to know how to define the inner boundaries with exact pixels...
these are the Key handlers and where a major change comes in: I placed frame labels on the inside of the movie clip Character, contained within are additional movie clips with space to play under each frame label, or a stop(); on top to hold it in place.
enter frame handler: I have never gotten the VX or VY code to ever work int the past. I've used substitute codes like speed codes to work instead. That it seems that the inner boundaries don't seem to be taking...
apologies for this being very long, but I can't even address the errors, since it seems it wont tell me them unless I put the code in the main file rather than a action script class file and try to export. I really hope someone can help, Ive been asking over at stack overflow and they seem to have much more about java, and I just can't find the answers I need there.
I think you're adapting a Class file to work in the timeline, which is ok, but if you are your code has extra lines. This part
{
function BetterScrolling() {
look like the beginning of a BetterScrolling class. Those lines wouldn't be needed in the timeline.
Copy link to clipboard
Copied
It can be tricky adapting Flash Builder code for Flash Pro or Adobe Animate.
You have several lines where it says Embed(sorce="some path, etc. Should those be 'source=' and not 'sorce='?
Copy link to clipboard
Copied
Thank you that helped me with the embed code, but now its giving me this error, "Source path yada yada, does not have a recognized extension and a mimeType was not provided." I have no idea what a mimeType is or what has to do with this, do you know where can I look that up? (or even better just know what it is?)
Copy link to clipboard
Copied
Look at the example code you were given to make sure the embed path lines are correct.
Or, manually import the images you need into the Library. Flash Builder works that way because it doesn't have a Library, but Animate does. If you can get the images into the Library you can either place them yourself or use code to place them. Either way it's easier that using embed code.
Copy link to clipboard
Copied
If the images are in the Library, which they are, how can I address them in the code, by instance name?
Copy link to clipboard
Copied
If they are to be movieclips you could drag the image onto the stage and use Modify/Convert to Symbol to make it be a movieclip. Then in Properties you can give it an instance name.
Copy link to clipboard
Copied
Thanks, my current code is here: [ActionScript 3] current scroller code - Pastebin.com It yields no errors but still does not work. I have no idea why still. All mentions of the imports or embed work have been removed, as that can be done on the stage. I also added a code to attempt to focus the event listeners, but they still do not run... hum.... does it mater that I have objects on multiple layers or that the layers are locked when I export them?
Copy link to clipboard
Copied
I think you're adapting a Class file to work in the timeline, which is ok, but if you are your code has extra lines. This part
{
function BetterScrolling() {
look like the beginning of a BetterScrolling class. Those lines wouldn't be needed in the timeline.
Copy link to clipboard
Copied
Removing these lines made the code work! This and some other edits I made after inspecting it over and over here is the final code: [ActionScript 3] WORKING scroller demo - Pastebin.com and a demo game: Scroller demo 1 - mars714's Sta.sh its laggy but I think if i modify it to be a class again that might fix it. other problems exist, like the character changing direction, but I think thats with the characters timeline....
Copy link to clipboard
Copied
The lagginess won't be any different just by making it be a class file.
You have three problems in your code:
You're only checking the background position if the character has gone too far right. You should put that checking code outside of the check for whether the character has reached the edges.
When going right you test for it being at the edge by adding the width, but the character is animating, so its width is changing. You may have noticed that scrolling is smoother going left. I would just hard code in a value instead of using the character's width.
In a couple of places you are going to labels "ILDEL" and "ILDER". Those are typos, the labels are really IDLEL and IDLER.
Copy link to clipboard
Copied
I fixed the last two, but the first one I am unsure of how to fix, I'm going to read more in my book, I took a break from reading forward and just went over the existing code when I failed to get it working. The next chapter is about object collision, but they might expand on existing code. Even if not it will help me understand more of this particular game code. Thanks for helping me adapt it. If you have any ideas for changing it to check the edges, that be awesome too.
Copy link to clipboard
Copied
In the version you posted, [ActionScript 3] WORKING scroller demo - Pastebin.com
moving the close brace from line 95 to line 76 would do what I'm suggesting. That way the foreground position is checked if the character is moving left, not just if they are moving right.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now