ActionScript 3.0 :: Can't Change The Reference Of An Obj After "addChild"
Mar 23, 2009Well, see this simple example:
Code:
var a:Bitmap = someExternalBitmap;
addChild(a);
a = someOtherExternalBitmap;
[Code].....
Well, see this simple example:
Code:
var a:Bitmap = someExternalBitmap;
addChild(a);
a = someOtherExternalBitmap;
[Code].....
I have downloaded Box2d ([URL]) and created a project that looks like this: [URL]. catalyst is the green cube and it has the base class "shapes.box", it is inside "world" which has the base class "wck.World". What i want to do is to add another "catalyst" from the library inside "world" when i click on add_btn. I tried to accomplish this by this code:
[Code]...
Symbol 'buttons', Layer 'Actions', Frame 1, Line 41061: Call to a possibly undefined method addChild through a reference with static type Class.
I'm trying to dynamically set the addChild linkage identifier, but am having little luck.
Code:
for(i=0;i<6;i++){
if(i==this.myId){
var section:MovieClip = "section"+i
this.addChild(new section);
}}
In AS 2.0 I could simply do this:
Code:
attachMovie("section"+i, "section",0)
We are supposed to build a game, and each of us is to make a level. So we did, but integrating them is giving me issues. Specifically, each of our levels are contained within a symbol. I personally have a ton of symbols that point to eachother already (main.as, menu with various elements, level one, boss level) but for whatever reason whenever I try and addChild my partner's level it gives me "TypeError: Error #1009: Cannot access a property or method of a null object reference."
the way I've been doing it looks like:
var levelTwo:SkiHill = new SkiHill();
parent.addChild (levelTwo);
parent.removeChild(this);
like I said, it's worked every time Ive used it between my own things. My partner's is a no-go. If I just slap his level on the stage and go it runs fine, and it will properly add/remove child to transition to one of my levels.
All I can think of is that I've checked all the names. I also noticed my partner didn't use an ADDED_TO_STAGE event listener, but adding that didn't help at all.
I am attempting to make a class that handles the building in a game, but I can't get the object to come on stage. I can get everything to work if I am on the timeline, just not from this class. I've been getting this:
[Code]...
I'm trying to just make an image center horozontally in the page when I addChild it. I figure the formula I need is the width of the of the image deducted from the width of the page divided by two... but I don't know how to make that into a formula, as in I don't know how to represent the size of the newly added child in the formula. Code is below.
[Code]...
I am a newbee and just starting to learn about AS3. Copied some ideas and tried to paint a single particle on the stage for starters. No success! I get this...1061: Call to a possibly undefined method addChild through a reference with static type flash.displayisplayObject.In an "Particle.as" file I have this code...
package
{
import flash.display.*;
[code].....
I got this Error : 1061: Call to a possibly undefined method addChild through a reference with static type Class.
what I'm trying to do :I have create a new class called Graph and make it extends Sprite and add a scroolpane to my stage and make an empty movie clip called content_mc and make the source of the scrollpane equals to content_mc
in the first frame i wrote this code
import Graph;
var graph:Graph = new Graph();content_mc.addChild(graph);
I'm adding a bg to the same canvas, but it's overlapping everything added before it.
View 2 RepliesI have the following scenarios.
[Code]....
how can I change the txtField.text without using the addChild function in the main class?? because the Content Class is already visible when you compile it.. and when I remove the that addChild function, the txtField.text is still in its default value which is "Lorem Ipsum"
Both websites have around 75 videos on it, fed to them by XML. It's a complete mirror. What I'm looking for is to see if there is a way to only have to change (1) XML to reference both sites. Is there any code I could put into the XML to have it reference another XML on the same server?
[Code]...
Ok, I have a class like this:
public class Foo extends Sprite {
public function Foo(x:Number, y:Number):void {
this.x = x;
[Code]......
I'm getting this error from the compiler: "Error: Illegal assignment to function bar". How can I change the public function bar on the fly?
I'm trying to have a class file which can add objects to the stage via addChild; however, when I call addChild from within the class file, I get the error "1180: Call to a possibly undefined method addChild." I've tried importing flash.display.* and that doesn't fix the problem. Does the class file have to extend Sprite or MovieClip to be able to add objects to the stage?
View 8 RepliesI am unfamiliar with Flash and actionscript and I need help to dynamically change the font of a textbox based on the value of a flashvar. I have a flash template whose content I can edit through XML. The flashvar value specifies the language and points to a different XML file. This works without problems, and I have found online a way to change the font via actionscript. However I need help on how to get a reference to that textbox.
There are two files an .fla and Main.as file. Within the fla file there is a single Scene and when the textbox is selected the properties display "thisLogo" as its name and "Dynamic Text" in the combo box below. Within the Main.as file I have attempted to add the following code:
[Code]...
1119: Access of possibly undefined property thisLogo through a reference with static type Main.
I have the followings:
_p:Player (which is a MC)
a1:Animation1 (which is a MC)
_p.addChild(a1); //doesn't display anything
_p.stage.addChild(a1); //displays a1
Why won't the MC display a child without using his stage?
I'm trying to resolve an issue that reared it's ugly head yesterday.Frame one of main timeline I have the following code:
Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
[code]....
The newMC doesn't show up.If I add 'parent.' in front of the addChild then it appears.mc_LibItem has a base class of "flash.display.MovieClip" and is exporting for ActionScript and on frame one.For grins I created a new .fla and began messing around with the same addChild idea and it worked.
somewhat understood the basics of adding and removing children, however, I am facing another problem. After using the removeChild Function, I can't seem to add another child.For example:
ActionScript Code:
var attachedMC = new (getDefinitionByName("Content1") as Class)()
Page.addChild(attachedMC);
[code].....
I have a main "shell" swf which, by clicking several buttons, will load/unload various external swfs into a Placeholder_mc which resides on the main timeline in Shell.swf In the documentation and tutorials I've seen a couple different methods, and I'm not sure I quite understand the difference, or at least the reason you would use one over the other...In the 1st method, you can just add the Loader object using the addChild() method:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
Placeholder_mc.addChild(myLoader);
This will apparently add myLoader to the display list once it has completely loaded.The 2nd method, you supposedly can add the Loader.content; however, it appears you can only do this once the content has completed loading, so you need to incorporate an event handler with the contentLoaderInfo object:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
[code]....
What are the pros/cons of adding the entire Loader object, as opposed to the Loader.content and vice versa?
I need to remove the word Button from the reference to reference the actual item that will be tinted.
[Code]...
I'm having this frustrating error showing up and I have no idea why. Let me show you my classes and see if you can spot anything wrong.
First, here's my ILode interface:
ActionScript Code:
package com.schelterstudios.lodeSystem.flash.lodescode].....
So the problem I'm having is the compiler is throwing that 1000: Ambiguous reference error for any reference to instance.priority or instance.label. Why??? Instance is typed to IFlexLodeInstance, and IFlexLodeInstance lists method signatures of priority and label getters, and it inherits ILode, which lists method signatures for priority and label setters. What can I do to get the compiler to stop complaining?
My code is an external .as file. Google provides this code on their demo, which contains the this keyword:
[Code]...
Notice that I have 4 calls to console.log. The first 3 fire, but after the new GATracker statement, the 4th does not fire. I have a feeling that I'm overriding the entire package with the object created from new GATracker when I should be passing a different context. I believe the correct context I should pass is whatever this defaults to when not inside of a package/external file, I assume it references the main stage object.
package uk.co.bigroom.utils
{
import flash.utils.Dictionary;
/**
* Class to create a weak reference to an object. A weak reference
[code]....
In this Class, how they denote one as Weak Reference and one as Strong reference.
What I have is a function that occurs every second. Every time this function is called, it will add two movie clips from the library onto the screen. I am wondering if there will be a problem if my function keeps on continuously adding children to my scene?
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;[code].............
Im wondering if its possible to arrange movieclips with addchild in such a way like this?:[code]mc_1 and mc_2 is in my case a forward and back button (obviously these have to be on top all the time).. mc_3 - 6 is images rotating.
View 2 RepliesI'm new to programming in general, so not only are the basic concepts new to me but OOP and all of the various underlying rules are keeping me very frustrated in this learning process..I've reached a point that I'm simply stuck and can't find the solution through trial and error, and perhaps am not grasping how addChild works. traces just fine, but then when I try to run addChild I get "error 1023: stack overflow occurred: at Bullet$iinit()".Ignore the commented out lines, they're just for some testing and some trial and error).
//Bullet Class
package {
import flash.display.MovieClip;
[code].....
I have a movie clip that I add Bitmaps by using addChild(). I was wonding how would I go about displaying the next image that I added because as of now it is stuck on the first image.
View 3 Replieswhere addChild comes from? Is it pre-built in or does it com from importing Flash.display. Sprite (and if it is from Flash.display.Sprite, does it mean it gets imported whenever you display *any* subpackage of Flash.display?)
View 1 RepliesI am trying to add and remove children from the stage using a string. the string takes the instance name from the button pressed and i want to use that string to add a child from my library and its giving me:
"TypeError: Error #1034: Type Coercion failed: cannot convert "Floor2" to flash.display.DisplayObject."
I realize i have to make the string into the actual object but not exactly sure how.
Code:
var rollstr:String = this.toString();
var Floor1 = new floor1();
var Floor2 = new floor2();
[Code].....
I am looking at an xml file, and creating a big list of visible buttons for each "flag" via addchild().
One of the subsets of each "flag" button in the xml is "Content"
I've been reading a lot on this but I'm just getting more and more confused. Can someone break down for me:
How to pass the xml Content to each addchilded button, so it can then pass that Content to a function when it's clicked.
The Content is a string, like "Flag40.swf" which is the file I want my function to load when I click the button. I have everything working except for getting each button to tell my function which .swf to load.
I had a previous old script working with AS2 and have tried to convert it as the new system requires AS3 .the below script :
function displayItems() {
var xPos = 0;
var yPos = 0;[code].....
This gives me the following for the bolded line
Scene 1, Layer 'as', Frame 1, Line 44 1067: Implicit coercion of a value of type String to an unrelated type flash.display:DisplayObject.
This line used to be addmovieclip which worked. I'm not sure how to edit this to suit the new addchild method.