Flex :: Error : Classes Must Not Be Nested --> Actionscript?
Nov 23, 2009I write a actionscript fileIncludeMyFile.as :
package CustomComponent
{
public class IncludeMyFile extends Object[code]......
I write a actionscript fileIncludeMyFile.as :
package CustomComponent
{
public class IncludeMyFile extends Object[code]......
I'm trying to build a simple FLEX application. Unfortunately, I get '1131: Classes must not be nested.' errors even with the simples MXML .... the error pops out at the mx:Application openning tag: (I'm using PureMVC if it's important)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
[Code]....
I created a new Flash file (Actionscript 3) and pasted this code on the first frame:
ActionScript Code:
class TestClass1 extends Object {
public function identify() {
[Code].....
I get the error 1131: Classes must not be nested?
I am trying to compile one sample file in ActionScript 3.0 but it is show error:"1131: Classes must not be nested."[code]
View 6 RepliesI have created a simple class to change the color of a movie clip on the stage. The movie clip that I want to change the color of has 3 other movie clips nested inside of it. Here is the structure of the Movie Clip
[Code]...
I'm an intermediate AS2 coder starting to use better OOP practices. I have searched for the answer to this but have not found anything, perhaps because everyone else learned it a long time ago.It appears that classes which extend an MC which is contained inside a different MC do not run their constructor immediately after the containing MC is instantiated. Also this MC's methods are not immediately available. As a result I need to wait a bit, by using onLoad or another frame.Here is an illustration which I have made as slim as possible:
LIBRARY:
--Symbol with ID "ball", linked to AS2 class "Ball".
--Symbol with ID "box", linked to AS2 class "Box". This symbol contains an instance of "ball" which I dragged in there and gave an instance name "ball_0".
--Symbol with ID "launcher", linked to AS2 class "Launcher".[code].....
QUESTIONS: How can I fix this so that setB would work in the above example? I have found two workarounds but I wonder if there is another which feels less kludgy.
Solution A): As seen in the example, put into Ball an onLoad function (or maybe just its constructor) which then runs any initialization functions. As a result I need to store in the object some properties which the object can find in itself and use for initialization.
Solution B): Put the method call on a timeline frame after the frame in which the attachMovie is done.
At the heart of this question is, why can I set the ball's properties (as seen with setA) but not be able to call its methods successfully? On one hand, I can see that the thread is busy with the box's initialization and can't be expected to run ball's constructor right away, even though ball has been instanced. But on the other hand, I am actually calling a method of an instance which is obviously there, so shouldn't it have the common decency to do as I ask?
Bonus question is, is the fact that this does not work a bug in Flash AS2 or is it perfectly to be expected due to some CS common sense which I lack?Another bonus question is, is this a harebrained way to use Flash AS2 classes—linking symbols to AS2 classes which extend MovieClip (or which are subclasses of classes which themselves extend MovieClip), and using attachMovie to instance all of these MCs except the one "Launcher" which is the only thing on the .fla's stage? It's a cornerstone of my architecture so I'd like to know if this is utterly daft.
In my project I have to classes that inherit the MovieClip class. Then I create a movie clip and in the library I click on linkage and I set on AS2 class field the name of the first class. Inside this movie a create another movie clip and I set his AS2 class to the second class. The problem is, when I run the file the properties of the nested movie clip are not available for the parent. What a mean is that in the constructor of the first class I cannot acces the methods of the nested movie clip. Somehow I need the nested movie clip to be initialized first and then the parent.
View 1 RepliesFor some reason I can't get this nested set of functions to work, it executes the first tween and the tween invoked after motion of the first is finished but it doesn't ever get to the third!
ActionScript Code:
var t1:Tween=new Tween(p1,"rotationY",Strong.easeOut,90,0,50,false);
var t1x:Tween=new Tween(p1,"x",Strong.easeOut,-900,0,50,false);
t1.addEventListener(TweenEvent.MOTION_FINISH,onMotionFinished);
[Code].....
I am trying to create a gallery. I am having a problem coding the document class for a menu window ("galleryPane"), which is to be called into the Main class at runtime. In particular, I am encountering problems dynamically creating the thumbs container. I want the thumbs container to be accessible from both the galleryPane class and the Main gallery class [the galleryPane class will need to control thumbsContainer scrolling properties, and the Main class will load content into it].
I have an empty movieclip in the .fla library (with a class name of "All_thumbs" for exporting purposes). In my galleryPane class, I have created a new public instance of this (called "thumbsContainer") and have added that within the nested structure in the menu. However, when I call it in a later function to manipulate its movement, the undefined term error is thrown and I cannot understand why. Here is what I have in the galleryPane document class.
ActionScript Code:
package {
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.events.Event;
[Code] .....
I have a large flash app (> 100k) w/ its own looping preloader animation in the first frame. This preloader should happily spin while the app loads. (For various important reasons, I can't use a separate SWF to load the app.)Bug:When I export the classes in a later frame, all of the preloader animation's simple timeline commands (stop, gotoAndPlay) stop working.Test:I can reproduce this in a very simple test:The red ball should stop (as seen in example 1) and doesn't (example 2).Question:Do any of you know how to get around this? I've been trying everything I can think of and haven't found a solution. If this is unbeatable, it seems the only real timeline preloader you can do is a code-drawn progress bar
View 0 RepliesI have a few questions I am hoping to get a few clear answers to. I have been looking around the web and in books for the last few hours and I can't seem to get an answer that is clear, at least not clear to me Question1 If an external class such as a document class is used, you cannot simply access a nested movie clip that has been dropped on the stage from the library using dot syntax, is this correct? Example:
[Code]...
I cant call a class using: "<fx:Script source:"myClass"/> For some reason, no matter what I do, the error is always the same.
"Packages cannot be nested".
This is with Flexbuilder 3.2, Eclipse 3.3.2.I am moving my development environment to a new machine. Actionscript classes that compiled in the old environment now get a compile error:
A file found in a source-path must have an externally visible definition. If a definition in the file is meant to be externally visible, please put the definition in a package.I do declare the package in these classes - I think failure to declare the package is the usual reason for this error.To add to the mystery, many classes in this project compile without errors.
i have the following AS class file:
package {
public class DropImage {
[code].....
Every time I try to create a package I get a compiler error, "packages cannot be nested". I've read the manual, tried the examples, tried dozens of other examples over the past few months, but have never successfully created a package.Here is an example of a package I am currently working on:
package {
import flash.display.Sprite;
import org.papervision3d.core.animation.channel.AbstractC hannel3D;
[code]......
I am new in AS 3 and trying to learn this one. Here is the error I got.
Scene 1 Layer "layer1" Frame....1037. Packages cannot be nested
Here is the code
package {
public class dogClass {
public function sayHello():String {
var greeting:String;
greeting = "Hello World!";
return greeting;
}}}
I have an index.swf that serves as the main part of my page, and it loads swfs as sub pages.One of my sub pages, home.swf, needs to be able to load it's own set of sub pages as well, which means I'll have a swf within a swf within a swf (index.swf > home.swf > home_1.swf). When I test compile home.swf by itself, it works fine. But when I test compile index.swf, I get the Error #1009. Here's my code with the line indicated where the debugger says the problem is:
Code:
// index.fla ///////////////////////////////////////
stop();
[code].....
I am trying to replace an Object inside my nested array (colArray) by using splice, the object acts as my player and will need to maneuver around the Array it's in. The Problem is splice doesn't appear to be showing anything in return, it comes up with an error saying: Cannot access a property or method of a null object reference.What am i doing wrong ? And how would i go with moving my playerObject around the array?
var gridContainerMC:MovieClip = new MovieClip();
var gridSize:Array = [col,row]; //Rows, Columns
var gridArray:Array = new Array();
var col:Number = 44;
[code]....
ERROR 1046: Type was not found or was not compile-time constant:textline.
I have nested my animation into a movie clip and have tried to use a pre-loader on it. The nested movie clip opening screen as a button on and the second screen as back and forward buttons. The movie clip works fine no problem until adding it to the pre-loader. The code for the pre-loader is (below) on frame 1 frame 2 to is tells it to stop and also were my nested movie clip is
function loadProgress(my_content:ProgressEvent):void {
var percent:Number = Math.floor( (my_content.bytesLoaded*100)/my_content.bytesTotal);
myLoadText.text = percent + "%";
} function loadComplete(e:Event):void {
currentFrame + 1;
} loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
I am trying to load the movie clips in my library one by one, using a for look and tween them but it seems as i am getting an error Stuff in my Library
6 movie clips
car_mc1
car_mc2
[code]........
I am trying to pass a value from the Doc class to* subClass1. This part work fine. subClass1 receives the value and sets an internal variable to the value it got from the Doc class. When I set subCl[code]...
View 4 RepliesI am building a quiz using XML for the questions and a ButtonTopLevel class to control the behaviour of the buttons tasked with choosing a question. Basically, the docClass imports the XML, makes sure it is fully loaded and then adds these top level buttons as children. I need to maintain the MouseEvent.CLICK in the button class because once the button has been used, it will switch to feedback mode and no longer be available as a button. Once clicked, the button says:
[Code]....
I have a sort of "go back" button in during development, and if I go back to the top level buttons and click any one of them, it works as it should. There is nothing undefined, with the possible exception of a variable or two I've declared and not yet used. Is it something in the way I'm telling the child to talk to its parent? My code is rather lengthy, but I will post if need be - just hoping it might be something I'm missing in this call to the parent.
1. I've created a menu which works almost what I want, but after I click a button and roll over to other buttons, it would show error. It show the error at the output panel but everything still working fine
Code:
private function bgGlow(event:Object):void {
//Disable menu below
event.parent.button.visible=false;
[Code]....
My project is about a header.swf that calls a nav.swf (with a menu and other stuff) and also inits a slideshow through a Slideshow class.This is in header.swf:[code]I renamed the XmlParser class to "XmlParser2.as" (as well as other references to it) and then...it worked...what the hell was going on here?
obs: I tried that also: I commented all the code inside the "initSlideShow" function, keeping the XmlParser instantiation, and the nav.swf didn't show as well.
obs2 : i didn't had XmlParser.as imported cause it was in the root directory. ( i explicitely imported it and tried to compile but same thing happened)
obs3: nav.swf uses the XmlParser.as to load two menus, however I don't believe it has anything to do it since it's a file that is already compiled, at the point I try to load it into header.swf, right?
I am having an issue where I cannot use my own classes in CS3. When I try to create an instance of one class inside another class, from within the same package like this:
var t:myClass = new myClass();
gets me 1067: Implicit coercion of a value of type myClass to an unrelated type Class.
The constructor for the class is simply:
public function myClass():void {
this.isactive = false;
}
I just start reading Advanced Game Design with Flash and downloaded it's source files. Where I use Flash CS5.
The goal is to create a StatusBox that is a class in an other place then the project files are.[code]...
I have an image which I have converted to a movieClip, I have exported the movie clip as an AS class and have some code in the class which adds some text to the movieclip. What I want to do is rotate the movieclip around the y axis but I get the following error:
ActionScript Code: Error #1069: Property rotationX not found on classes.LargeCard
How can I rotate the movieclip without using the timeline?
I try to load classes ex:flash display.Sprite(); and I get error messages. Not just with this code with any class I try to implement. why this is happening. Am I missing the folder that has all of the classes in them in Flash CS3.
View 3 RepliesI have several nested VBoxes in flex, and I'm aiming for one of them to get scrollbars if the total content is larger than the window height. However, when I grow the container, it doesn't get scrollbars at all (vertical scroll policy is AUTO), and the outer container stretches past the bottom of the screen, causing the entire app to get scrollbars. So it looks something like this:
[Code]...
I'm currently working on a Flash platform game and I'm trying to make each level have its own class that defines a hitTest function (Each class is linked to the MovieClip of the level), which would allow the character to walk on the level. Whenever I try to import the subclass into the Document class, errors start popping up and it is driving me crazy (Error 1120: Access of undefined property)
Document Class (Class_Main.as):
package
{[code]....