ActionScript 3.0 :: DisplayObject And AddChild - Use The Variable OpenType In The Call For The Image??
Nov 24, 2009
I am working on a project where we are making a "wizard" where you answer a series of questions and in the end you are presented with a "parts list" based on your answers.There is also logic which decides which questions you are asked based on how you have answered certain questions so far. The outcome is a list of door control hardware (locks, mounting plates, handles etc. etc.). show a "live image" of the parts list as it builds. For example one of the questions is this: Door Type?
A) Aluminum
B) All Glass
C) Wood
Depending on which you choose I need to show an image of an aluminum, glass or wooden door.Then if the next question is about lock types then your new lock shows up and so on and so forth until you reach the end.The questions all relate to their own variable which are each defined at the beginning of the movie like this:
Code:
var doorType:String = "DT0";
The questions use radio buttons and each question (re)defines it's variable like this
Now the tricky part (for me at least) is figuring how in the world to use this in conjunction with the questions (more accurately, the variables they define) to produce this live image.Another thing to add complication to this whole mess is that there are basically two entire sets of images. Single doors or Double doors, they both have (nearly) all the same hardware but they are two different sets of images. They are differentiated by the ot1 or ot2 in front of the class name. The variable openType defines OT1 or OT2 in a previous question. I would like to be able to use the variable openType in the call for the image
Code:
//This is how I tested it
currImage = new ot2_wood_exit();
//I would like to use openType instead of hard coding ot1 or ot2
currImage = new openType_wood_exit(); //I KNOW this is wrong, but I don't know what is right!So that is my basic dilemma. I need to show or hide specific images based on the answers to previously answered questions AND questions currently being answered (live update).
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?
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 having trouble simulating a click call to a button(displayObject) thats generated via an API call( youtube as3 API). I have not seen any mention of security reasons as to why I can not simulate a click as long as something is registered with a click handler. Basically I checked to make sure the button made is listening to a mouse click event with:
trace(generatedButton.hasEventListener(MouseEvent.CLICK)) which returns true
I proceed to than call this:
generatedButton.dispatchEvent( new MouseEvent(MouseEvent.CLICK, true) );
And nothing happens yet if I physically click the button it works. Is there some security measure that prevents something from being fake clicked unless its origin is strictly from the system mouse?
I even set a timeout call on the click function and moved my cursor over the button and let it fire in case it was an issue of the mouse having to over the object but still nothing. I am kind of stumped at this point.
When I add a DisplayObject to a DisplayObjectContainer (e.g. a Sprite to a Sprite) in a function, it seems that the DisplayObject is actually added not immediately, but after finishing the function.
So we have a simple green button, and when it is clicked, there's a red Sprite constructed and added to the stage. But actually the red Sprite isn't visible until the onClick() function has been fully executed.
Why is that and what can I do for the red Sprite to be visible immediately?
Is there some (for the developer invisible) global paint() or update() function, that is not executed until some stack is fully executed or something?
I'm coding this minigame implementation where a sprite traverses tiles on a screen, and when he's done traversing a tile, the tile "disappears" (its alpha decreases and it becomes a "wall" the player can not move onto). Now, simple enough. Make use of a traversing and traversed boolean arrays to store if a tile is currently being traversed, or if it isn't, but it has been traversed. So, if traversing == 0 and traversed == 1, make the tile "disappear". However, and here's the weird part, if I just set the alpha to, say, 0.5 in this if statement, it sets the alpha on just the tile I traversed, whereas if I try to make it part of the wall as well (in the same if), every tile except the one I've traversed to becomes a wall.
Here's part of the code (it happens in the enterFrame game loop):
Code: const NUM_TILES = 15; //Add MC for all the tiles var tiles = new MovieClip(); addChildAt(tiles,5);
I've been hunting around for a simple opentype font embedding implementation for AS3, but haven't quite found one that worked yet... I tried the most straight forward option of simply adding the font into the library of the FLA, but unfortunatly it didn't go as planned. I am trying to embed the AvenirLight and AvenirMedium fonts, but when I try to add a new font it only ever gives me one option of "Avenir", even though I have several varieties of Avenir installed. It seems like it is defaulting to one of them or something perhaps? A lot of other methods I came across involved using Flex Builder instead, and I don't want to restart my project in Flex instead just to load these OTF fonts.
I'm working on a Flash Lite 3.0 application using AS2 and I've created a class that extends MovieClip. The problem is that I'd like to dynamically add Child Movieclips using the addChild method... but it doesn't work, it gives me the following compiler error: "There is no method with the name 'addChild'". But I can call other MovieClip specific methods such as this.getNextHighestDepth()
heres a reduced version of my class:
class com.sck.DragList extends MovieClip { //Declarations private var placeHolder:MovieClip; private var listMask:MovieClip;
In Flash CS5 I am trying to load an image from a class and I am getting Call to a possibly undefined method addChild. In the class fileNot sure how to fix this as I have a sprite class and believe I have done everthing correct.The image is in the same folder as the .fla and .as file
I've got a function that call's on a class too make a chess board. The problem is, is that I'm getting this Error:1180: Call to a possibly undefined method addChild.Now if I just copy paste CreateBoard into Exercise1.as it works and creates a board but if I add it as a function too BoardSquare it works and traces out 32,32 but doesn't display anything![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...
I load an png image and add it to the display list. Now I want to add this image more than once, like a pinball game there could be 3,4,5 balls, all with the same image. But I cant add the same image reference more than once to the display list, right? So should I make a copy of it? How can I copy it and add to the display list without needing to load it from file more than once?
I tried using this: [URL] But didnt worked! I use the class Loader to load an png, and I use the Loader.content as a parameter of that function. When I add the result to the displaylist nothing appears!
I am trying to use addChild on a current project I am working on, the only problem is that I have to add movieclips to the stage based on an array of movieclips given to me and a number (index).
At this point I am trying it like so:
Code: var array:Array = new Array('Mc1', 'Mc2', 'MC3'); // etc. var num:Number = 1; addChild(array[num]);
I want to loop and put on several movieclips which are named Node1 to Node15. How do i add them and access them afterwards? Tried to give it a name and access it afterwards, but had no luck.
Code: i++; var newnode:Node[i] = new Node[i](); newnode.name=i; addChildAt(newnode,i); newnode.1.x=10; newnode.2.x=40; .... newnode.15.x=440;
Code: var doorType:String = "DT0"; var openType:String = "OT0"; var imagePositioner:Sprite = new Sprite(); //Places a Sprite that will "contain"
[Code]....
openType is defined on a previous screen, it will be equal to OT1 or OT2. I have two sets of images (movie clips) that each have a prefix of "ot1_" or "ot2_" (in their class name). Other than those prefixes the two sets of image names are the same. I think I could cut the amount of code in half if I could use a variable when I use addChild.
I am not very knowledgeable of AS3 and everything I've tried has failed. My theory is that addChild() needs to contain a movieclip, so putting a variable name in addChild() doesn't work.
I'm new to oop and I'm trying to convert a auto scrolling TextField into a class. I guess it has something to do with there not being a stage when the class is instantiated but I'm not sure how to get around it. my code:
I want to monitor a variable. Whenever the variable value changes I want to call a function. In actionscript 2 I can use "watch" but in as3 what can do ?
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 would like to be able to quickly check if a given DisplayObject is a descendant (not in the inheritance sense - ie. child, grandchild, great-grandchild, great-great-grandchild, etc.) of another DisplayObject. There doesn't seem to be a native way to do this and I can only think of two ways to achieve it: Create the mother of all nested loops. Seems a bit, I dunno, wrong? Dispatch a bubbling event at the 'child' and check if the potential 'parent' receives it.
I need to reload the same JPG about every second for an indefinite time. Problem is that that right now with addchild it adds the JPG on top of the old one eventually running out of memory from adding so many JPG's Is there a way to specify with addchild() to replace the old one?