ActionScript 3.0 :: Adding A Dynamic Number To A Instance Name?
Jan 11, 2010
My name is Bryan i am 17 years old and i'm from the Netherlands. As i am trying to become a web design and developer i decided flash was a MUST to know, so i started trying flash and messing about. Now i'm trying to get into Action script 3.0 deeper. Currently i am trying to fix an externaly (XML) loaded image gallery for my self, except i'm a little stuck right now.Up to now all my code has worked. I've got 3 UILoaders set up for 2 jobs: Loading thumbnails (2 of them) and the other is for loading a 'full' version. I got that working. Except if i get huge images like a wallpaper etc. it screws up the size, so i set scaleContent to true.
- Set all the images dynamicly, with that i mean it loops trough all the thumbnails and gets the first 2, it dumps them into the UILoader wich is already the part i am failing at XD
- Check for the width and the height of the image (wich i either will include in the XML document or can i use something like: XMLData.image[ *number here* ].img_thumb.width (as a example)?
- Check if these are less than the UILoader's size and if they are less dissable scale content, if they are more enable it
So as i said im already failing at trying to dump the images in the thumbnails.I've got the following setup:
Root document has a MC: mc_content.
Inside mc_content we have: loader_image (full size of the image loader)
loader_thumb1 and loader_thumb2.
So what i want:
- Load the XML (works)
- Set some limits using variables (works)
- Start a for loop (works)
- get the thumbnail for the current image number (wich is a variable set and maintained in the for loop) (works)
- load the image into the loader_thumb *insert current image number here* (fails)
here is my current XML function:
ActionScript Code:
// Function that is called upon loaded complete
function xmlLoaded(event:Event):void{
// get the XML Data from the file
The buttons are used to jump to a specific (root-)frame (based on a variable); they're all nested inside a moviclip, each on its own layer, and for every frame there's one button more showing (imagine a staircase). Now, is there a way for a script that works for all buttons without adding the specific frame number every time? I started working with
ActionScript Code: on (release) {_root.gotoAndStop(_root.VAR+3);} where VAR also defines, how many buttons are shown (eg. frame number of the button-MC). +3 is just for the frame number on root. That way, of course, all buttons eventually lead to the same frame, or more precise: only the last button shown will lead to the correct frame.
I have a library object (SomethingMC) which extends a custom class (Something). Something, in turn, extends MovieClip.If adding SomethingMC to the stage within Flash CS3 IDE, is it possible for it's super class (Something) to assign an instance name from a class constant (Something.THE_CONSTANT)?
The above does not work. It throws Error #2078: The name property of a Timeline-placed object cannot be modified. if the instance is assigned a name in the IDE, and it just doesn't work if no name is assigned in the IDE.
I am really not sure what to call this problem / search for to view an old solution. So if I am being redundant, simply link me to an old thread / lock this.[code]...
Ok, Background. I have two objects both of which im spawining in though code. We will call them bullets and wolves. They have their own .AS files which tells them everything they need to know about themselves. I figured i would do most of the hit testing on the bullet.AS file, hit testing against the wolves as there were going to be a set number of wolves but not a set number of bullets.o, I named them by running a loop and putting the linenewWolf.name = i.toString();Yes, new wolf is a declared variable, and i is the name of the variable that makes the loop run. I also have a test in it, and it works fine.
However, The hit testing is where i come into an issue. Remember, its on a seperate .AS file. The wolf maker and namer is on the main flash page.The hit testing function isif(this.hitTestObject(a)){i changed up my variable name to run a second loop. first variable name is "i" and the second variable name is "a"And for some reason i get a type error 1034, which from what i understand is an error that you get when two instance names are the same. Also, If possible, i would like to add letters to the name of the object, but im not sure if flash will let me as i belive the code would look something like this
I want to add a new instance of a MovieClip named chair_mc in my .as file but am not sure where to place it. I also want to bring in two other MovieClip symbols but am not sure where to place this. This is the code:
When addressing nested movieclips like so: _root.movieclip.movieclip.variable they need to have an instance name set, otherwise they count as undefined. So I can set that in the properties no problem, but when deleting it from the stage and then readding (manually or by actionscript) the instance name is gone thus I can not address nested clips by action script.
I don't understand how this will work then, since every time I add a clip by code it will have no instance name. The only alternative for me so far was keeping the clip on the stage the whole time, just out of bounds or invisible so I can still do stuff like _root.movieclip.movieclip.variable or _root.movieclip.movieclip.gotoAndStop(2).
i have a preexisting instance known as gamelevel. When the screen scrolls, gamelevel.x is modified. When the player shoots a projectile, this projectile is not moved along with the screen, because it is simply added using the addChild. How can i add the movieclip, but have it contained within the gamelevel instance?
I'm stuck on this annoying bug of Flash:to animate a character i have different graphic symbols of hand positions inside a single container graphic symbol; that way instead of having to swap different symbols while animating and tweening, i just have to change the number on the "single frame" input box on the properties of the symbol.
It worked fine a few sessions ago, but now it won't let me change the frame number if there's a tween before that keyframe; tha keyframe isn't participating on any tween, and may even have some frames between the previous tweening one. The only way it will change is if i remove the first tween or add a blank keyframe between them, wich of course isn't an option when animating... i know it would work if i add a new layer and continue there, but it'll add a lot of mess to the already busy timeline.
The strange thing is that it remains working on some frames, from the previous session, and if a cut and paste them i can change the frame number freely; but if i try to build a secuence from scratch, it won't let me, even on a new document.
As you can see it equals a number, (This number is subject to change throughout the project.How can I add all of the digits in this number up into a new variable.The number is "1382" so the new number would be all the digits added together... 1+3+8+2, "14"
I have an array, strictly numbers, how could I add... say array[0](value=2)+array[1](value=1) to equal 3? What I come up with is an undefined error, or not a number...
I know this is one of the most basic things, but I am having trouble adding an instance of a symbol to the stage with action script in Flash CS4. I have a "fireball" symbol and at the beginning of my code I say: var myFireball:MovieClip = new fireball; addChild(myFireball); But it says : "1180: Call to a possibly undefined method fireball."
Is it possible to add a textField dynamically but have different instance name each time this is created? In other words if I have a button that whenever its click it will add a textField to the stage and assigns a new instance each time this is added.
Code: button.addEventListener(MouseEvent.CLICK, addField); var inputWidth = 200; var inputHeight = 20;
I have a ComboBox, with it prepopulated with the States.When I have a variable that says it should be pre-selected to for example CA, how do I do that, without haveing to figure out the index number for every single state?
I imagine this to be a simple question, but I don't seem to be able to figure it out being knee deep in code !!I have this variable :-var blackCredit = creditBlack.text;When I try to add or subtract 1 from the amount in the text box, like this :-blackCredit += 1;and then update the text box with the new value :-creditBlack.text = blackCredit;It's adding the 1 to the end. i.e. 16 becomes 161, instead of 17..
Right now it generates a random number from between -1022 and -16 (positions along the x axis).
However, sometimes the skyline movie clip only moves a few pixels and looks boring.
I added 200 pixels to the movement (Math.random() * (-1022 - -16) +200 ) and it looks better. However, sometimes this slides the movie clip past -1022 or -16 and off the stage.
How can I set the value to +200 without passing -1022 or -16?
Having some issues with some variables not adding together to make a new number. Instead they are appending to each other as if adding characters onto a string rather than a number. Here is my code.
ActionScript Code: var dispenserPos:Object = {x1:"41", y1:"180", x2:"283", y2:"180", x3:"530", y3:"180", x4:"775", y4:"180"}; function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min; return randomNum; [Code] .....
It should be tracing out 388 instead of the numbers appended onto one another.
I have addChild(ball); in a for loop creating many balls. I also have addChild(number); I want number to be placed in the ball mc. So ball.addChild(number);. However the whole thing freezes and takes longer than 15 seconds to load. Is there something wrong with adding number, a textfield, in ball?
If I want to add or substract number variables, how can I name them to indicate they are numbers and how can I do basic math with them? If I try adding common variables like
_root.answer = _root.var1+_root.var2; and if var 1 is = 1 and var 2 is = 2
I have created a movie clip on the stage and in symbol properties I have checked "Export for ActionScrip" the MC name is "slide" and the class is "slide" base class is flash.display.MovieClip.
When I test the movie I get this error. TypeError: Error #1009: Cannot access a property or method of a null object reference. at main_fla::MainTimeline/frame1()
Here is my code: PHP Code: var slide = getChildByName("slide"); //add instance from library? function slideRollOver(event:MouseEvent):void { // trace("OK"); } slide.addEventListener(MouseEvent.ROLL_OVER, slideRollOver);
I am trying to add a simple navigation to an instance of a button on my stage through AS3. my code is below... I have used the same code in AS2, but i must be leaving something out in AS3..
I have a script to upload images to my server. I want to generate a random number to add to the users file name incase they upload an existing name and write over it. I have created a var called file nameAddOn and it gets a random number. When I trace the var nameAddOn I get the number, but when I upload the file it doesent sent the nameAddOn var with the file name. I cant see anything wrong with the code.:[code]....
just learning as3 for flex. i am trying to do this:
var someNumber:String = "10150125903517628"; //this is the actual number i noticed the issue with
var result:String = String(Number(someNumber) + 1);
I've tried different ways of putting the expression together and no matter what i seem to do the result is always equal to 10150125903517628 rather than 10150125903517629.
It all works fine. However, I am trying to put in links on the stage outside of SSP (i.e., Home, Gallery, About, etc.) as shown in this example website [URL]. When I do, the stage is truncated and part of SSP is skewed off the page.
How do I make sure that my stage containing text and SSP is captured as the SWF?