Passing Class Names As A String...
Hi People, I need to pass a class name to a function acting as a class 'instancer' (bad english, sorry)
I've tried [] and eval but no result...
one of wrong cases I've tried:
Code: showModule = function(moduleClass:String){ var module = new eval(moduleClass)(_level0.module_container); } thanks
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 02-08-2007, 06:42 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Getting String Names To Be Variables
This is easy for all you gurus' out there, but it would sure help a novice if someone could give me some insight. I need to take a string name and evaluate it as a variable:
For example, if I was in a loop and wanted to make all the movie clips in the loop turn invisible I would think I would write the following if my mc's were content1, content2, content3..etc:
for(k = 0; k<= 5; k++){
"content"+k._visible = false;
}
but that doesn't work. Why does it work to evaluate the name with the count in a loadMovie command like:
for(k = 1; k<6; k++){
loadMovie("tester"+rarray[k]+".swf", "content"+k);
content+k._visible = false;
}
but not in the statement I used. Thanks for helping me.
String Names? How Can I Get This To Work?...
i want to set variables named word1, word2 ect in first frame, then later i want to have a text box and be able to get the word2 and stuff to show by saying
text=word add i then have i be a number so if i was 1 i could get word1, which lets say in the first frame word1="hello";
anyone know how to do this? and do you get what im saying?
Getting All Flashvars Names Or Passing & As A Var
Hello,
I have to pass to a flash script a parameter like this one
Code:
<param name="FlashVars" value="mygoto=http://www.website.com/file.php?language=en&iduser=30" />
The problem is that if I want to access mygoto variable, I get only this string
Code:
http://www.website.com/file.php?language=en
Is there any way to get all the string including & ?
Is there any way to get all the variables that come from HTML ?
Regards
Passing Instance Names To Functions
Howdy!
I'm new. Not very bright either. Learning functions after wandering in the darkness for a very long time. I have an instance on the stage that was created using the duplicateMoveClip method. Users can drag these instances to positions on the stage for later use. It would be nice to have them simply pass off the task to a function in the main timeline, but I can't get it to work.
Here's the function:
code: function SensorDrag(ClipName:String){
_root.ClipName.startDrag();
}
Here's the actionscript for the instance:
code: onClipEvent (load) {
var ClipName:String = this._name;
trace (ClipName);
startX = this._x;
startY = this._y;
onClipEvent (mouseDown){
_root.SensorDrag();
}
If I can get this to work,, I should be able to tackle more complex issues. What do I need to do?
Passing Names As Arguments (if Those Are The Right Terms)
Gosh. I hope I can manage to explain what I’m trying to do here.
Imagine I have a column of text input fields and a checkbox next to each of those fields - something like this:A text input field called ‘name’ and a checkbox called ‘nameCb’ to the right of it
A text input field called ‘address’ and a checkbox called ‘addressCb’ to the right of it
A text input field called ‘phone’ and a checkbox called ‘phoneCb’ to the right of it, etc, etc, etc
Now, let’s say I want each respective checkbox (unchecked by default) to automatically get checked as soon as the field WITH A SIMILAR NAME looses focus (or whatever).
Basically, I want the code to dynamically:
read the instance name of the field
store that instance name in a variable as a string, or whatever
add “Cb” to the end of that name
perform an operation to the symbol that has the resulting instance name (field name + "Cb")
For example, as soon as a field called ‘address’ looses focus the code acquires the instance name ‘address’ adds ‘Cb’ to the end of it, which results in a name ‘addressCb’ and finally applies the function to a checkbox with an instance name of ‘addressCb’
Perhaps this particular problem can be approached differently, but still I’d very much like to learn how to manipulate symbols based on their dynamically calculated names.
Does anyone know how to do this type of thing?
Please let me know if it needs clarification.
Thank you
Passing Instance Names To A Function
Hi guys. New at this.
I want to create a function that animates a dynamic text field. I will create a few instances of an empty movieclip and give them all instance names. Then for each instance, I want to do create a text field filled over time by the function.
Question is this:
How do I tell the function what the name of the textfield is? I'm having problems with paths. I thought I could use this.textfieldname.text = 'texthere' --- but that doesn't work. It seems I need an absolute path:
PHP Code:
_root.something.textfieldname.text = 'texthere';
Can I pass the "something" as a variable to the function? How?
Bless all who respond,
J.
Passing Interval Names As Parameters
Im stumped :?
Im trying to use setInterval to save some processor power but in order for that to happen I have to figure out how to clear the intervals Im setting.
In this case Im trying to clear each interval by passing the interval's name to a parameter of the function it is running. The code is below:
ActionScript Code:
// function being run :)
fadeIn = function(clip, alphaCeiling,fadeIncr, intervalName){
if(clip._alpha<alphaCeiling){
trace("yes...yes...yes!");
clip._alpha+=fadeIncr;
}else{
trace("ohhh no!");
clearInterval(intervalName);
}
}
this.container_mc.pictura_mc.loadMovie("my.jpg");
preloadJpg = function () {
if(textBk_mc._currentframe>=14){
textFade = setInterval(fadeIn, 40,t.some_txt, 99, 11, textFade);
if(container_mc.pictura_mc.getBytesLoaded()>100 && container_mc.pictura_mc.getBytesLoaded()>=container_mc.pictura_mc.getBytesTotal()){
container_mc.setMask(mask0_mc);
updateAfterEvent();
mask0_mc.play();
linesInterval = setInterval(fadeIn, 40, container_mc.lines_mc,15,4,linesInterval);
loading_mc.unloadMovie();
clearInterval(preInterval);
}
} else {
loading_mc._visible = true;
}
};
preInterval = setInterval(preloadJpg, 20);
Can anybody see anything Im doing drastically wrong or is this just not possible :?
Thanks in advance for your help
Passing MovieClip Names To Different Buttons/MCs
I have 5 MCs on stage, acting as buttons (ChoiceA_mc to ChoiceE_mc) - referred to in a loop (instead of individually naming them). I have to disable all these MCs when one has been pressed & reactivate them when the 'Next Question' button is pressed. My script works but I think there is a much more efficient way of doing it - so I don't have to repeat the 'for' loop 3 times.
I'd be grateful if anyone can show me a more efficient way of doing this. Script is :
next_btn._alpha = 20;
next_btn.enabled = false;
///////////////////////////////////////
// define content and actions for each answer button:
var choice:String;
for (var i = 65; i<=69; i++) {
choice = "choice"+String.fromCharCode(i)+"_mc";
this[choice].letter_txt.text = String.fromCharCode(i);
this[choice].id = String.fromCharCode(i);
// when this answer is chosen:
_root[choice].onRelease = function() {
for (i=65; i<=69; i++) {
var allButts:MovieClip = this._parent["choice"+String.fromCharCode(i)+"_mc"];
allButts.enabled = false;
allButts.gotoAndStop("_up");
}
next_btn._alpha = 100;
next_btn.enabled = true;
};
}
next_btn.onRelease = function() {
this._alpha = 20;
this.enabled = false;
//show all 5 answer btns again:
for (i=65; i<=69; i++) {
allButts = this._parent["choice"+String.fromCharCode(i)+"_mc"];
allButts.enabled = true;
}
};
Names From Extenal XML File To String Variable
I'm new to AS 3 and I have this problem:
I want to make a dynamic menu with some buttons. Names(labels) of these buttons are in external XML file. Parameters of buttons are specified in main file .fla. I have also actionscript file .as (it works without errors), which makes these buttons with parameters specified in main file .fla .And I want to GET NAMES OF BUTTONS FROM EXTERNAL XML FILE TO STRING VARIABLE, but here is the problem. How could I do that? Please help.
Here are my scripts:
------------------------------
this is in main file .fla:
import flash.events.*;
import flash.net.*;
import flash.text.*;
//declarations
var NumberofButtons:Number = 3;
var xposition:Number=25;
var textBut:String=new String;
//load XML file names.xml
var navData:XML;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
loader.load(new URLRequest("names.xml"));
function onComplete(evt:Event):void {
try {
navData = new XML(evt.target.data);
trace(navData);
loader.removeEventListener(Event.COMPLETE, onComplete);
loader.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
} catch (err:Error) {
trace("Could not parse loaded content as XML:
" + err.message);
}
}
function onIOError(evt:IOErrorEvent):void {
trace ("An error occured when attempting to load the XML " + err.message);
}
//parameters of buttons
for (var i:Number=0; i<NumberofButtons; i++) {
//text of button label - HERE IS PROBLEM MAYBE
textBut= navData.buttons.button[i].text();
function positions():Number {
xposition=xposition+75;
return xposition;
}
// CreationBtn(hightofButton, widthofButton, colorofButton, colorofTextLabel,
// textLabelofButton, xpositionofButton)
var btn:Sprite = new CreationBtn(25,50,0xFFFF00,0x000000,textBut,positi ons());
addChild(btn);
}
----------------------
here is XML file - names.xml
<buttons>
<button>Animations</button>
<button>Photo</button>
<button>Books</button>
</buttons>
----------------------
actionscript file is CreationBtn.as and has no errors
----------------------
Loading A String From A Embed Tag Containing No Variable Names
Hi, I'm develloping a little image loading application for a client.
the same swf has to be reused over and over to load the files.
They are passing me the image location in the embed tag but they are not using the usual
flash.swf?path=folderpath&img1=image1.jpg&img2=ima ge2.jpg&img3=image3.jpg
instead they are using this format :
flash.swf?/folderpath/::SPLIT::image1.jpg::SPLIT::image2.jpg::SPLIT::ima ge3.jpg
do you know how I can read those variables into my flash file ?
any help would be greatly appreciated.
Thank you.
Names From Extenal XML File To String Variable
I'm new to AS 3 and I have this problem:
I want to make a dynamic menu with some buttons. Names(labels) of these buttons are in external XML file. Parameters of buttons are specified in main file .fla. I have also actionscript file .as (it works without errors), which makes these buttons with parameters specified in main file .fla .And I want to GET NAMES OF BUTTONS FROM EXTERNAL XML FILE TO STRING VARIABLE, but here is the problem. How could I do that? Please help.
Here are my scripts:
------------------------------
this is in main file .fla:
import flash.events.*;
import flash.net.*;
import flash.text.*;
//declarations
var NumberofButtons:Number = 3;
var xposition:Number=25;
var textBut:String=new String;
//load XML file names.xml
var navData:XML;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
loader.load(new URLRequest("names.xml"));
function onComplete(evt:Event):void {
try {
navData = new XML(evt.target.data);
trace(navData);
loader.removeEventListener(Event.COMPLETE, onComplete);
loader.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
} catch (err:Error) {
trace("Could not parse loaded content as XML:
" + err.message);
}
}
function onIOError(evt:IOErrorEvent):void {
trace ("An error occured when attempting to load the XML " + err.message);
}
//parameters of buttons
for (var i:Number=0; i<NumberofButtons; i++) {
//text of button label - HERE IS PROBLEM MAYBE
textBut= navData.buttons.button[i].text();
function positions():Number {
xposition=xposition+75;
return xposition;
}
// CreationBtn(hightofButton, widthofButton, colorofButton, colorofTextLabel,
// textLabelofButton, xpositionofButton)
var btn:Sprite = new CreationBtn(25,50,0xFFFF00,0x000000,textBut,positi ons());
addChild(btn);
}
----------------------
here is XML file - names.xml
<buttons>
<button>Animations</button>
<button>Photo</button>
<button>Books</button>
</buttons>
----------------------
actionscript file is CreationBtn.as and has no errors
----------------------
Passing Variable Names & MC Properties To Functions
I'm having trouble getting a function to understand the properties of an MC I'm passing to it. I'm using this...
Code:
function repelObj(repelTarget) {
this.onEnterFrame = function() {
var xdistance = repelTarget._x-this._x;
var ydistance = repelTarget._y-this._y;
distance = (xdistance*xdistance)+(ydistance*ydistance);
force = 9999999999/(distance*distance);
apply = force/distance;
movex = (xdistance*apply)+movex;
movey = (ydistance*apply)+movey;
repelTarget._x += movex;
repelTarget._y += movey;
}
What I'm passing to it is the _root path of the name of a duplicated MC. When I use trace(repelTarget) to tell me the name of the variable, it works fine, and I've double and triple checked that the MC exists on the stage, my having the MC trace its name when created. Yet when I tell it to trace (repelTarget._x), I get "undefined." Why can my function tell the MC's name, but not its properties?
EDIT: I think I've just figured out it has something to do with getting the relative path right, since the full MC instance name turned out to be something like _level10.etc.etc. Hope that helps.
Passing Movie Clip Names To Functions
Hey, i'm trying to create a game where I need to be able to spawn a bunch of different kinds of enemies so i figured i'd write a function to create an enemy. I've attached what I came up with.
now i'm assuming the problem is with these 2 lines. Am I allowd to pass data to a function and use it this way? Is there a special way I'd go about doing it? Can anybody suggest a better way to write this code? Thanks.
this.createEmptyMovieClip(_root[enemyName], this.getNextHighestDepth());
_root[enemyName].attachMovie(_root[enemyPicture], "enemyBlue1", this.getNextHighestDepth());
Attach Code
var enemyCounter:Number = 0;
function createEnemy(enemyName, enemyPicture, xvar, yvar){
this.createEmptyMovieClip(_root[enemyName], this.getNextHighestDepth());
_root[enemyName].attachMovie(_root[enemyPicture], "enemy"+enemyCounter, this.getNextHighestDepth());
enemyCounter++;
_root[enemyName]._x = xvar;
_root[enemyName]._y = yvar;
}
createEnemy("slimeSmall", "enemyBlue", 200, 200);
Edited: 05/21/2007 at 01:55:51 AM by Gooms9
Passing Dynamic Instance Names In 1 Param
I am trying to pass a MC target to a function through one parameter... The problem is that there are multiple variables that are requiered to reference the MC properly.
is there a way to conjugate all my variables and pass the target reference to my function in one param? If so, how does it need to be sent to the function and how does it need to be reference from the function to an actual MC.
Thanks
Question About Passing Instance Names Through Vars
Here is what I am trying to do.
I set a variable. the variable contains an instance name for a movie clip.
Later on another movie clip plays and when it gets to a certain point, I want to to be able to tell the another clip, whose instance name is stored in a variable, to play.
I've tried
var clip_to_play = "playme";
_root.eval(clip_to_play).play();
It doesn't seem to work. Any help is appreciated.
Thanks
Creating Functions And Passing Instance Names To It.
I have a bit of script that I'd like to turn into a function. I need to call this function from a button located within a movieclip (this clip is the one the function will act upon) I need to pass the instance name of this clip into the function. Here is what I have, placed on the main timeline, but it's not working:
Code:
function moveWindow(window) {
_root.window.gotoAndPlay("Open");
_root.createEmptyMovieClip("windowAnchor_mc",0);
_root.windowAnchor_mc._y = _root.window._y;
var winanch:String = _root.windowAnchor_mc._y ;
trace (winanch);
_root.window.onEnterFrame = function() {
_root.window._y -= (_root.window._y-_root.News_Window_mc._y)*.5;
_root.News_Window_mc._alpha = _root.News_Window_mc._alpha-10;
_root.Photos_Window_mc._alpha = _root.Photos_Window_mc._alpha-10;
_root.Store_Window_mc._alpha = _root.News_Window_mc._alpha-10;
_root.Shows_Window_mc._alpha = _root.News_Window_mc._alpha-10;
_root.Lyrics_Window_mc._alpha = _root.News_Window_mc._alpha-10;
trace("hello");
trace (winanch);
if (_root.window._y == _root.News_Window_mc._y) {
delete _root.window.onEnterFrame;
}
};
}
And then on my button
on (press) {
moveWindow(this);
}
or moveWindow(_root.Contact_Window_mc);
Also, as you can see I have a couple of repetitous commands (changing the ._alpha of 5 movie clips). If I were in php, I'd stick the names of those in an array and do a "for each" loop on it to cut down on all of that code - is there a way to do that in flash?
Create A String Array Of JPEG Names In A Folder
I am creating a dynamic flash picture gallery. I have external folders filled with the thumbnails, all of which are descriptively named. I was wondering if there was a way to create a string array of the JPEG names (per folder), then use that to drive my loader loop, instead of "pic"+i+".jpg", something like picArray[ i ], or picArray[ i ] + ".jpg". I honestly don't want to rename the hundreds of descriptively named files to pic1, pic2, etc, as I may want to use the descriptive file name in the SWF. Also, if the user wants to browse the folder contents w/o the SWF, they have an idea of what the picture is. Any help is very much appreciated. Thanks in advance!
Edited: 10/31/2007 at 01:12:26 PM by Samuel-san
Mulitiple File Names As A String In One XML Attribute, Then Spliting Into An Array
I am attempting to take an already opperational xml video player with a playlist and add the ability to assign mulitple filenames to a single description in the playlist. I want the video player to play through 6 video clips sequentially and then move on to the next title in the playlist which will also have another 6, etc.
I tried to create a String and then split that string into an Array. But I am uncertain how to tell the video object to play through each video.
PLEASE HELP!!!
Here is what I have so far... the string and array variables are not working properly.
Code:
xml.onLoad = function() {
var nodes = this.firstChild.childNodes;
for (i=0; i<nodes.length; i++) {
var myFlv:String = nodes[i].attributes.flv + "1_" +i+ ".flv";
var splitAr:Array = myFlv.split(",");
list.addItem(nodes[i].attributes.desc,myFlv[i].attributes.flv);
}
vid.play(list.getItemAt(0).data);
list.selectedIndex = 0;
};
Mulitiple File Names As A String In One XML Attribute, Then Spliting Into An Array
I am attempting to take an already opperational xml video player with a playlist and add the ability to assign mulitple filenames to a single description in the playlist. I want the video player to play through 6 video clips sequentially and then move on to the next title in the playlist which will also have another 6, etc.
I tried to create a String and then split that string into an Array. But I am uncertain how to tell the video object to play through each video.
PLEASE HELP!!!
Here is what I have so far... the string and array variables are not working properly.
Code:
xml.onLoad = function() {
var nodes = this.firstChild.childNodes;
for (i=0; i<nodes.length; i++) {
var myFlv:String = nodes[i].attributes.flv + "1_" +i+ ".flv";
var splitAr:Array = myFlv.split(",");
list.addItem(nodes[i].attributes.desc,myFlv[i].attributes.flv);
}
vid.play(list.getItemAt(0).data);
list.selectedIndex = 0;
};
Conflicting Class Names
I've been seeing an error a lot recently:
The name of this class, 'MyClassName', conflicts with the name of another class that was loaded, 'MyClassName'.
I'm not sure why I keep getting this error, especially with projects that only have one custom class. The only way I have been able to get around it is to continually rename the class.
Dynamic Class Names?
Hello, i have a bunch of movie clips in my library, with the linkage turned on.
i would like to add them to my stage, but using a variable to access them.
the clips/linkage are names like 'mc1' 'mc2' 'mc3' etc
so how would i do something like this?
Code:
var clipVar:String = "mc1"
var newMC:[clipVar] = new [clipVar]()
thanks for any help!
Using Arrays To Store Class Names
I want to store class names in arrays. This code looks pretty straight forward to me but all I get is the error message 1046: Type was not found or was not a compile-time constant: .
var myArray:Array=new Array(Bob);
var myObject:myArray[0]=new myArray[0];
addChild(myObject);
How To Dynamically Iterate Through Class Names
hi there,
i am finally doing the transition to AS3...
to do that i am trying to convert an old as1 project.
in this project i have 88 sounds with the linkage SND_0,SND_1,... to SND_87 in my library.
now in as1 / as2
i would do the following to create a sound object for each sound:
Code:
all_sounds={};
for (var i =0;i<88;i++){
all_sounds["snd_ob"+i]=new Sound();
all_sounds["snd_ob"+i].attachSound("SND_"+i)
}
as i understand it in AS3 i would have to code:
Code:
var snd0:SND_0=new SND_0()
and there is of course now way i can loop through that like:
Code:
for (var i =0;i<88;i++){
var "snd"+i:"SND_"+i=new "SND_"+i()
}
so what is the solution for doing something like this in AS3?
thanks a lot!
Dynamic Class Instance Names....
I'm trying to build a controller class that creates instances of other classes. I'm new to AS 2.0 and I can't seem to figure out how to dynamically create instance names without getting a compiler error. For instance, the following code throws back a syntax error:
Code:
class Controller {
private var i:Number;
public function createButtons() {
var buttons:Array = new Array();
for (i=0; i<32; ++i) {
var button[i]:Buttons = new Buttons(); // trying to create instances of the "Buttons" class
}
}
}
So... in what way would I create instances of classes dynamically? I just can't wrap my brain around it. Any help would be greatly appreciated.
How Can I Convert Strings Into Class Names?
I have a number of movieclips exported for Actionscript. I'd like to create new instances of them in my Document class based on names in an XML file. My problem is that the names in the XML file are strings. This makes me end up basically coding:
var a = new "Symbol01"()
where I want to create an new instance of Symbol01. Is there a way to convert the string into a class name so that it says
var a = new Symbol01()
AS3 - Dynamic Class Names With *new* Operator?
I'm using ActionScript 3 and Adobe Flash 9 Public Alpha.
I have 50 movie clips in the Library that use Linkage to set the Class name to: Img1, Img2, Img3, ..., Img50.
I have a parent class named RandImg. I want the constructor for RandImg to randomly select one of the 50 movie clips from the Library and display it. I could get this working by generating a random number, and then writing a really huge switch statement to associate each possible random number with its respective Library Movie Clip Class name, but I would much rather do this with a dynamic/variable class name based on the random number, such as:
var nImgChoice:Number = Math.floor( Math.random( ) * 50 ) + 1;
var mcImg:MovieClip = new [ "Img"+String(nImgChoice) ] ( );
addChild( mcImg );
Note that this used to be possible in AS 2 by doing the following:
this.attachMovie( "Img"+String(nImgChoice) , "mcImg", this.getNextHighestDepth());
Suggestions?
Thanks,
~JC
Passing SQL String To PHP
hi...
what im trying to do is: pass a complete sql string to a php script. this works fine for passing numbers for the SQL WHERE conditions (e.g. "SELECT * FROM myTable WHERE YEAR(mydate)=2005").
but as soon as i try sending strings (e.g. "SELECT * FROM myTable WHERE YEAR(mydate)=2005 AND item='myItem'"), php just won't process it.
the same goes if i wrap that statement into escape();
i also tried putting in and leaving out the inverted commas....
I'm using loadVars() and sendAndLoad() for this action...
anyone ever encountered this problem???
Passing XML String
Alright, so I am trying to pass an XML file as a String from a JSP page. I know the JSP code works and it creates a String of XML data that is formatted correctly, however when I try to load into my flash I am getting undefined errors.
This flash code works if I try to load a file locally or off the server, but unfortunately I cannot load it that way, I need to load it from this JSP as a String.
Here is the AS code:
Code:
myXml = new XML();
myXml.load("rssloader.jsp");
news = new XMLSA();
news.load(myXml);
XMLSA just takes a formatted XML() object and returns it as an array, this has all been verified to work as well.
Passing A String
Ok, so Im passing a param (proLabel) from an asfunction to another function (byeByeContent). It traces correctly from byeByeContent function, but will not work as a frame label. If I replace the param with the string "pro1" all works fine. Whats wrong?
Attach Code
// asfunc
function showPro(proLabel:String) {
proHighlightClick = true;
byeByeContent(mNavContent_3_mc,"NA",proLabel);
reset();
mNavbar_mc.mNav_3_btn.enabled = false;
mNavbar_mc.mNav_3_btn.btnAni_mc.gotoAndPlay(11);
//trace(proLabel);
}
// show/hide content
function byeByeContent(viewContent:MovieClip, bannerPos:String, proPos:String) {
//.. cut alot of things out
if (viewContent == mNavContent_1_mc) {
mNavContent_1_mc.gotoAndStop("lastFrame");
//reset2();
viewContent._visible = true;
} else if (proHighlightClick) {
// this ius where proPos traces fine "pro1" but doesnt gotoandPlay the frame labeled pro1
viewContent._visible = true;
viewContent.gotoAndPlay(proPos);
}}
String Passing
I am trying to create a string on the main stage which I will use to load swf's externally into a scroll pane. Say I create a string called name (name = new String()) and when I click the button called home, name is changed to home.swf (name = "Home.swf"). The button home also loads a movie onto the main stage from the library called animation which is a nice little preloader and a couple of things flying around before I want the page to show up. Within the movie I just called onto the main stage, I include the code myScrollPane.loadScrollContent(name). How come it doesnt load Home.swf when I click the home button?
Passing A String Into A Variable Name
I have a function, and as a result of the function, I want it to create a value in a variable. The string is passed in a button as this,
on (release) {
this.boxCheck("x1");
}
function boxCheck(letter) {
if (this[letter]._currentframe == 2) {
this[letter].gotoAndStop(1);
} else if (this[letter]._currentframe == 1) {
this[letter].gotoAndStop(2);
}
HERE I WANT TO CREATE A VARIABLE THAT WOULD CONTAIN THE STRING IN IT. SO FOR THIS INSTANCE, I WANT TO CREATE A VARIABLE NAMED: x1selected = 1;
How can I do this passing the string to keep it dynamic?
like this? this[letter] + "selected" = 1;
}
Any ideas?
Passing Vars In AS3 Without Using URL String?
Hello,
I have one AS3 swf (loader.swf) that needs to load a second AS3 file (main.swf).
loader.swf has some variables that I would like to pass to main.swf.
I don't want to append the variables in the URL string, because then main.swf won't be cached properly.
In AS2 I could use FlashVars, which passes the variables without adding them to the URL string.
How can I do this in AS3?
Passing Var:string To New URLRequest
Hi,
I have a main movie on which I have two buttons that each should load a new external movie when clicked.
The code on frame one for each button is:
Code:
function onIntroClick(evt:MouseEvent):void {
var language:String="english.swf"
gotoAndPlay(2);
}
english.addEventListener(MouseEvent.CLICK, onIntroClick);
and
Code:
function onIntroClick2(evt:MouseEvent):void {
var language:String="french.swf"
gotoAndPlay(2);
}
french.addEventListener(MouseEvent.CLICK, onIntroClick2);
on frame 20 I have the following code, which should load the external movie (either the english.swf or the french.swf) in the main movie.
The code is as follows :
Code:
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest(language));
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}
function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(l);
}
stop();
This doesn't work as I get an error 1120: access of undefined property language.
What am I doing wrong or what should I do to do it right ?
Thanks for your assistance.
Smalco
Passing String Into Flash
Hi All,
I was wondering if someone could help me out with some trouble I'm having. I've tried to find tutorials for this but it seems to be missing the what I'm looking for. I want to pass a string into flash from a php page. I know I have to have the string in the object. But I don't know how to write the code so flash can understand. I want to have the string value be entered into a text box. Any help would be great thanks..
Passing A String To A Function
Hi I want to pass a varible (a string) to a function when I roll over a
button. I have tried this but it does not work.
var ross:String('hello');
freshnLogo_mc.addEventListener(MouseEvent.ROLL_OVER, oneRollover, ross);
function oneRollover(event:MouseEvent, ross):void {
trace('you passed' + ross);
}
Passing A String To An External MC
I load my external swf....
var myRequest1:URLRequest = new URLRequest("external.swf");
myLoader1.load(myRequest1);
var _content:MovieClip = MovieClip(myLoader1.content);
stage.addChild(_content);
_content.myname ="Albert";
on the first frame of the external swf
trace("hello you" + myname);
I get an error. How Do I do this?
Thanks
Passing Data With Query String
I'm trying to 'pass-through' a variable in a flash movie.
Basically I'm using flash to create a form that needs to be posted back to a server side database, using get url this is no problem.
However I want to populate the flash movie with a value that when the get url command is exectued, this value is passed back to the database.
e.g.
I have a variable called "AdvertID" it's value is "100". I know this before I play the movie, so I call the movie thus:
embed src "movie.swf?AdvertID=100" etc.
However when flash posts this data back using get url, it doesn't appear as one of the variables.
I do not want the user to see this value (however if they must I can live with it).
Do I have to declare "AdvertID" as a variable for this to work?
If I do where?
Thanks.
Passing A Filename As A Variable..is It A String?
Hey can someone help me,
I want to set a variable as a file name,
i.e variable_1 = "file_1.exe";
How should I declare it? I was declaring it as above but it was being passed as a string and wasn't being picked up by my other functions, I also tried without the inverted commas and it wasn't being picked up at all, any advise?
Cheers
Passing String Variables To Flash
I am passing variables in a url string from an asp page to my .swf file and reading the variables into text boxes within flash.
eg.
http://www.mywebpage/pageFlash.asp?...ameVar=François
As you can see, the variable I am using contains a special french character.
Now here is the problem. On some computers the variable is passed to flash with no problem at all and on other computers the same flash file is unable to read the variable. I have tried url encoding the variable to read %E7 and also have placed System.useCodePage=true; on my first line of actionscript, but neither works.
Does anyone know why the special character works on some computers and not on others? All the computers have IE 6 and are running Windows 2000.
Passing String To Target In LoadVariables
for the loadVariables function, I have a file to be loaded. however as for the target, i have no definate target. but a string of the target will be produced in the code. but it doesnt seems to work when i put the string of the target address to the target parameter of loadVariables. how can i get it work?
thanks
[CS3] Passing Variables From Query String
Hi there,
i'm trying to pass a variable from a web page to a flash file. The flash file has a dynamic text box with the var value set to formError.
In the webpage i have the following code:
<script type="text/javascript">
var so = new SWFObject("flash/index_030308.swf?t=150", "mymovie", "938", "305", "8", "#FFFFFF");
so.addParam("allowScriptAccess", "sameDomain");
so.addParam("quality", "high");
so.addVariable("formError", "<%=request.QueryString("formError")%>");
</script>
to test i am typing in the address bar default.asp?formError=woteva, hoping to see "woteva" displayed in my dynamic text box in the flash file, but this isn't the case. Where am i going wrong?
Passing A Variable To Flash Via Url String
I understand how to get a variable into flash when it's hard coded into the html using Flashvars or this is how I do it with SWFObject:
where variable: location=subdirectory
Code:
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("featuredviewer.swf", "featuredviewer", "620", "480", "8", "#fff");
so.addVariable("location", "subdirectory");
so.write("logo");
// ]]>
</script>
What I don't understand and can't find is how to do this...
I have an html file with an swf in it. Different buttons in the file open a popup window via javascript. I want to pass a variable to the swf in the pop up window, possibly like this:
Code:
on (release) {
getURL("javascript:Launch('featuredviewer.html?position=one')");
}
But how do you extract the variable position=one out of the url and get it into flash?
Passing Variable On Querry String To PHP
I'm building a upload app and need to send my php script some info when I call my upload script. I've established a var ID.
Can someone confirm if my syntax is correct.
ActionScript Code:
fileRef.upload("upload.php?userid='+ID+'");
Thanks!
Passing A Variable To A Query String
I am trying to create a form in Flash that passes variables to a query string. Simple enough, but when my variables have an underscore (eg variable_one) Flash coverts the underscore to “%5F”. I noticed that it seems to convert all non letter or number characters to something else. Unfortunately I don’t have the option to change the names of the variables I am passing.
This is the code:
submit.onRelease = function () {
getURL ("http://www.actionscript.org","", "GET");
};
Has anyone encountered this? Help Please!
Passing String Info Via MovieClip?
Hello.
I'll try to explain what I'm looking for, I haven't started coding yet so have nothing to show.
I have 190 movieclips which display various types of information. When a user clicks on a movieclip, it has to tween larger but also send a string to a method. I'll probably e.currentTarget to use one function which contains a tween and I wondered if there was a quick way to pass string info in a similar way?
So, each movieclip has it's own value which can be passed to a method which will use that value. The only way I can think of so far is to have 190 functions which send the string data to the appropriate place. I'm trying to avoid that if I can.
Thank you.
Passing A Query String To Flash
Here's the need:
I'm going to be making a gallery of "thumbnails" which are all a flash file dynamically loading new content in each. So a single html page will house up to 48 copies of that same swf loading a new picture in each.
There has to be a way to load a flash file with a query at the end, right (in the html source code)? Like filename.swf?id=123&thispage=123 right? If so, how do I access those variables passed to flash?
My idea was to write my standard loop (in PHP) posting a new swf in each iteration but change the query string with each so that I can load the new content.
MX : Passing Variables To Command String
I'm trying to design an interface that to simplify the construction of a string. Here's an example: My output (using the getURL command) needs to be in the form of:
http://fakesite.com:8080/java/submit...ng2=y&thing3=z
I'm able to define variables for x, y, and z, however I am unable to figure out how to substitute the defined values for those variables into the string when it is time to send it.
I may not be being very clear here, but does anyone have any ideas?
Thanks
Jeff Kirsch
Passing Variables Via Query String
i am trying to load different xml that get generated through .net when I am trying to pass varibels i am getting undefined. Can someone give me a heads up on what i might be doing wrong. from what I have read and learned I can pull via-
Code:
xmlData.load("/family/galleryimage.xml.aspx?pid=" + _root.loaderInfo.parameters.pid.toString());
Then I am defining pid in within the object class.
Code:
<param name="pid" value='<% =Request.QueryString["pid"] %>'>
However I am getting undefined. Any help is much appreciated, thanks.
MT
|