ActionScript 3.0 :: Telling Compiler To Reference MovieClip From String
May 3, 2010
I'm trying to keep my code succinct by naming my section labels the same as the buttons that navigate to them. I've also put the contents of each page in a movie clip of the same name with suffix _mc. The following code successfully traces the name of the movie clip, but how do I tell the compiler that I want to reference the movie clip whose name is held in the string, rather than the string itself.
function clickSection(evtObj:MouseEvent):void {
currentContent = currentLabel + "_mc";
trace(currentContent);
currentContent.alpha = 0;
gotoAndStop(evtObj.target.name);
mainNav_mc.gotoAndStop(evtObj.target.name);
View 3 Replies
Similar Posts:
Sep 3, 2007
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?
View 9 Replies
Feb 21, 2009
I want to send a string to a function and then, via the string reference a Sprite. Are theire any other ways to adress a sprite with a String value?I thought this[myString].alpha = 0.5; was gonna do the trick but i keep getting (1010: A term is undefined and has no properties.). I tried every possible solution it feels like. Delaring Strings locally and Global...but i can�t get it to work. And the String is well spelled btw![code]
View 3 Replies
Apr 29, 2009
I'm moving a movie clip using actionscript (as2) instead of a motion tween (because I want to save file size) and I have this code on the first frame of the main timeline ("stone" is the movieclip instance name) and it tells the movie clip how many pixels to move in the x direction:
Code:
xTargetstone = 600;
I have this code on the movie clip itself ("stone" is the mc instance name) to handle the actual moving of the movie clip:
Code:
onClipEvent (enterFrame) {
xstone = getProperty(_root.stone, _x);
movestone = _root.xTargetstone - xstone;
setProperty(_root.stone, _x, xstone + (movestone/5));
}
The movement works fine, but the issue is that it starts out fast and then slows down over time (even though that amount of time is small). The result is that the movie clip seems to wiggle and vibrate before it stops. Is there a way for me to change the code so that it doesn't wiggle and vibrate? perhaps something with the math I'm just not totally understanding? I would like a nice consistent motion from start to finish, while being able to set the time it takes to move etc.
View 4 Replies
Feb 16, 2004
I am making a game and need to know how much a particular mc is covered by other mc's placed randomly on the screen. Is there a way to tell how much is left seen of the mc as it's slowly being covered by other mc's?
View 3 Replies
Apr 13, 2011
I'm developing a compiler generator in actionscript 3 with flash builder 4. I need to find a way to:
1.- Execute code inside of a string.
it could be very complex code, not just trace() functions but complete code
2.- Another alternative can be to tell to the actionscript compiler to compile the code autogenerated from my compiler generator.
View 2 Replies
Feb 28, 2012
I have a movieclip on its own layer, with the intention of using it as a background to all the other layers. It is simply a black square with the alpha at 60%. There must be a relatively simple way of telling this movieclip to either tile or stretch to cover the whole of any page it loads into.
View 1 Replies
Apr 12, 2009
i have a movieclip within a movieclip within a movieclip... i want to simply tell flash to play that movieclip once i click on it.. however, i get an error saying "1120: Access of undefined property tl_character" when i try to publish the file..[code]i know there might be a solution by using a custom class for "police1" but i'd like to know how i could play that movieclip using a function thats written on the main timeline..
View 2 Replies
Apr 12, 2011
i'd like to do something like this:
[Code]...
of course i could hardcode that - but if I then change something about the as file, the linenumbers won't be correct anymore, or maybe i rename the as file and so on. It'd be great to be able to create that string somehow using compiler directives. Is this Possible in an AIR application created with ActionScript 3.0?
View 1 Replies
Mar 17, 2010
I have a movieClip called "mcUnitedStates" inside another mother movieClip.
I have two instances of the mother movieClip. One entitled "mcWorldMapTop" on its own layer and the other entitled "mcWorldMapBottom" on its own layer.
I thought having two instances of the same movieClip and applying different filters to the mcUnitedStates movieClip in each.
Error I get is: Access of unidentified property mcWorldMapBottom
I'm doing this because the colorTransform is making the glow the same color as the colorTransform instead of the color I want the glow to be.
I am getting a Compiler error with this code:
stop();
//
import flash.display.Sprite;
import flash.filters.GlowFilter;
[Code].....
View 5 Replies
Aug 19, 2009
I have a very simple class as so[code]...
I'm loading the mp3 from a compiled swf so I don't have to compile it every time, but am having a nightmare playing it.
Even with loader.loaderContentInfo.content, I can't seem to access my play methods.
I've tried all sorts of casting combinations from the parent timeline, but no luck.
View 4 Replies
Aug 19, 2011
I'm coding an AS3 web app which needs to access the webcam. The webcam code works fine apart from my initial attempt to detect whether a webcam is plugged into the pc. I'm trying to use Camera.isSupported as specified in the Adobe docs but I get a compiler error telling me 1119: Access of possibly undefined property isSupported through a reference with static type Class. BriefingScreen.as /ADAPT_PSA/src line 147 Flex Problem I can get around this by compiling without strict checking but this seems a little clumsy...
View 1 Replies
Aug 5, 2011
Its stated in adobe site that the Flash Builder 4 compiler is indeed 25% more performing than the previous Flex Builder 3 compiler.
How can I confirm that?
For example if I make a simple application on Fx3 and the same on Fx4, then how would I compare the compiler performance using my project?
View 1 Replies
Jul 24, 2009
I've got a set of arrays being dynamically generated with paths to nested movieclips. The paths are coming in as strings, and I can't seem to get them to work as movie clip instance variables.as example, a string would be:
siteMC.b1MC.b1f1MC.rMC
(that path works fine outside of the array)
How do I get that kind of nested path from the string to something flash wont spit out as null?
View 4 Replies
Apr 6, 2012
I cant get the this[] keyword to work. I want to send a string to a function and then, via the string reference a Sprite. Are theire any other ways to adress a sprite with a String value?I thought this[myString].alpha = 0.5; was gonna do the trick but i keep getting (1010: A term is undefined and has no properties.). I tried every possible solution it feels like. Delaring Strings locally and Global...but i can�t get it to work.
PHP Code:
//Nothing Worksthis["myString"].alpha = 0.5;this[myString].alpha = 0.5;//Anyway to reference a Sprite with a String?
View 3 Replies
Feb 15, 2011
is it possible to create a new reference to an array by using it's varname ?
e.g.
private var _myArray:Array = new Array("a","m","d");
...
function getReference(_varName:String):void
{
[Code]....
View 2 Replies
Feb 21, 2009
I want to send a string to a function and then, via the string reference a Sprite. Are theire any other ways to adress a sprite with a String value?I thought this[myString].alpha = 0.5; was gonna do the trick but i keep getting (1010: A term is undefined and has no properties.). I tried every possible solution it feels like. Delaring Strings locally and Global...but i cant get it to work. And the String is well spelled btw!
PHP Code:
//Nothin Worksthis["myString"].alpha = 0.5;this[myString].alpha = 0.5;//Anyway to reference a Sprite with a String???
[code]....
View 2 Replies
Apr 2, 2009
Is there, uh, a way to use the value of a string to reference a variable name?
I'm trying to dynamically assign XML node names and attributes using a string value, I tried something like this:
Code:
var sItem:String = "book"; // to be dynamically assigned
for (var i:uint; i < _xml.book.length(); i++) {
aList.push(_xml.(this[sItem])[i].@title);
[Code]....
View 2 Replies
Jul 30, 2009
I'm trying to refer to a specific XML node dynamically. Is there any way to convert a string to reference properly? Or is there any other way?
So I want to be able to write...
Code:
trace(myXml.fruits[1].name);
...but have the "fruits[1]" stored in a variable so it can be changed easily. It might look something like...
Code:
var special:String = "fruits[1]";
trace(myXml.special.name);
...but that doesn't work.
View 1 Replies
Jul 6, 2010
I'm wondering, and hoping, if I can access and use a specific instance of an object if I only have the name of the object instance in a string? The code below perhaps explains it a littler better.
[Code]...
View 2 Replies
Sep 6, 2010
I have movie clip Ball what has public function glow[code]...
full access to Ball is MainMenu.ImagesPanel.Ball
I want to send command from server in text like:
string="MainMenu.ImagesPanel.Ball.glow"
How to convert sting to structure?
View 0 Replies
Feb 7, 2011
I want to reuse these two functions for about 10 items that need to be dragged and dropped. I need to reference 10 Boolean variables on the main timeline by building strings in the functions to make up the Boolean names so I can reuse the functions. Check the coded in red. [URL] Fla is above
[AS]
stop()
var startX:Number;
var startY:Number;
[Code]....
View 1 Replies
Feb 5, 2010
I am trying to set the value of some static vars but I need to reference the class with a string rather than a proper constructor. In AS3 I can do this with:
var ref:Class = getDefinitionByName(classDefinitionAsString) as Class;
ref[varNameAsString] = newValue;
I can't find an equivelant approach that will work in AS2 though. I have tried:
var ref:Object = new [classDefinitionAsString];
ref[varNameAsString] = newValue;
This seems to just create an Object and as the vars that I am trying to access are static I don't really want to be using 'new' I just want to reference the vars.
View 1 Replies
Jan 22, 2010
I need to compare a number with a element in a Array(curModeDisplay), I can trace the element and see it without problem. But when I try to compare the inside element with a String, it didn't work. Why?
ActionScript Code:
curModeDisplay = new Array(); \this is the Array I need
for (var tvM:XMLNode = tv.firstChild; tvM!=null; tvM=tvM.nextSibling){
curModeDisplay.push(tvM.childNodes); \received element fine here
}
trace(curModeDisplay); \ This works fine. Array displays correctly
When I need those elements from the Array(curModeDisplay) and try to make some comparison work, it did not work:
ActionScript Code:
function DigitCompare():Void{
for(var index in curModeDisplay){
if(curModeDisplay[index]=="11265"){ //it seems didn't work here
[code]....
Is that because the element in the Array is reference to the XML node, and "11265" is String. If so, how should I fix this problem. The "11265" will be changed to any named String type variable in the future.
View 4 Replies
Dec 12, 2010
how to make a simple AS3 class.I've made a simple calculator application that allows you to add, subtract, multiply, and divide after entering 2 values into their respective text box.The problem, how ever, is once I moved it into it's own class, I cannot figure out how to reference the text fields. I have the movie clips referenced just fine, but, I cannot figure out the text fields.Here are the errors it's spitting out:
Code:
1120: Access of undefined property Number1_txt.
1120: Access of undefined property Number2_txt.
1120: Access of undefined property finalValue_txt.
And it does that for each instance of those in the Calculator.as
Main.as
Code:
package {
import flash.display.MovieClip;
public class Main extends MovieClip {
[code]....
View 5 Replies
Jan 19, 2011
So i have an external text file organized like this:
/* $file: data.txt */
&title0=Sacrum
&detail0=Detail text for Sacrum
&title1=L5
[Code].....
There are 28 of these 'title' and 'detail' pairs. The 'title' text is to fill a dynamic text box and the 'detail' to fill another dynamic text box depending on which section the user is mousing over.
My issue is getting the text from the file stored into arrays. For my test loop I keep getting undefined as the stored value, and i know it has something to do with converting a string value to object..
var lv:LoadVars = new LoadVars();
lv.onLoad = handleDataLoad;
lv.load('data.txt');
function handleDataLoad (success:Boolean) {
[Code]....
View 1 Replies
Jul 17, 2011
I am trying to make a reference to a movieclip instance that is in another movieclip.
Here's the deal: I have a main timeline for different pages of a website...then within that I make all of the art on each page into a movieclip so I can do animations every time that main timeline frame is called to, yet still keep my main timeline clean.
Within one page's movieclip I have a few buttons that I want to use to go to other pages by referencing them on the main timeline.I have been using this: (home_about is the about us button on my home page, and frame 31 is on the main timeline).
home_about.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_6);
function fl_ClickToGoToAndPlayFromFrame_6(event:MouseEvent) :void
{[code].............
Since this home_about is within another movieclip,I get the access of undefined property error. Do I need to change the code I've pasted above or add in variable definitions to fix this?
View 1 Replies
Nov 30, 2010
I have the following code:
var myPercStr = myStr.text;
myPercStr= myPercStr.toString();
var myPerc = Number(myPercStr);
I am trying to get the value of a text field which is created by the user pushing a pin-pad. This text field is a string which is joined() from an Array of the sequence of pin-pad entries. Now my problem is that Flash will not convert the .text text field into a string with which I can use the value to convert to a Number and perform math on it.
View 1 Replies
May 20, 2009
I am trying to create an interactive graphic. Basically, it's three squares layered on top of each other, with a large square in back, a medium square centered in the middle of the large square, and a small square in front centered in the middle of the medium square.
When you roll over the medium square, say, it expands to almost the size of the large square and some text fades in, and the small square on top of it fades away. When you roll off of the medium square, it goes back to it's smaller size, and the small square fades back in.
Currently, I have the actionscript in the movieclip to make the medium square get larger and smaller (and the text fade in), but I need to somehow reference the instance of the small square movieclip to hide it when I roll over the medium movieclip.
My actionscript for the medium square activity, currently:
Code:
stop();
this.onEnterFrame = function(){
if(rewind == true){
[Code]....
how to have this rolling over action get rid of the small square and then bring it back on roll out.
View 2 Replies
Feb 21, 2010
I have built a movieclip (parentMC) that houses two movieclips within it (mcA, mcB).
in mcA, i'm dynamically attaching movieclips from the library through a loop.
in mcB i'm trying to reference a particular movieclip from mcA via "_parent.mcA". Doesn't seem to be working. However, when i reference said movieclips from the loop within mcA - or even parentMC, it works fine.
View 2 Replies