Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Making Variable Values Globally Accessible In My Code



I have certain variables, and when I declare their values within a function I want the value to be accessible in other functions. Right now it's not, so obviously I have a scoping problem.For this example, I have a function that decides if an avatar is too close to the side of the screen, in which case it sets a flag var tooClose:Boolean = true; Of course my other functions don't see this and aren't getting the message.In old 2.0 I would have just said _root.tooClose = true or I would have made the variable global.Could someone please help me here? Its something I find myself needing quite a bit.



Adobe > ActionScript 3
Posted on: 06/05/2008 08:30:18 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Aren't Functions Globally Accessible ?
I have a function in the first frame of my main time-line and a button that is within an mc calling the function, but it's not working..err

What Is The Best Way To Create Globally-accessible Class Instances?
Hi there,

I created a custom class (no arguments needed for constructor) and I wanted to create an instance of that class that can be accessed by AS from aywhere inside the SWF (i.e. globally from any function or class).

So far the only way I can think of doing that is to create the custom class with an associated MovieClip Symbol, drag an instance of that MovieClip Symbol to the stage, and then give it an instance name. It seems like I can then use the instance name to access that class instance anywhere.

Is there a better or more proper way of achieving this? What if the custom class requires arguments for its constructor?

I'm still a relative newbie here, and still trying to wrap my head around how to do things the "right way" in AS 3.0. Any help will be appreciated!

Cheers,
- K.

Making Sites Accessible
Hiya everyone.

I was just wondering what everyone thought about making my website more accesible to my visitors. I'm working hard at the moment to remove those disgusting frames and so I'll direct you to this site instead.

There are a few little animations on there, I wondered if you have any pointers.

Making Components Accessible Help Needed
Hi i have 4 buttons on a page 2 are my own 2 are components and i want to set up a tab order, however i can only tab between the 2 component ones. I have set the tab order and added the following code to the first frame of the script. "mx.accessibility.ButtonAccImpl.enableAccessibilit y();" however this has no effect. please tell me whats going wrong.??

Making My Flash Application More Accessible...
just wondering what i can do to make my flash application more accessible ? so how to get back buttons working, or allowing it to be found on search engines, screen readers etc...
thanks for any advice
joey.

Making Flash Blind Accessible?
Hi!

Just had a very interesting email contact from a web site I manage. The user is blind and can not 'see' the flash buttons that trigger my audio samples. The screen reader obviously can't read them.

Is there a way to make the Wimpy player Flash button somehow accessible so a screen reader can recognize it and I can indicate to play the sample?

The code I am using is attached.

Thanks for any help you can give!









Attach Code

<!-- START WIMPY BUTTON: Standard HTML -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="wimpybutton104" width="25" height="25">
<param name="id" value="wimpybutton104" />
<param name="width" value="25" />
<param name="height" value="25" />
<param name="bgcolor" value="#FFFFFF" />
<param name="loop" value="false" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="flashvars" value="theFile=http%3A%2F%2Fwww%2Enatalie%2Dbrown%2Ecom%2Faudio%2Frandom%2Dthoughts%2Fthings%2Dthat%2Dyou%2Ddo%2Emp3%0D&playingColor=550A34&arrowColor=F9F2E0&grinderColor=4E2F1B&theBkgdColor=5B0000&rollOverColor=000000&buttonStyle=square" />
<param name="src" value="http://www.natalie-brown.com/audio/wimpy_button.swf" />
<embed type="application/x-shockwave-flash" id="wimpybutton104" width="25" height="25" bgcolor="#FFFFFF" loop="false" menu="false" quality="high" wmode="transparent" flashvars="theFile=http%3A%2F%2Fwww%2Enatalie%2Dbrown%2Ecom%2Faudio%2Frandom%2Dthoughts%2Fthings%2Dthat%2Dyou%2Ddo%2Emp3%0D&playingColor=550A34&arrowColor=F9F2E0&grinderColor=4E2F1B&theBkgdColor=5B0000&rollOverColor=000000&buttonStyle=square" src="http://www.natalie-brown.com/audio/wimpy_button.swf"></embed>
</object>
<!-- END WIMPY BUTTON: Standard HTML -->

Array Variable Not Working Globally
I have an array var declared on the 1st frame, but when I load variables into the array, they do not stay in the array once it leaves the onLoad function. I have used the _global attribute, but still it does not seem to load the 3 variables into the array permanently. Any Suggestions ? Here is the code:

var myArray:Array = new Array();
var members:LoadVars = new LoadVars();
members.onLoad = function(success:Boolean) {
if (success) {
for (var i = 0; i<3; i++) {
fullname = (this["Member"+i]);
Pic = (this["MemberPic"+i]);
Bio = (this["MemberBio"+i]);
_root.myArray.push(new myPeople(fullname, Bio, Pic));
}
} else {
trace("Error loading/parsing LoadVars.");
}
//so far here the array is of lenght 3
};
//
members.load("members.htm");
this.attachMovie("aboutchefs", "aboutchefs", this.getNextHighestDepth());
trace(_root.myArray.length); //returns 0

function myPeople(myname, mydescription, mypicture) {
this.myName = myname;
this.myDescription = mydescription;
this.myPicture = mypicture;
}

Making Flash Accessible To Screen Readers
Ok. I'm making a website that serves up MP3s to users in a fairly straightforward manner. I'm delivering them by linking to the sound files directly. I also want people to be able to play these files without having to open up a media player, so I've used an inbuilt flash player wherever the files are that calls the MP3 with the Flashvars function (I'm not getting too technical here as I'm not a Flash coder and I'm using someone else's script).

The main problem that I'm running into at the moment is that I would like to make my Flash Player accessible to people who are using screen readers, like JAWs. When I check the 'make movie accessible' panel in MX, and assign tab orders to my various buttons, the flash movie is accessible via keystrokes if you're just using your browser, but if you turn JAWS on the flash becomes inaccessible. The screen reader recognises the Flash Object, and reads out what I've put in the elements, but will not let me tab between them. I'm assuming this is some kind of conflict with the TAB key commands in explorer not being the same as the TAB key commands in JAWS. Is there a way (with Flash) that I can get around this? Do I need to assign keystrokes to each button in my Flash movie? (and if so, how? the Help section in Flash was quite vague about this).

I would love to hear from anyone who has used Flash in an accessible way, especially with JAWS or any other screen reader.

what macromedia says

Making Text Boxes Accessible To Movie Clips
Hey,

I have a Flash front end connected to a MySQL back-end database and I am trying to send some text input to the db. The input text box is available on the root level and within this same level I have a movie clip which contains the loadvariables AS. In the PHP script (which is initiated through the movie clip), I need to be able to access the text within the input box on the root level - any suggestions on how I can do this? Is there a way I can make the text input available to everything..?

THANKS!!!

R.S

Accessible ('correct') Flv Code?
ok since both dreamweaver and flash dont seem to know how to accessibly
insert FLVs into websites does anyone know the 'correct' tags to use??

at present im using the following which is only coming back with 26 errors at
present!!!


[HTML]<object type="application/x-shockwave-flash" data="movie.swf" width="170" height="148">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Clear_Skin_ 1&streamName=media/teaching_vid&autoPlay=true&autoRewind=true" />
<embed src="FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=Clear_S kin_1&streamName=media/teaching_vid&autoPlay=true&autoRewind=true" quality="high" scale="noscale" width="170" height="107" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
[/HTML]

using the object type as apposed to embed as W3c doesnt allow embed.

any ideas??

many thanks

david

LoadVars Variable Not Accessible
/*
goal get the username2 variable inside the myLoadvars.onLoad = function
to be accessible from outside its function.

I've been told that adding a key frame to the timeline will allow the username2
variable to be used outside its function, which works but this script is
part of a larger script and the keyframe causes a movie clip on stage to blink
and display wrong.

I've attempted to use stops(); and gotoAndPlay(); to control the frames/blinking
but that either stops the loadVars script or causes the movie clip to blink faster.

I've also attempted to put the movieclip on keyframe 6 then used
gotoAndPlay(6) stop(); on key frame 5.
Which stops the movieclip from blinking but as you know the script on frame 1
isn't accessible from frame 6 because of the stop(); on frame 5.

How can i access the username2 variable?
*/


Code:
var myLoadVars:LoadVars = new LoadVars();
myLoadVars.onLoad = function( success ){
if(success){


_root.msg.text = username2;
}

}
_root.username2 = myLoadVars.valid;
trace(_root.username2);
myLoadVars.load('loadvars.php');

LoadVars Variable Not Accessible
/*
goal get the username2 variable inside the myLoadvars.onLoad = function
to be accessible from outside its function.

I've been told that adding a key frame to the timeline will allow the username2
variable to be used outside its function, which works but this script is
part of a larger script and the keyframe causes a movie clip on stage to blink
and display wrong.

I've attempted to use stops(); and gotoAndPlay(); to control the frames/blinking
but that either stops the loadVars script or causes the movie clip to blink faster.

I've also attempted to put the movieclip on keyframe 6 then used
gotoAndPlay(6) stop(); on key frame 5.
Which stops the movieclip from blinking but as you know the script on frame 1
isn't accessible from frame 6 because of the stop(); on frame 5.

How can i access the username2 variable?
*/


Code:
var myLoadVars:LoadVars = new LoadVars();
myLoadVars.onLoad = function( success ){
if(success){


_root.msg.text = username2;
}

}
_root.username2 = myLoadVars.valid;
trace(_root.username2);
myLoadVars.load('loadvars.php');

_global.variable Not Accessible
Greetings!
I'm new in this forum, but have been coding in several languages for years.
I wonder if someone can give me some help.

I have this script:

+==============================+
var MAX_ITEMS:Number = 20;
_global.msgList = new Array(MAX_ITEMS);// initialize array to hold the message list items

function setTicker(news_file:String, maxItems:Number, mesgID:String):Void {

var news_file:String = news_file;
var maxItems:Number = maxItems;
var mesgid:String = mesgID;

var newslist:LoadVars = new LoadVars(); // will store the news imported from a text file in this variable

newslist.load(news_file);
newslist.onLoad = function():Void{
for (var i: Number = 1; i <= maxItems; i++){
mesgid = mesgID + i;
// trace("mesgid: " + mesgid);
var mesgItem:String = eval ("this." + mesgid);
// trace ("MsgItem: " + mesgItem);
if (mesgItem == "undefined"){
break;
} else {
msgList[i] = mesgItem;
_level0.news_txt.text = msgList[1]; // shows the correct value
// trace("Array elem: " + msgList[i]);
}
}
}
} // ticker()

function showItems():Void{
trace ("Elems: " + msgList.length) // shows the correct number
_level0.news_txt.text = msgList[1] // shows : undefined !!
}

+==============================+

The function setTicker() works fine and when I test it iterates through the message items and adds them to the mstList array (which is a global array).
But when I try to access the elements of the array from the function showItems() it turns out the the array elements are empty but that should not be the case because the previous function shows they are set.

I've spent 2 days in this and cannot see where the problem is. Can anyone give me a hand here?

Much appreciated.

Rick

Setting Variables To Be Accessible Outside The Code
Hi,

I want to trace Code:

trace(a._height*i); outside myXML.onLoad. The trace above the Code:

myXML.load("XML/links.xml"); works great because the variables is set localy, however the trace below it, doesn't work. How to set the variables, so the second trace will work?

Code:

var myXML:XML = new XML();
myXML.ignoreWhite = true;
var urls:Array = new Array();
myXML.onLoad = function() {
   var myData:Array = new Array();
   myData = this.firstChild.childNodes;
   for (i=0; i<myData.length; i++) {
      urls.push(myData[i].attributes.earl);
      var a = links.attachMovie("mcTxtField", "mc"+i, links.getNextHighestDepth());
      a.numb = i;
      a._x = -239;
      a._y = -73+i*16;
      if (i>=myData.length/2) {
         a._x = 9;
         a._y = -((myData.length/2)*16)-73+i*16;
      }
      a.txtField.txtFld.text = myData[i].attributes.desc;
      a.onRelease = function() {
         getURL(urls[this.numb], "_blank");
      };
   }
   trace(a._height*i);
};
myXML.load("XML/links.xml");
trace(a._height*i);

Thanks, Mario :D [/code]

Flash Right Click Panel Code Accessible In ASR
I just opened a projector file (exe) in Buraks action script replacer program, and to my amazement i can access all the actionscript within the swf that appears when you usually right click on a swf.

i supposed thats old news? but its rather interesting stuff.

http://www.buraks.com/asr/

Global Variable Not Accessible From Loaded-in Swfs?
Hey guys,

On the main timeline of swf A I have the following code:

_global.MyRoot = this;

This captures the root and any time I use MyRoot it references the _root of this timeline as expected.

Now the problem arises when I load swf B into swf A using loadMovie; If from the code inside of swf B references MyRoot it gets undefined...instead of the _root of swf A....why is this? Isn't this sort of thing one of the main reasons to use global?

Can you please tell me what i am doing wrong (or recommend an alternative method). Thank you.

Make Variable Accessible Outside Of Class LoadComplete
Hi Guys

I would like to access a variable outside of a class loadComplete, but inside the package.

Here is the class I create the variable


ActionScript Code:
package{
    import flash.display.Loader;
    import flash.display.Bitmap;
    import flash.net.URLRequest;
    import flash.events.*;
   
   
    public class TestClass{
        private var _loader:Loader;
        public var _loadedImage:Bitmap;
       
        public function TestClass(URL:String){
            // create loader
            _loader= new Loader();
            _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
            _loader.load(new URLRequest(URL))
           
        }
       
        private function loadComplete(event:Event):void{
            _loadedImage = Bitmap(_loader.content);
            trace(_loadedImage);
        }
       
    }
}

And here is where I call the class


ActionScript Code:
package{
    import flash.display.Sprite;
   
   
    public class MainTest extends Sprite{
       
        public function MainTest(){
            var testClass:TestClass = new TestClass("someImage.jpg");
            addChild(testClass._loadedImage);
            trace(testClass._loadedImage);     
           
        }
    }
}

How can I make the variable available in the MainTest Class ?

Thanks

Vikana

Clip Building Techniques Such That Each 'colour' Is Accessible By Code
Hi all,

This is a bit messy to describe but I think it's an interesting topic and I hope someone can shed some light for me.

There is a problem I've been toying with and I can't find a 'good' solution.

I'm working on a bunch of flash games. The animation style doesn't lend itself fully to automated tweening. Some things need to be redrawn on occassion. An example is a shoe. When the character walks, we have a few frames of handdrawn keyframes as the toe bends compared to the rest of the foot.

So far, so good.

I want - at a future date - to allow players to choose their character's colours and have them replace existing colours on my graphics.

For example, the girl character has tights with two tones. Just now, they are both shades of green. In the future, I will store (via 'normal' web site back end) profile informatin for each player and will allow them to chose two tones to repllace those on the tights.

Again, so far so good.

In theory.

As far as how to do this... forget the 'colour picking' part - that's easy. And ignore the webby back end bit - that's easy too.

But as far as I can see, when I apply a colour transform to a MovieClip, it changes the whole clip's colour.

This means that I need my artist to break each individual graphic she draws into a few movie clips and give the instances names.

I have been thinking that I would swap the colours in a fashion similar to this pseudocode:


Code:
start game
place character MC on the stage, invisible.
maintain a list of MC's (so far, just player avatar)
while ( MC list != empty) {
get next movie clip
examine each property of clip and if "instanceof MovieClip" is true, add it to my list
examine "_name" of the MC to see if it contains a predefined word (such as "skintone" - so 'ankle_skintone')
if (match) {
look up table and apply colour transform
}
}
OK. so you may suggest a better route - but in a very small demo, this works fine.

BUT!

Because the animation has redrawn keyframes, when I hit a new keyframe for whatever MC needs one, the NEW drawing hasn't had its colours changed.

It's obvious, and I can see why (it's not on stage in my initial loop).

What isn't obvious is how I can fix this issue.

Now, I COULD make sure that the animator places each component-graphic on the stage in the MC's initial frame - and manages key framing by controlling x/y and _visible - but that's a bit messy.

I could also ask the artist to put a function call or something in every key frame, but IMHO that's a terrible idea! - It's messy, it spreads my code all over the place... it has an artist programming... bad bad bad.

The whole thing is quite messy already actually, because it requires such careful breaking down and building up of MC's.

So...

I have either one question or two!

"The one question version"

Can you advise how, with my current implementation idea, I can access 'future' MC's - so with a 'leg' MC, not just access the current 'tights_dark_green' and 'tights_light_green' areas, but also the future MC's corresponding areas?

"The two question version"

Is there a better way to do this ( '"palette switching" actionscript' Google searches didn't show up much)?


So...

Thanks for anyone who got this far!

Any advice or suggestions would be much appreciated.

Muchos Grazias!

David

Generating Random Values For A Variable While Excluding The Already Generated Values
Hey Flashers:

Here's my question this time around. I want to generate random values between 1and 50 for a variable but I want every time I generate the new value to exclude the already generated values from the pool of options. Something like playing the lottery where no two drawn numbers can be the same. Any hints or references to open code will be greatly appreciated.
As always, thanks a lot!

Problem Passing Variable Values (from XML) To Variable In Child Movie
I'm reading something from XML, and store it in a variable. I can trace the variable and it shows two items. I can display those two seperately with variable[0] and [1], meaning that it works as intended.

After that, I'm calling a movieclip, which is supposed to read that variable.. sadly, it can't do it. So I resorted to passing the content of the first variable to a variable inside the called movieclip. This works, and tracing the second variable shows both items from the first. However, I cannot access the items seperately with variable2[0] for example.

What's the problem? The second variable is currently a string. I tried to declare is as other things (like xml or array) as well, but that didn't help. Is there also a way to make this procedure unnecessary, i.e. can I somehow access the first variable?

I've attached the fla/xml/swf in case my description doesn't make sense!

Apply Variable Values To Variable Names?
I have a gallery with a series of 5 thumbnails, named gallery_position_1, gallery_position_2, etc, up to 5. I am loading an image with XML into gallery_position_(#), and have a button on top of that with scripts on it.

My question is whether I can have an integer variable (call it x) that starts at 1 and can be put into a for loop, using it then on the end of my other variable like so:

for (x = 1; x < 6; x++) {
gallery_position_x.loadMovie(URL path to image);
}

I basically want to be able to "index" a regular variable by changing a number within its name. I know its a long shot, as I've never seen it done before, but I thought I'd ask, all the same.

Making The Mx.transitions Stick To Integer Values
The title says it all, im using the code below:


ActionScript Code:
function MoveTransition(object, moveAmount, dir,time)
{
    transitionType = mx.transitions.easing.Strong.easeOut;
    if(dir == "x") {
    objectMove = new mx.transitions.Tween(object, "_x", transitionType, object._x, moveAmount, time);
    }
    else {
    objectMove = new mx.transitions.Tween(object, "_y", transitionType, object._y, moveAmount, time);
    }
}

Code - A Value Between Two Values?
is there short hand when evaulating if a value is between/within two values?

ie, instead of

if ((value1 > value 2) && (value1 < value3)) {}

Help With Code: Undefined Values
basically I have a function that is called on a few button onRelease events. Values like the top 3 variables will be defined depending on what button is clicked. It traces fine until the last few lines dealing with the array. The last two array trace() lines return Undefined. I've written this a few different ways and have not been able to resolve it= any ideas?

Thanks in advance for any comments or suggestions you may have,
noel

count = 5;
mcType = "region";
regionArray = new Array();

function buildContent(){
trace("filter press and load variables = success");
for(i=1; i<=count; i++){
//should eval() be used in the following?
mcType+ "_mc".duplicateMovieClip(mcType +i+ "_mc", i);
trace(("my mcType " +i+ " is: ") + mcType +i+ "_mc");
var mcArray = mcType+ "Array";
trace("my mcArray: " +mcArray);
mcArray.push("region" +i+ "_mc");
trace(regionArray[i]);
trace(mcArray[i]);
trace("");
}
}

Code To Get Whole Pixel Values
I was wondering what the code to get something to go to a whole pixel value is. I'm using pixel fonts inside of a movieclip and when the movie clip is moved through actionscript and lands in a different spot with easing, the fonts look bad because i suspect that they are no longer on pixel values. any help is greatly appreciated. thanks in advance.

Code To Get Whole Pixel Values
I was wondering what the code to get something to go to a whole pixel value is. I'm using pixel fonts inside of a movieclip and when the movie clip is moved through actionscript and lands in a different spot with easing, the fonts look bad because i suspect that they are no longer on pixel values. any help is greatly appreciated. thanks in advance.

Variable Values
How do I pass the value of a variable from the main time line into a movie clip?? Please Help.

Same Variable Name With Different Values...is It Possible?
Hi friends,

I have a big problem.
I have a flash movie connected to a access database via ASP.
I have 2 variables (ws_is and ref_id) that modify the SQL query in the ASP.
All that works fine. But here is the problem:
I assigned diferent values to my variables in each frame of the timeline, but when I publish my movie the values of my variables are all the same! Seems that the values of the first frame are copied to the other frames when I publish the movie. If I change the variable name then it works, but I have to keep the same variable name for the ASP to work.

Is it possible to have the same variable give different values in each diferent frame?

If any of you know how to do this please let me know...I'm stuck here big time...I need your help.

thanks

Andino

Min And Max Values For A Variable
Hi ppl.
Im making my first flash game (Goin quite well! yay)
Its like The Sims only with one Sim not a family.

Anyways, I have set up my variables for the Sim's stats. (hunger, energy etc.)
How do I set a minimum and maximum value for each variable tho?
I have tried various things but nothing works. I keep ending up with -£1000 and 250 for health and such.

Can anyone plz help?
Thanks

Get Variable Values From An Mc
hi I am trying to get the valus for a MC.
I have a card game.


the cards are pre-built an are in the library
each card has the following variables declared in it's TL



Code:
var cardName = "Two of Clubs";
var cardValue = 2;
var cardSubValue = 2;
var cardCountValue = 1;
var cardSuitValue = 2;
stop();
how can I access these values?


here is what I have:


Code:
mc_con.attachMovie(cardMasterArray[toMaster],cardMasterArray[toMaster],4,{_x:136.3,_y:146.7})
thanks

Variable Values
How do you set a variable's value equal to the text in a text box

Variable Values
I have a movie clip instance on my main timeline and I need to change the value of a variable from within that clip, but I need the value to be seen on the main timeline. I figured defining the variable from the main timeline (outside any functions) would make it global and then the movie clip could alter the value. The problem is the movie clip instance does not know the variable has been defined. How do I do this? It seems so simple...

Dave

Same Variable Name, Different Values...possible?
Hi friends,

I have a big problem.
I have a flash movie connected to a access database via ASP.
I have 2 variables (ws_is and ref_id) that modify the SQL query in the ASP.
All that works fine. But here is the problem:
I assigned diferent values to my variables in each frame of the timeline, but when I publish my movie the values of my variables are all the same! Seems that the values of the first frame are copied to the other frames when I publish the movie. If I change the variable name then it works, but I have to keep the same variable name for the ASP to work.

Is it possible to have the same variable give different values in each diferent frame?

If any of you know how to do this please let me know...I'm stuck here big time...I need your help.

thanks

Andino

Evaluate Variable Values
Hi!

I need fast help with sorting variables...
I have ten(10) variables and I should evaluate their values and sort them from highest to lowest.... !

like this

var10 = 30
var2 = 24
var3 = 10
var5 = 2
var6 = 1

and so on...

but how to do it?


. matti

Changing Variable Values...
I have a drag and drop navigation...

whenever i release, 2 variables will be updated: prevX and prevY.

Its works...that is before i declared a value for these 2 variables when the scene loads. (i placed it in a frame script)
After i did that, the values will not be updated on event,
instead the values remain.

What should i do??

Sending Variable Values To A New Swf
Here's the plan:

I'm developing a flash application, which gathers options for an electronic rack enclosure. Once all 16 options are chosen I want to generate a datasheet based on the customer’s choices.

He hits a button, a new window pops up with a flash SWF that grabs all the variables and populates the datasheet. It will have to be a new SWF as the size will be drastically different for a printable datasheet.

Is there an easy way to pass along the Var values, or am I looking at some kind of server side programming?

Thanks!

Adding Variable Values
I have two variables, named month and day respectively, that store integers in them. I want to create a new variable called date that adds the values of these two variables together. I have a button to try to do this:

on (release) {
date = month+day;
}

But, it thinks this is a string and is sticking the numbers together, not adding them. So if the value of the month is 31 and the value of the day is 2, I get 312, instead of 33.

I tried using eval on each one but that just returned a value of 0 everytime.

I'm sure this is the simplest thing, but I'm a beginner...

How To Do A Variable To Get Some Values Not Randomly
How to do a variable to get some values not randomly but by a certain order.
For example if i have numbers from 1 to 8 i want the variable to get the values in this order: 1, 4, 7, 3, 6, 2, 5.

I trayed with this function it doesn`t worked.

function value (number) {
if (number=5) {
number = 8;
} else if (number=2) {
number = 5;
} else if (number=6) {
number = 2;
} else if (number=3) {
number = 6;
} else if (number=7) {
number = 3;
} else if (number=4) {
number = 7;
} else if (number=1) {
number = 4;
} else if (number=0) {
number = 1;
}
return number;
}

Adding Variable Values
I'm trying to make a simple bank simulation. I have these variables: money (the money in your hand) bankcash (money in your bank) and deposit (desired amount to deposit). I have the following code for a deposit:
(before this code bankcash=0 and deposit=150, however I think that the text box where the user enters the deposit is making it as deposit="150")

if(deposit<=money){
bankcash+=deposit
money-=deposit
}
and I end up getting bankcash=0150

anyone know how I can make the text box make the entered value as a number, not text?

ex. deposit=150, not deposit="150"

Variable Values Between .swfs
I have a question about the availablity of variable values from one .swf to another that I think might be at the root of a lot of weirdness going on in my development environment.

Basically I have one .swf, which I call "index" which serves as the shell interface for my movie. It contains a navigation bar on the left and almost nothing else except for a large, empty movieclip "c", which serves as the target into which seperate .swfs are loaded in order to display dynamic content.

The following code is used to load data from the server and to declare the function which is used to navigate.


code:--------------------------------------------------------------------------------
one = new LoadVars();

one.onLoad = function() {
_global.template = _level0.one.template;
_global.page = _level0.one.page;
_global.button = _level0.one.button;


loadMovie("http://dev.this_site.edu/generic_"+template+".swf", "_root.c");

};



function loader(page, button, frame) {
one.load("http://dev.this_site.edu/vars.cfm?page="+page+"&button="+button);
_root.headings.gotoAndStop(frame);
}


loader();
--------------------------------------------------------------------------------

Most often the "template" value serves a page called "generic_one" and loads it into the movieclip "c" on the root timeline. That template contains several dynamically populated elements. For simplicity's sake, I will use just one of these to exemplify my difficulty.

There is a dynamic textbox named "teaser_mc", which populates this way:

teaser_mc.teaser.htmlText = _level0.one.the_teaser;

Where "the_teaser" is one of several variables loaded into the LoadVars object "one" declared in the first line of code cited above, located on frame one of my shell of "index" movie.

Now here's the thing.

When I test this from within the application by running "test movie" on the shell, I can press a navigation element and my template will load, but the textfields are empty. If I press that element again, it will populate the screen appropriately. When I publish it and look at it on the web, it seems to behave correctly, though I suspect that to be nothing but a benevolent quirk.

In an effort to figure out what was going on I tried running this "trace" statement:

trace (_level0.one.the_teaser);

first from within this function literal on the shell, which you can locate in context in the codeblock at the top of this post:


code:--------------------------------------------------------------------------------

one.onLoad = function() {
_global.template = _level0.one.template;
_global.page = _level0.one.page;
_global.button = _level0.one.button;

like this --->trace (_level0.one.the_teaser);
loadMovie("http://dev.this_site.edu/generic_"+template+".swf", "_root.c");

};
--------------------------------------------------------------------------------

which returned the proper value every time.

Then I tried running the same statement from inside the code located on the first frame of the template .swf "generic_one", which contains the dynamic text fields. Correspondent to the scenario mentioned above, where I had to press the navigation elements twice in order to populate my screen, my trace statement returned "undefined" when the .swf first loaded, and then returned the proper value when I pressed the element again and it populated the fields.

My question, obviously, is why is this happening? I have a feeling that many of the little quirks I have uncovered in building this site and the reason that certain necessary functions (like getting the BrowserHistory class to engage the browser's back button -- a subject I am certain to bring to show and tell later) are behaving erratically are related to this problem.

If I understand the code I cited early correctly, what I am asking Flash to do when the function "loader" executes is to send a query to a cold fusion page and load the returned data into the LoadVars object "one". I am using the .onLoad method of that object to tell Flash to wait until it has all the necessary data before it loads the template .swf which refers to those values to populate itself with content.

Why, then, if that code is actually doing what I think it should, would those values not be visible from within my "generic_one" template when it first loads, seeing as I have asked Flash not to load any template until it has the data necessary to populate that template?

Does this seems like a data lag issue? Or does it have something to do with how seperate .swfs need to talk to one another when referring to variable values declared in one place and accessed in another?

Perhaps it is something entirely different. I am hoping in any case that I am bumping my head up against a know issue, since it seems that the scenario I am describing might be fairly typical.

Any advice or pointers would be extremely helpful.

I hope that was clear enough.

If you've read this far, I thank you.

Ed

Passing Variable Values
I'm trying to figure out a way to pass data from an input text in one mc to a dynamic text field in another mc. Can anyone help me? Pleeeeeaassseee?

Get Variable Values In An ASP Page...
Hi All,

I've created this page, www.easyboarder.com/Rego/FlashNewMember.htm and am
wondering how I get the values in the variables I've named in the Flash
file...? I've used the Get method. Any help greatly appreciated. cheers.

Initial Variable Values
Hi,

are initial actionscript
variable values set to 0, all flash viewer versions ?


and.. is it possible to view/modify all actionscripts at once,
without clicking frame by frame, scene by scene ?


thank you

Vanishing URL Variable Values
O.K.,

I just asked a question about checking for a variable's existence, and was duly reminded of what a dunce I can be, but I have another question, and this one does seem legitimate.

Basically, I have four variable values coming in on a URL string (page,button,news,frame) and, for some reason, Flash only seems to see three of them.

page, button and frame are all parameters of a function.

page and button get massaged a little bit before they are used.

frame and news are used just as they come.

Now, by virtue of an extremely helpful script written by cyberfunk, I can trace the values of these variables in the browser at runtime. When I do, I get accurate values for page, button and frame, but Flash seems to refuse to acknowledge the existence of the variable news.

Here is the URL string I am passing:

http://dev.massachusetts.edu/index.c...n=677&frame=12

"page" traces to "news"
"button" traces to "677"
"frame" traces to "12"

"news" returns nothing.

Any idea why?

Thanks,

Ed

Send Variable Values From One SWF To Another
Greetings

Here's the didge: I want to send different variable values to a SWF when loading it - so it goes to the frame I want it to.

I have several buttons - each send the SWF to a different frame upon loading - okay I got that... but now when I want to choose a new link to zip to a different frame, or part of the site, the SWF must load again - some kind of caching problem.

A kind gentleman gave me some assistance to solve this problem, but I didn't know how to interpret it: (this is out of context - from the scripting & backend forum)
__________________________________________________ ___

Hi,

if you require a recent flashplayer (this feature was added to FP6 later), you can also use <embed src="movie.swf" flashvars="var1=value1&var2=value2"> and its param counterpart - this looks the same for the movie but solves the caching problem

Either way is very similar to flash loading variables from a text file or server, and you do not add quote marks there either

Musicman
__________________________________________________ _____

Could this work with a loadMovieNum command?

The work in progress is at

http://www.indoamericanfilms.com/test.html

several links under "the film" all go to the same SWF-but jump to a different frame. but the SWF reloads every time

Any feedback would be greatly appreciated!

Thank you,

quazi

Disappearing Variable Values?
Hi all!

Ok, here we go:
There are five different MC's with input fields. They are all stored in another MC - each on one frame.

The problem:
After inserting values on MC A and switching to another and back, they're gone.

The Question:
How can i store the variables (and update them if a user decides to change them after returning from another set of variables?

Cheers, and thanks
----va

Variable To Set The Routine Values
Hi

All is it possible to use a variable to set the routine values, something like this?

ReturnTo = home;

on (release) {
gotoAndStop (ReturnTo);
}

Thanx in advance
Blnukem

Changing Variable Values
Im trying to make simple poll in flash where it changes the value of the variable in the results textbox using Load Variables like for example &text=0, then i would use post in load variables to change the value of &text=0 to &text=1 with out me having to update it manualy, if this is possible someone please help me and explain to me how to do this.

heres a link to the file

PS its only a test meaning i just want this part to work for now.

Getting Variable Values From Loaded MCs
Hey everyone, maybe you guys can help me with a problem I'm having. I'll explain this the best I can. There are too many levels in the actual project to post the code.

Say I have this swf and inside this swf is a scrolling component with a mc inside. Inside the mc is a loadMovie syntax loading an external file (a calendar)with this code: loadMovie("calendar.swf", "calplaceholder");.

The calendar has programming behind it so that when a user clicks on a date that date is loaded into a hidden variable on the root level of the calendar.

How on earth can get that value to be recognized by a function I have way back on the root timeline of the main movie?

Here is the function I'm trying to use to get the hidden date value on my main timeline:

function checkDate() {
checkDateValue = comp3.calplaceholder.hiddenDate;
date28 = 28;
if (checkDateValue == date28) {
_level13.gotoAndPlay("Date28");
}
}

The function is simple, but the hiddenDate variable is not working as a variable or an instance. I found one way around it where I just don't check the date, but I prefer to check the date. Any suggestions you have, or a flat "this can't be done" would be helpful.

Copyright © 2005-08 www.BigResource.com, All rights reserved