ActionScript 3.0 :: Creating Object With Dynamic Name
Dec 2, 2009
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 am simultaneously creating an object and adding it to an array, perhaps ill-advisedly. The following code worked on the main timeline, but not when I moved it to the constructor of a document class:
{ package { import flash.geom.Point;[code]......
The following error is generated: ReferenceError: Error #1056: Cannot create property xx0 on IconTour. at IconTour()
I guess this is because xx0 isn't declared? How does one declare a dynamic object/variable?
I want to create a generic component in flex. This component deals with different ArrayCollections dynamically (I want it in that way). So I thought to pass the arrayCollection and the type of that arrayCollection as arguments to the component.
Like, var list:ArrayCollection<ClassA>; init_Comp(list, "ClassA");
If it is possible, I can read it like this, var newDynamicInstatnce: typeOf("ClassA") = list.getItemAt(0) as typeOf("ClassA");
Finally I have a Dynamic Instance type of that I pass. Is this possible in Flex or Is there a better way?
I want to generate a mc for each rep with 6 text fields containg the 6 values for eash rep.So for this xml there would be 3 mc's with 6 text fields in each. This is one of my first times really diving in to xml parsing in Flash.
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 have this situation where i'm trying to save "chat logs" while people switch around views in my flex mobile application..so, my plan is i'm starting out with a main object that I plan to re-use as the main chat log object..I call it textObjso, when someone new wants to chat my plan is to make a new object with the persons username.so how if i were to get the username from something like data.username how could I translate that into the var name of the object I want to make? So in the end i end up with.[code]
I am using a regular Flash object as a simple data container, and I want to remove a particular property of that object. Then that object gets passed on to a for..in loop. But even after using delete to remove the property, the key still shows up in the loop.
For example:
var obj:Object = { a: "a", b: "b", c: "c" } delete obj['b']; for ( var prop:String in obj ) {
[Code].....
So deleting the property seems to be the same as assigning its value to null.
Is there any way to immediately remove the property from the object altogether so that it is no longer looped over in a for..in loop?
It is not sufficient to check the property for a null value since a property with a null value is not the same as not having the property in the first place, and represents a different state. I don't want to set the property to null, I want to remove the property.
I am having trouble using the name of given button to determine my loader URL. If my button is called yerBasicButton_bt ... I would like it to utilize a reuseable function to dynamically determine and load a URL named yerBasicButton.swf. In this manner yerBasicButton2_bt would then load a movie named yerBasicButton2.swf, and so on. So the function looks at the instance name of the calling button to determine it's URL.
stop(); unit133bd3ba_bt.addEventListener(MouseEvent.CLICK, getUnitSWF); function getUnitSWF (e:MouseEvent):void { var swfLoader:Loader = new Loader(); swfLoader.x = 25; swfLoader.y = 368; var swfURL:String = e.currentTarget-"_bt"+".swf" var swfURLReq:URLRequest = new URLRequest(swfURL); swfLoader.load(swfURLReq); this.addChildAt(swfLoader, 0);}
Create a flash application which will be displayed on a web page which will read from a list of text inside an XML file and display them randomly with fade-in fade-out effects and also at random positions.My current approach to the problem is using a Dynamic Text Area which will read from the xml file, however I only got to the stage where the swf will read the xml file. Trying to get the fade effect and the positioning effect is proving very difficult for me.The sample XML I am working with:
<tag> <tagline>Global Jobs Pact</tagline> <tagline>Green Jobs</tagline> <tagline>Decent Work</tagline>[code]......
var page1:Branch = new Branch(); page1.y = 124; addChild(page1);
I want to have the value "page1" to be dynamic, along with "Branch". Since there's a number of templates (up to 20), Branch is one of the templates. So it would be nice to use one instance creator. Also, I'm not sure how to get "page1" to be a dynamic value.
The closest to this that I've been able to find is:
star1sp.addChild(this["star"+star1Num]);
except that it doesn't fully address what I want to do. I tried adding in a bunch of "this[load_page]" and "this["page"+curpage]" to my code but had no success. I'm still on the prowl for the answer but wanted to put this out there. It's something I've tried to figure out for some time.
I would like to create a simple 2D interactive grid. The user should be able to increase and decrease the number of axis (both X and Y simultaneously) that compose the grid, and also the scale of the grid itself (Zoom in and Out).
If this goes well enough, I would like to be able to plot graphical content on the grid that visually changes as the grid itself changes. They should, in some way, be linked to one another and correspondingly affected by the same two parameters. This, however, would be a second step. I am more concerned with the base grid model at this point.
I would like to create a simple 2D interactive grid. The user should be able to increase and decrease the number of axis (both X and Y simultaneously) that compose the grid, and also the scale of the grid itself (Zoom in and Out).
If this goes well enough, I would like to be able to plot graphical content on the grid that visually changes as the grid itself changes. They should, in some way, be linked to one another and correspondingly affected by the same two parameters. This, however, would be a second step. I am more concerned with the base grid model at this point.
I got the first part to work. The only problem is when I click any buttons it produces errorTypeError: Error #1009: Cannot access a property or method of a null object reference.at resume_fla::MainTimeline/frame1()not sure what I have to do. All it's supposed to do is when you click a button the target movie clip plays frames 2 - 10 and the previous movie clip plays frame 11 - 20. Not sure what's the problem here.
I know the Post Title is not much explicative but I didn't know how to summarize my problem. Here it is in full version: I'm making a card game, and I have all the vectorial graphics for the cards. I have a class named Deck and one named Card. When I create a new Deck I have this constructor
After a click event I want to dynamically create 2 movieclips with the sequential number in their name, e.g. mc_001 & mv_001 so that I can 'link' them together later on.How can I create a movieclip with a dynamic name?I am trying to use this at the moment:Code:var movieclip["name"+dynamicNumber]:MovieClip = new MovieClip();I can't use an array unless someone can tell me how to access it across multiple classes...
this is a wierd problem I am facing in flash I need to create a dynamic global variable where the variable's name is stored in another variable. say I need to create a global variable , _global.fam , but "fam" is stored in a variable temp="fam";
now how can I declare the global variable 'fam' using the variable temp.
But the loophole here is that after creating the global variable I should be able to access the variable as
im trying to dynamically create buttons...here's an example scenario -> off stage is a movie clip called "originalButton_mc"I want to use a loop to duplicate this movie clip 25 times, and each one should be able to perform a unique onRelease function ex.
Code: for (i = 0; i<25; i++) { var newButton_mc = originalButton_mc.duplicateMovieClip("button"+i, i+1); newButton_mc._y = i*22; newButton_mc._x = 10;
[code]....
the problem with the above code is that when I click my new buttons it always traces 25...because, clearly - my code is wrong, and the onRelease is getting rewritten for each button - hence its left with the last i ... 25.
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]
Back 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?
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..
I would like to know if its possible to create a background flash that is dynamic while keeping the bars static?for an example checkI would like someone to build a home page for me to be exactly like the samsung site above except using my images. Is this possible?