ActionScript 3.0 :: Errors While Creating Object
Aug 11, 2010I have created a file in which I have a movieclip which links to AS file.
When I create the instance on timeline it throws the below error. [code]...
I have created a file in which I have a movieclip which links to AS file.
When I create the instance on timeline it throws the below error. [code]...
I've been trying to create a scrollpane dynamically but I keep getting a bunch of errors when I publish the swf. At first I thought maybe there was a problem with my code so then I looked in the file and copied and pasted one of there examples into a blank fla and I still get the same errors when I publish. If I look at what is the source of the errors it looks like the error originates at this section of the ScrollPane.as file:
Code:
override protected function drawBackground():void {
var bg:DisplayObject = background;
[code].....
Trying to create a 2D vector. I'm getting type coercion errors when trying to store the 2nd vector inside the first.
Code:
var vector1:Vector.<Vector> = new Vector.<Vector>
var vector2:Vector.<CustomClass> = new Vector.<CustomClass>
for(var i:int=0;i<5;i++){
vector2[i] = new CustomClass()
}
vector1[0] = vector2;
1067: Implicit coercion of a value of type __AS3__.vec:Vector.<CustomClass> to an unrelated type __AS3__.vec:Vector.
I've been busy with a small tutorial on creating a flaming mouse trail. I'm getting two errors though in the same line which I do not understand in the following part of my code:
function startTheFire( e:Event ):void{
TweenLite.to( e.target,0, {alpha: ( e.target.alpha -= 0.05 )} );
if ( e.target.alpha < = 0 )
e.target.removeEventListener( Event.ENTER_FRAME, startTheFire );
removeChild( e.target as Sprite );
}
ERRORS:
1084: Syntax error: expecting rightparen before semicolon.
1084: Syntax error: expecting identifier before assign.
Both refer to the following line: if ( e.target.alpha < = 0 )
I'm a begginer flash game developer-ish individual working on my first project - An economic game with RPG elements, I'm mixing AS 3.0 with Flash CS5 (for the graphics, buttons, tweens and the simple stuff in general since it's easier for me atm than scripting it). The trouble started when I had to script in variables. I've sorted out a couple of issues but a few still remain:
1. I need to limit three of my main skills to 0-100. Only managed to stumble across tutorials for AS2,
2. Each character will have 3 main skills, and then the 18 secondary skills will be calculated from those 3 values. This works fine, when I modify existing variables directly in the code. The thing is that I created those buttons that add or subtract from a certain skill value, but when I press them the var changes but all of the 18 skills remain unchanged (as if they do not refresh themselves - i was thinking about an eventListener waiting for a change in skill value but if I would have to do one for every one of the 18 skills in conjunction with the 6 buttons to change levels - so 144 functions - im thinking maybe an array...but I'm such an actionscript newb that I can hardly translate the tutorials into my ideas.
3. Also wondering how to create a pool of unused skill points so when I add points I can't max it out right off the bat but rather take it from that value instead and once it's 0 you can't add points anymore.
4. Last but not least, I'm having trouble creating global values. My main menu is in scene1 and when I press Newgame it goes to scene2, the problem starts when i go back to main menu errors keep showing up (since scene 1 has no information about statistics but a function probably keeps asking )which means that the program can't get access to an attribute or a method of reference for the null object at MainMenu_fla (don't be fooled by the file name, I have everything in 1 fla file)Of course an error pops up for every skill, main or secondary.
I have been using Flash for a long time and I have never seen this error before. I have the solution for this, but I don't understand what is actually causing the issue.
I have attached a zip file with an fla and two as files. If you run it as is you will get :
Code:
1026: Constructor functions must be instance methods.
5000: The class 'Main2' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.
5000: The class 'MemoryGame' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.
The problem appears to be that on frame 3, we have an instance (named replayButton) of an object called btn_Replay, with linkage turned on correctly. If you rename the object and linkage to Replay (or anything else) it works fine. Set it back to btn_Replay, it breaks once again.
There is nothing in the code that should affect this.
I use the following doctype in a page that has a flash object,
[Code]....
information on how to embed a flash object[.swf] in a page with no validation errors?
I am almost done my short AS3 "Flight of the Conchords" game I just want to attempt to do one last thing...to successfully restart the game without getting a bunch of null object errors. The way it restarts now is that if you die or win the game then a screen pops up and a button takes you to the previous scene (menu), the problem is that once it goes to the previous scene all these null object errors occur.
P.S. This is my second time working with AS3, and I was able to do this following a YouTube tutorial by Borris123psn.
I've managed to get a sensor attached to an arduino talking to flash using something called AS3glue. it works, when i set up a trace("leaf") for the contition that the sensor reads 0, i get a printout of the word "leaf". however i want the program to make a graphic appear on the screen when this condition is met, not just trace something.
I'm trying to get the program to generate a library object called "Enemy" on the screen at a random position each time the conditions are met. It's called enemy because I was following a game tutorial...actually it's a drawing of a leaf. Here's the bit of the code which is causing me problems:
[Cdoe]...
I am new to flash. I am experiencing random (at least to me) errors (#1009) while navigating through my tested file. I can't reproduce them everytime. It only happens sometimes. Usually they occur after I have clicked back and forth between different pages (frames). Sometimes the error shows up once, and the file moves on as if nothing bad has happened. Sometimes the error continuosly displays, which really slows down the test. One example of such: TypeError: Error #1009: Cannot access a property or method of a null object reference. at About28_fla::MainTimeline/clickResumeFromAbout()
View 7 RepliesI have one MXML File as
<objecthandles:ObjectHandles xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" backgroundAlpha="1" xmlns:mx="library://ns.adobe.com/flex/mx"
[code].....
is it possible to create instance inside method of another instance? But I want new instance to be sibling of instance where it was created.something like this:
ActionScript Code:
parent = new Parent();
childA = new Child();
parent.addChild(childA);
Child class would have this onclick event function:
ActionScript Code:
public function child_click(e:MouseEvent):void {
childB = new Child();
}
I want "childB" to be child of "parent", no property of childA. so I could do:
ActionScript Code:
parent.addChild(childB);
how is this possible without passing "parent" instance as parameter?
I'm having trouble creating instances of an object, I want a random number to be generated and then based on the number which was choosen create an instance of an object in one of four positions.The problem I'm having is, my instances are generated fine but there is one that keeps jumping to x 0 and y 0.[code]
View 21 RepliesBack in the day (AS2), I used to create what I called an"ivar" property that collected the index of a series of buttonsthat were clickable (see attached code). Imagine 10 buttons on thestage with names (selectButton0, selectButton1, ...selectButton9).The code under the //----------BUTTONS header would make a propertyof the button that was clicked, call it "ivar" and then send it upto a function that would use it as an index to then load theappropriate content with MovieClipLoader (remember that Class?).I have tried something similar in AS3 without any luck sincethe whole button thing is now steered by events. Does anybody knowan elegant solution that would achieve a similar result. That is,click a button called "selectButton0" and have returned the zero asan index variable that could be used further?
View 14 RepliesOn library i have mc. In property i made Export for ActionScript. And on timeline add code:
var my_pic_mc:Pic=new Pic();
addChild.(my_pic_mc);
but dont see my movie clip on the stage after compile.
I am trying to create a BitmapData object of a jpg that is loaded into a movieClip, so that I can then remove the jpg and have just the BitmapData of the image to manipulate. I have the original image loading into my temporary MC without any problems..and am using a listener to check to make sure that the image has been fully loaded before it moves onto creating an empty movie clip for the BitmapData... but for some reason the BitmapData isn't working as nothing shows up in my holderMC.. and it says the width of the holderMC is 0 when it should be something liek 367 for the 'surf.jpg' test image I am using. My code is below..
Code:
import flash.display.BitmapData;
stop();
_root.createEmptyMovieClip("tempMC", 1, {_alpha:0});
[Code].....
I have a xmlfile with some node. I need to create an object of my class for each node. I knoz how to parse xml and get value, no problem here, but I can' create dynamic object with dynamic name...
Here's my class code:
public class Simple_Forum_MV extends MovieClip{
public function Simple_Forum_MV(MV_name:??,title_forum:String,description_forum:String) {
MV_name:MovieClip = new MovieClip();
MV_name.width = 500;
MV_name.height = 50;
I'm wanting to create a tshirt as a mc object in which users can write their name etc on the object. I'm thinking that it might be best to create a button called insert text and when clicked it opens a text box on top of the object...I'm using flash cs3 and actionscript 2.0
View 7 RepliesI'm trying to add a custom object to the stage by calling a function like this:
Code:
var effectName:String = new String("Explosion");
var thisObject:MovieClip = //some movie clip class, like an enemy
addFX(effectName, thisObject);
[code]....
How can i turn a string value into a movieclip?
I want to do is create several arrays to hold groups of movie clips (i am using as buttons) which have similar functions so that I can add event listeners using a for loop statement rather than making a huge list of add and remove event listeners.I have seen this method working before but I cannot get my code to work!! This is probably a very noob concept but I have been struggling with it for hours.Ok, so in the extends movie clip bit on my as file I declare the array as such:public static var controlBtns:Array;Then in the initializing function I put values into the array as such: [code]The trace seems to output all the object names (as they are listed in the library) and then I get this error: TypeError: Error #1010: A term is undefined and has no properties.Which is kind of obvious as I cannot seem to access the movie clip instance names that I have set up in the array.I tried putting quotation marks around the names in the array making them strings but then I can't access properties of strings - which is obvious enough to.
View 8 RepliesI would like to add a bunch of cars to the stage, and store them in an array as objects. The problem is I hate using external AS files and would like to keep it as simple as possible.I tried doing :
var car:Object = {carcolor:String,carscale:Number,carpower:Number};
var test:Array = new Array()
for (var i:Number=0; i<10; i++) {
test.push(car)
}
The problem is if I try to set a value of one object in the like test[1].carscale = 5
Every object in the array gets their attribute carscale set to 5.Is there any way I can do this without using external class files?
I'm trying to create a dynamicly named object.
something like
private var myVar:String = "dynamicName";
private var [myVar+"staticName"]:Object = new Object;
but what i wrote above dosn't work for some reason.
i have the following switch case:
switch (appModel.currentPage){
case "Programma":
case "Winkelwagen":
case "Films":
case "Contact
[Code]...
I've been trying to write a function to create a simple circle in Box2DFlash . but it keeps telling me that the object is null and I can't access it's properties here's the code:
public var f1:b2Body;
public var f2:b2Body;
public function addACrate(fallingCrate:b2Body,
[Code]....
and when I try to access the "y" property of my "f1" object it tells me that it's null .
What I want to achieve is a script that creates a random tween of a certain object (a button object in this case), within a confined space (i.e. don't move the button out of visibility completely). My basic idea is:
a) for each button (there will be about 5 or 6 buttons in total), get its position.
b) for each button, move (randomly) either left or right by X pixels and (randomly) either up
Or down by Y pixels (where X and Y are random numbers within a specified range, e.g. random number between 10 and 40 pixels for instance). [However, before moving the object, determine if the new coordinate will put the object out of visibility. If it will, repeat step b) until it won't put it out of visibility. if actionscript has while loops, I'm sorted]
c) repeat from a [is there something like javascript's setInterval() for actionscript?].
I have a MovieClip that I made with a simple text box inside to hold some text..
I am basically using it to generate a "member list".
Each name would have its own TxtSlot_mc... so it can be manipulated later.
I have so far been able to dynamically load a concatenated string of member names from php into flash and then split the string into an array.
I have also been able to create each movie clip and assign the member name to the text in the text box and add/position it to the screen.
The problem I am having is that after exiting the function that handles the creation I can't figure out how to get access to them.[code]...
I am trying to create a bookmark in my e-learning application. So far I have been abe to create 2 buttons that write and receive information from a shared object. My next step is writing the current frame and swfs to the shared object, but I am unsure how to write the code to do this. How would I display the swf's retreived from a shared object as a hyperlink, where the user can click on and return to their bookmarked spot?
View 2 RepliesMy question deals with adding a cuepoint in actionscript 3 using code. In flash 8, I made use of the FLVplayback component which included a method addASCuePoint(). In Actionscript 3, I am now using the standard method of creating a video object, except i can't figure out how to use actionscript to add a cuepoint. In the AS3 LiveDocs entry for NetStream , it list only event and navigation as cuepoint types. Previously there was a third type of cuepoint: actionscript.
Code:
public function LoadVideo(){
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var vid:Video = new Video(320, 240);
[Code] .....
I am guessing one option is to create an onEnterFrame function that compares the NetStream.time to each value in my cuepoint array, and then do a addEventListener(EventType.ENTER_FRAME, onEnterFrame); Although this might work it requires my application to loop through my cuepoint array every single frame, which isn't really efficient.
I'm building a web flash 8 app with an animated nurse that talks and help the user in different events. the voices sit in a external folder and i load them using load sound method. It works fine as a desktop app, but when testing the movie on slow download (DSL 32 KB/s) I realized that i must load all the sound before i can play the animation.
problem nr.1: How do i create folowing sound objects (voice_0, voice_1, voice_2..) using a loop?
I've tried this, but it doesn't work
for (i=0;i<numVoices;i++)
{
var this["voice_"+i]:Sound=new Sound;
}
[Code]....
I'm trying to build an object object from input text. I can load the information into a variable using LoadVar with no problem but when I load that information into an object ( object {} Flash does not recognize the object as on object.
View 4 Replies