Need someone to correct my code
- Senhorze
-
Senhorze
- Member since: Dec. 10, 2012
- Offline.
-
- Forum Stats
- Member
- Level 04
- Animator
Hey, I'm really embarassed about this but I need help with my code. Well it's not actually mine, a friend gave me his base and I just messed around with it, it worked fine once here but it's giving me a lot of errors now, and I swear I didn't touch it. Could someone please help me debug it? Just contact me and I'll send you the FLA. Thanks in advance
- Diki
-
Diki
- Member since: Jan. 31, 2004
- Online!
-
- Forum Stats
- Moderator
- Level 13
- Programmer
Why don't you just post the code in this thread? If you post it here you will get more eyes on it, and therefore will be more likely to receive help.
- Senhorze
-
Senhorze
- Member since: Dec. 10, 2012
- Offline.
-
- Forum Stats
- Member
- Level 04
- Animator
At 12/4/13 08:48 PM, Diki wrote: Why don't you just post the code in this thread? If you post it here you will get more eyes on it, and therefore will be more likely to receive help.
yes I tought about that but I really don't know what the problem is, and there are two .as files but the output says the errors are on the implicit imports which I have no idea on how to fix. I'm really tempted to just start over from scratch tho.
I'll post them anyway, why not?
LOAD.as
package src {
import flash.display.Stage;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Load {
public var movieClip:Load_mc
private var mainStage:Stage;
private var bytesLoaded:Number;
private var bytesTotal:Number;
private var initialBytes:Number;
public function Load(load_mc:Load_mc, mainStage:Stage) {
movieClip = load_mc;
this.mainStage = mainStage;
movieClip.gotoAndStop(1);
movieClip.barmc.gotoAndStop(1);
bytesTotal = mainStage.loaderInfo.bytesTotal/1024;
initialBytes = 0;
}
public function enterFrameHandler(event:Event):void{
bytesLoaded = mainStage.loaderInfo.bytesLoaded/1024;
if(initialBytes == 0){
initialBytes = bytesLoaded;
}
var percent:int = int((bytesLoaded-initialBytes)/(bytesTotal-initialBytes)*100);
if (percent < 100)
{
movieClip.barmc.gotoAndStop(percent);
}
else
{
movieClip.barmc.gotoAndStop(100);
}
if(bytesLoaded >= bytesTotal && Main.animState != "load finished"){
movieClip.gotoAndStop(2);
Main.animState = "load finished";
movieClip.playBtn.addEventListener(MouseEvent.MOUSE_UP, function onMouseUpHandler(event:MouseEvent){
Main.animState = "play";
})
}
}
}
}
MAIN.as
package src {
import flash.display.MovieClip;
import flash.events.Event;
public class Main extends MovieClip {
public static var animState:String = "loading";
private var load:Load;
private var nextscene:int;
public function Main() {
nextscene=60;
gotoAndStop(1);
load = new Load(Load_mc(load_mc), stage);
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function enterFrameHandler(event:Event):void{
if(Main.animState == "loading"){
load.enterFrameHandler(event);
}else if(Main.animState == "play"){
if(currentFrame < nextscene){
play();
}else{
stop();
nextbtn.addEventListener(MouseEvent.MOUSE_UP, function onMouseUpHandler(event:MouseEvent){
play();
if(currentFrame == nextscene){
nextscene+= 60;
}
})
replaybtn.addEventListener(MouseEvent.MOUSE_UP, function onMouseUpHandler(event:MouseEvent){
nextscene = 60;
gotoAndStop(59);
})
}
}
}
}
}
- Diki
-
Diki
- Member since: Jan. 31, 2004
- Online!
-
- Forum Stats
- Moderator
- Level 13
- Programmer
At 12/4/13 09:09 PM, Senhorze wrote: yes I tought about that but I really don't know what the problem is, and there are two .as files but the output says the errors are on the implicit imports which I have no idea on how to fix. I'm really tempted to just start over from scratch tho.
What are the exact errors? Post them as well.
And if you could re-post that code inside the code tags that would help a lot too; the code tags preserve formatting. The message to the left of the text input box explains what the code tags are if you don't know what I'm talking about (basically just replace the em tag you wrapped your code in with code).
If I had to guess I'd say it's because you're not importing the Load_mc class.
- Senhorze
-
Senhorze
- Member since: Dec. 10, 2012
- Offline.
-
- Forum Stats
- Member
- Level 04
- Animator
At 12/4/13 09:23 PM, Diki wrote:At 12/4/13 09:09 PM, Senhorze wrote: yes I tought about that but I really don't know what the problem is, and there are two .as files but the output says the errors are on the implicit imports which I have no idea on how to fix. I'm really tempted to just start over from scratch tho.What are the exact errors? Post them as well.
And if you could re-post that code inside the code tags that would help a lot too; the code tags preserve formatting. The message to the left of the text input box explains what the code tags are if you don't know what I'm talking about (basically just replace the em tag you wrapped your code in with code).
If I had to guess I'd say it's because you're not importing the Load_mc class.
My bad!
package src {
import flash.display.Stage;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Load {
public var movieClip:Load_mc
private var mainStage:Stage;
private var bytesLoaded:Number;
private var bytesTotal:Number;
private var initialBytes:Number;
public function Load(load_mc:Load_mc, mainStage:Stage) {
movieClip = load_mc;
this.mainStage = mainStage;
movieClip.gotoAndStop(1);
movieClip.barmc.gotoAndStop(1);
bytesTotal = mainStage.loaderInfo.bytesTotal/1024;
initialBytes = 0;
}
public function enterFrameHandler(event:Event):void{
bytesLoaded = mainStage.loaderInfo.bytesLoaded/1024;
if(initialBytes == 0){
initialBytes = bytesLoaded;
}
var percent:int = int((bytesLoaded-initialBytes)/(bytesTotal-initialBytes)*100);
if (percent < 100)
{
movieClip.barmc.gotoAndStop(percent);
}
else
{
movieClip.barmc.gotoAndStop(100);
}
if(bytesLoaded >= bytesTotal && Main.animState != "load finished"){
movieClip.gotoAndStop(2);
Main.animState = "load finished";
movieClip.playBtn.addEventListener(MouseEvent.MOUSE_UP, function onMouseUpHandler(event:MouseEvent){
Main.animState = "play";
})
}
}
}
}
package src {
import flash.display.MovieClip;
import flash.events.Event;
public class Main extends MovieClip {
public static var animState:String = "loading";
private var load:Load;
private var nextscene:int;
public function Main() {
nextscene=60;
gotoAndStop(1);
load = new Load(Load_mc(load_mc), stage);
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function enterFrameHandler(event:Event):void{
if(Main.animState == "loading"){
load.enterFrameHandler(event);
}else if(Main.animState == "play"){
if(currentFrame < nextscene){
play();
}else{
stop();
nextbtn.addEventListener(MouseEvent.MOUSE_UP, function onMouseUpHandler(event:MouseEvent){
play();
if(currentFrame == nextscene){
nextscene+= 60;
}
})
replaybtn.addEventListener(MouseEvent.MOUSE_UP, function onMouseUpHandler(event:MouseEvent){
nextscene = 60;
gotoAndStop(59);
})
}
}
}
}
}
All errors are implicit imports:
implicitImports, Line 1 1172: Definition __AS3__.vec:Vector could not be found.
implicitImports, Line 2 1172: Definition flash.desktop could not be found.
implicitImports, Line 10 1172: Definition flash.globalization could not be found.
implicitImports, Line 13 1172: Definition flash.net.drm could not be found.
implicitImports, Line 17 1172: Definition flash.sensors could not be found.
implicitImports, Line 20 1172: Definition flash.text.ime could not be found.
implicitImports, Line 21 1172: Definition flash.text.engine could not be found.
- MSGhero
-
MSGhero
- Member since: Dec. 15, 2010
- Offline.
-
- Forum Stats
- Supporter
- Level 16
- Game Developer
At 12/4/13 09:37 PM, Senhorze wrote: All errors are implicit imports:
implicitImports, Line 1 1172: Definition __AS3__.vec:Vector could not be found.
You're targeting flash player 9. We're at 11.9 now. All of that stuff was added in flash player 10-10.2ish.
- Senhorze
-
Senhorze
- Member since: Dec. 10, 2012
- Offline.
-
- Forum Stats
- Member
- Level 04
- Animator
At 12/4/13 09:54 PM, MSGhero wrote:At 12/4/13 09:37 PM, Senhorze wrote: All errors are implicit imports:You're targeting flash player 9. We're at 11.9 now. All of that stuff was added in flash player 10-10.2ish.
implicitImports, Line 1 1172: Definition __AS3__.vec:Vector could not be found.
Thanks a lot, that helps. Now I just need to find out how to fix it.
- kkots
-
kkots
- Member since: Apr. 16, 2013
- Offline.
-
- Forum Stats
- Supporter
- Level 10
- Blank Slate
At 12/5/13 07:04 AM, Senhorze wrote: Thanks a lot, that helps. Now I just need to find out how to fix it.
Go to File-->Publish Settings (Ctrl+Shift+F12 hotkey), then go to "Flash" tab and set the Flash Player version there. You must be using CS5 (might not work) or CS6 (will work) or Flash CC (will work).
- Senhorze
-
Senhorze
- Member since: Dec. 10, 2012
- Offline.
-
- Forum Stats
- Member
- Level 04
- Animator
At 12/5/13 09:26 AM, kkots wrote:At 12/5/13 07:04 AM, Senhorze wrote: Thanks a lot, that helps. Now I just need to find out how to fix it.Go to File-->Publish Settings (Ctrl+Shift+F12 hotkey), then go to "Flash" tab and set the Flash Player version there. You must be using CS5 (might not work) or CS6 (will work) or Flash CC (will work).
Just downloaded a CS6 trial, tried that and it just won't work. I have no idea what to do, sorry for taking everyone's time.
- Senhorze
-
Senhorze
- Member since: Dec. 10, 2012
- Offline.
-
- Forum Stats
- Member
- Level 04
- Animator
Go to File-->Publish Settings (Ctrl+Shift+F12 hotkey), then go to "Flash" tab and set the Flash Player version there. You must be using CS5 (might not work) or CS6 (will work) or Flash CC (will work).Just downloaded a CS6 trial, tried that and it just won't work. I have no idea what to do, sorry for taking everyone's time.
Actually had to import a xml file. I had no idea it was that. Thanks a lot for everyone's help!
- Sam
-
Sam
- Member since: Oct. 1, 2005
- Offline.
-
- Forum Stats
- Moderator
- Level 19
- Programmer
At 12/5/13 09:41 AM, Senhorze wrote: Just downloaded a CS6 trial, tried that and it just won't work. I have no idea what to do, sorry for taking everyone's time.
It should have worked if you targeted the correct Flash player version.
At 12/5/13 09:53 AM, Senhorze wrote: Actually had to import a xml file. I had no idea it was that. Thanks a lot for everyone's help!
Could you elaborate? It might help someone else with the same problem!
- Senhorze
-
Senhorze
- Member since: Dec. 10, 2012
- Offline.
-
- Forum Stats
- Member
- Level 04
- Animator
Actually had to import a xml file. I had no idea it was that. Thanks a lot for everyone's help!Could you elaborate? It might help someone else with the same problem!
I think it was something stupid I might have done, altought I can't really put my finger on it. Might have something to do with switching flash versions.
What I did was just go into the publish settings and import the "default" profile for the "publish profile". There was just no profile there before that.
Sounds really stupid when you think about it, but I've been going crazy trying to figure out what was wrong for weeks now.
- Knight52
-
Knight52
- Member since: Jan. 8, 2012
- Offline.
-
- Forum Stats
- Member
- Level 07
- Game Developer
Can you ask your friend for another copy? You haven't touched the code, right? So instead of getting this headache, you can just start over since the code itself hasn't changed.

