ActionScript 3.0 :: How To Define Variable Is Null
Nov 14, 2010first i using flashvars to send my $_session["username"] to flash i have a button in myflash that can see are they any user logged in when pressed the button..
[Code]...
first i using flashvars to send my $_session["username"] to flash i have a button in myflash that can see are they any user logged in when pressed the button..
[Code]...
how to define global variable in fms so that it can be accesses by different application instance of same application,
View 2 Repliesvar frName = fruit_txt.text;
disp_btn.addEventListener(MouseEvent.CLICK, disp_fruit);
function disp_fruit(Event:MouseEvent)[code]....
defining the variable i:e frName.... outside the function it does not display anything..same time if I define same variable inside function i:e disp_fruit...it displays the name ]why?
and how can i use variable i:e frName as global var so that it can be used in any function?
How to create a dynamic ArrayCollecton instance that use unque naming: ac1, ac2..ac999 whether user click a button. Without having to use hardcode variable name.
View 2 RepliesBasically I want to define a variable in a movieclip and then display that in a textbox outside of the movieclip. To be a little more specific I want to make a variable be false and then when a movieclip gets to a certain frame the variable is set to be true. The true will then be displayed in a textbox on the main timeline.
View 2 RepliesI am trying to split up my code in classes. But there is a issue what really bothers me. When I create a class for functions I am giving its own stage. Like this:
dragf:Dragfunctions = new Dragfunctions(this)
And in the class i use this
var stage:Object;
public function Dragfunctions(stage:Object) {
this.stage = stage;
}
As you can see I can now call a variable of the stage using stage.var1 = "hi" but when I need to adjust that variable many times it gets a quite messy. There is a way to tell that when I call var1 he knows i mean stage.var1 without need to call stage.
Its:
var var1 = stage.var1
And then using
stage.var1 = var1
But that is quite unhandy too is there a better way?
I'm trying to make children of a tile and put them in their respective locations. To do that, I need to know what kind of tile is to be created, but if I just use my old method:[code]I will have to use a chunk of code like this for every single imaginable tile. Obviously, that is not efficient! So I'm trying to optimize it by having what tile type is to be posted saved in a string, then using the string to refer to what child is to be created, something like below:[code]how to make the above code work. Surely, there is a way to do this?
View 14 RepliesI run a demo code,it extends Sprite,like follows:
public class Vehicle extends Sprite{ protected var _position:Vector2D; public function Vehicle(){ _position = new Vector2D(); draw(); } protected function draw():void{ graphics.clear(); graphics.lineStyle(0); [code]....
I don't understand following code,because I only define _position and don't define position variable,why I can use position.x? x = position.x; y = position.y;
Essentially this is what I want to accomplish, however it doesn't work like this. Is there any solution: - The problem is I can't dynamically name a new object..
import views.printingView;
public function initComponent(o:Array):void{
SomeObject::Array = o;
[Code].....
I'm just getting into this and can't seem to make the simplest thing work! I'm trying to learn to define and call functions. I get no errors but it won't trace the variable:
[Code]...
is there anyway to create and define a variable in a child from the parent? For example, if I add a child to the stage with code, and then want to be able to say
child.variable=0
to create a variable in the child and be able to edit and read the variable. I know the above code is way off but it's just to kinda get the point through.I have to define the variable this way.
As we know whent here is no such variable of null value assignment to a variable or instance flash throws this kind of Error.In one of my Application i need to get more flashVariables, They may or maynot come as FLASHVARS. But when i miss any variable flash thows this error as an alert box. is there any simple solution to avoid this kind of issue
when i use try,Catch statement the issue will not come, But i don't like to write Bunch of try,catch statement for all this kind of variables.
I've a question about variables in AS3 OOP. Do I have to set them to null or I it's not needed when I define them in beginning of the class? I just noticed someone doing so so I wasn't sure is it right or no.
private var _mcComponentHolder:MovieClip = null;
private var _mcComponentHolder:MovieClip;
I have a class named Locator that I use to GeoLocate a user. There's a static method in that class called "locate()". This method then calls another method which sets a static variable called "loc" to an instance of a LngLat class.The issue I'm having is, when I call the locate method at Frame 1 on the scene, and then try to access the loc variable it shows as null... but when I trace the loc variable after it's set in the Locator class it shows as an object.[code]and then trace the variable at the end of the static method in the Locator class it shows as a object and the city is traced as expected.
View 1 RepliesIs there a way to pass a null variable through a function? For example:
[Code]....
I'm working on a sliding gallery like Hulu. Setting it up and the sliding slides in and out is working fine. However, I need to add and then remove a button to each slide as it comes in and goes out. (I initially tried including the button on each slide, a mc, but this proved problematic for the event listeners). So when the file loads up, I add a mc to the first slide of the group like so (features[] is an array of movie clips - my slides):
Code:
var goBtn:MovieClip = new FeatureButton();
features[0].addChild(goBtn);
goBtn.x = 350;
goBtn.y = 230;
So I add the button/mc to the first slide - works just fine.
So there are two handlers, next and previous. So I started with the next handler. The first thing I have to do is kill the button on the panel that is sliding out, so I do that like so:
Code:
features[featureCount].removeChild(goBtn);
goBtn = null;
(featureCount is a counter keeping track of the slides). This works fine. I click the next button, and the button on the slide disappears and we move to the next slide - perfect.
So then I add the following next - exactly like I did in the beginning:
Code:
var goBtn:MovieClip = new FeatureButton();
features[featureCount].addChild(goBtn);
goBtn.x = 350;
goBtn.y = 230;
This time adding it to the current slide coming in - but this generates the following error:
Code:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at featuregallery_fla::MainTimeline/nextFeature()
How I'm getting an error on the removeChild() when that is already gone. I assume "parameter child" means goBtn - yes it is null because it's been removed. But I'm not trying to do something with that. I can only guess this is a variable scoping issue with goBtn - but I'm not seeing how to resolve it. Flash file attached.
If I execute the code below in FlashBuilder, I get the following error (I translate it) TypeError: Error #1009: Access to an Attribute or Method of an null-Object is not possible. at components::NumDisplay()[srccomponentsNumDisplay.mxml:39] This line in NumDisplay.mxml is the problem:
[Code]....
I did a separate levelData class to be able to flexibly add levels. I was happy with it until my supervisor ordered me to convert my levelData into XML. I did an XML version of the levelData's data (question, answers, correct answer...). I used the old class and converted it so that it fetches the XML.
All seems well, I did traces of my answers array and it printed nicely...
But the headache started when I tried this.
// This code appears in a different class with
// currentLvl:LevelData initialized in the constructor.
quizHolder.ansA.ansHud.text = currentLvl.choices[1];
[Code].....
LevelData Class in PasteBin: [URL]
If you have a variable that is a MovieClip, Sprite, String, Number, int, uint, or a Boolean, do you remove it's reference by adding:
myVariable = null;
OR delete(myVariable);
Basically I have 2 classes, A and B. B derives from A. Inside A, I declare a static variable/constant to the class of B. When I run the program, I get a null object reference error, with the line pointing to the class declaration of B, i.e.
Code:
public class B extends A
For reference, these are the 2 classes:
Code:
package
{
public class A
{
[code]...
Also, this error only occurs when the variable is static. If it's just a normal variable it works fine, i.e.
Code:
private var OTHER:Class = B;
If I change the static variable to point to a different class, it's also fine, i.e.
Code:
private static var OTHER:Class = Main;
I can probably work around this, but it's a bit of a pain in the ass. Anybody know what's causing it, or is this a Flash bug?
I add this actionscript code on the first frame. Variables are loaded but. The question is below the code.
[Code]...
I have begun on a list: My reference is null!Stage is null! Convert this code from as 2 to as 3 for me! Crossdomain policies are in the way of my cool idea Dynamic property names I need to use stuff on the parent! I don't want my children to scale when I scale the parent! Classes vs instances. Mod note: I do not want this topic pinned, we will use a fresh topic once we have agreed to the content.
View 9 RepliesI am creating Dynamic Destinations
MessageBroker broker = MessageBroker.getMessageBroker(null);
MessageService service = (MessageService) broker.getService("message-service");
MessageDestination destination = (MessageDestination) service.createDestination("Group1");
[code].....
But I am getting Null Pointer Exception
MessageBroker broker = MessageBroker.getMessageBroker(null);
the script i wrote is working fine. but the script attached to the flash player which i have no control over is throwing a script error (im using IE8).how can i fix this? if i run it locally there is no error.
'null' is null or not an object
try { document.getElementById("").SetReturnValue(__flash__toXML(function() { return document.location.hostname; }()) ); } catch (e) { document.getElementById("").SetReturnValue("<undefined/>"); }
but this is from flash script and i dont have control over it. it just say JScript - script block.
I have create a menu but when clicking on menu so that it shows, I get an error on the line because of the line "myMenu.show(null,null)". See function below:
private function createAndShowmyMenu():void {
myMenu = Menu.createMenu(null, myMenuDataProvider, false);
myMenu.labelField="@label"[code]........
sometimes I remove child and trace it afterwards and it outputs null although I havent yet set it to null, why is that? and do I need to set it to null also in that case?
Code:
trace(holderArr[loadedThumbs].getChildByName("photo_bg"));
//[object MovieClip]
holderArr[loadedThumbs].removeChild(holderArr[loadedThumbs].getChildByName("photo_bg"));
[Code]....
I have the following piece of code(part of a much bigger program). I this code I am re-using a motion that has been previously used successfully. The trace stmts are used to identify the exact location of the error and the error conditions as best I can.[code]
View 4 RepliesWhen you cast null to an object using Object(null), the result is an object.When you cast undefined to an object using Object(undefined), the result is an object.But saying null as Object or undefined as Object remains null.Why is this? I can't find anything in the documentation about this.
The objects that result from these casts can have properties set on and read from them. It's as if the cast created information, or removed whatever special information the null and undefined values have. But there's no indication in the AS3 documentation that the null and undefined special types are actually objects.
I created a Sponsorbar which dynamically adds sponsors according a XML script.
ActionScript Code:
for each( var imgPath2:XML in xdata.img )
{[code]...........
I am trying to add an EventListener to a MC, but I am getting the 1009 error. My script is referencing a MC that does exist. I have verified that my code is typed correctly, and that my instance names are correct.I am creating a portfolio site. On the first frame I have my main navigation (well, it's actually not the first frame. I alpha-fade everything in so it's really the 6th or 7th, but I'm not sure how pertinent that is). The main navigation works fine (5 movie clips, fyi). Clicking them will move to a different frame, and the information and sub navigation for the frame will fade up. It is the sub navigation that I am having trouble with.[code]
As you can see, it doesn't even get to the function before it gets thrown off. I have verified that the instance names are correct. The script and the MC I am trying to add it too [I/]are[I/] in the same frame, which is what's stumping me. Normally you get 1009 when the object you're trying to reference is not there, but mine is!!Obviously there is something wrong with my EventListener. I am not sure what else do; there is a gap in my understanding of AS.