PDA

View Full Version : I know what the problem is... and thats why i feel dumb lol



ultrapyro
October 14th, 2008, 07:57 AM
hey I have just started using the document class and I am now migrating towards full OOP w/no timeline this week. Its not easy though, and I'm beginning to have some problems that I am bumping into. I understand that this is a custom class, so I must import everything I use, and declare everything public/private etc... but I can't seem to figure out why I keep getting this error



line 22 - 1046: Type was not found or was not a compile-time constant: Event
Am I forgetting to import an event?




package
{
import flash.display.MovieClip;
import fl.transitions.easing.*;
import flash.events.Event.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;

public class SpaceSciro extends MovieClip
{
public function SpaceSciro():void
{
trace("Con-FUNCTION - SpaceSciro - Document Class 1.0 has been loaded!");

this.stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.align = StageAlign.TOP_LEFT;
this.stage.addEventListener(Event.ENTER_FRAME, onStageResize);
}

private function onStageResize(e:Event):void
{
trace("Pri-FUNCTION - onStageResize - hello world");
}
}
}
thank you! for taking the time to help me:sonic::sonic::sonic:

Magik5
October 14th, 2008, 08:06 AM
import flash.events.Event.*;

should be

import flash.events.Event;

or just

import flash.events.*;

ultrapyro
October 14th, 2008, 08:17 AM
I Think that worked, however now I am getting this



line- 17- 1120: Access of undefined property StageScaleMode.
line- 18- 1120: Access of undefined property StageAlign.


Am I addressing the stage correctly? what is the correct way to reference the stage.


you rule, thank you for your help

ViktorHesselbom
October 14th, 2008, 08:42 AM
Yes, you are reffering the stage property correctly. The error you're getting is because you're trying to access static properties of those classes (StageScaleMode and StageAlign are not inherited properties).

The solution is of course to import those classes aswell:

import flash.display.StageScaleMode;
import flash.display.StageAlign;

Magik5
October 14th, 2008, 08:47 AM
i find that when you start out with doc classes, importing .*s helps to avoid annoying errors like these, and as you ease into it, you can look up the help documents to find out exactly what classes you need to import.

for example, you have imported import flash.display.MovieClip;

which is great, but you also need to import flash.display.StageScaleMode to be able use it.

so starting out, import flash.display.*; which will give you access to all the classes within display.

this only increases compile time(slightly) but doesnt slow down your final swf/app

hope this makes sense =]

ViktorHesselbom
October 14th, 2008, 08:50 AM
@Magik5: It would also increase filesize. Not by much though so no worries. :)

I also highly reccomend using FlashDevelop for ActionScript development. It's a text editor for ActionScript (for both Flash and Flex [and recently haXe] development) sent from heavens. Trust me, it's worth it.

Why I bring FlashDevelop up is because if you use it's autocomplete feature when reffering a class it autoadds the import statement. Saves me alot of time and errors. :)

ultrapyro
October 14th, 2008, 08:20 PM
@Magik5: It would also increase filesize. Not by much though so no worries. :)

I also highly reccomend using FlashDevelop for ActionScript development. It's a text editor for ActionScript (for both Flash and Flex [and recently haXe] development) sent from heavens. Trust me, it's worth it.

Why I bring FlashDevelop up is because if you use it's autocomplete feature when reffering a class it autoadds the import statement. Saves me alot of time and errors. :):trout:Thank you!