ActionScript 3.0 :: Ensuring A Static Var Stays Updated?
Oct 28, 2009
I want to get the index of the image currently in the center of the carousel and then I want to use this index number in other classes but it has to stay updated each time.Isuccessfully managed to get the index of the image that is currently being clicked on (this image will then be moved to the center of the carousel so as long as one always clicks on an image at the start, my method will work ) but I dont know how to allow other classes to access this. I tried saving it as a static var and then trying to access it by using the following:
private var coverIndex : int = CoverFlow.selectedCoverIndex;
But I receive the error msg that selectedCoverIndex is not available to static class CoverFlow or something of that sort. This is what my CoverFlow code looks like (i.e. where I determine which image I want to position in the center):
public class CoverFlow extends Sprite {
public var covers : Vector.<DisplayObject>;
private var cover : DisplayObject;[code].............
View 4 Replies
Similar Posts:
Oct 28, 2011
I am attempting to create cash register simulation game and am running into a problem with a conditional statement that I am using to check whether the correct change is being provided to the customer and if a button is being pressed or not. In this game, the user can see the amount of the sale as well as the amount the customer pays. With this information they have to click on the cash drawer slots which will increase a variable called changeCount by the value of the monetary unit they have selected.
I am using an if statement to take them to the next frame if the changeCount = payment-sale and the confirm button has been pressed. To check for the button I am using a boolean to see if it is being pressed or not. For some reason, it is not registering the updated value of the changeCount for the if statement to work. If I trace the value with trace(changeCount); it will return the value I want.
The source code is pasted below:
package {
public class CashierMain extends MovieClip {
private var confirmBtn:ConfirmButton;
private var pennyBtn:PennyButton;
private var dimeBtn:DimeButton;
[Code] .....
View 1 Replies
Jan 7, 2011
I have a program in which I am running a number of for loops which are doing a number of different things.I pull in data from an xml file and then step through that data to dynamically create arrays, populate the arrays, and create and modify movie clips.
The program I'm building is similar in scope to one I developed in Director many years ago, and in that environment we had to actually put breaks in using timers to ensure that the data would be processed and that the system wouldn't choke.
What I'm seeing with this flash version of the application is similar and I suspect the same. Basically, when navigating from the frame where the scripts are processed to the frame where the movie clips are displayed, there are times when it works perfectly and times when things are out of whack. I put in a 5 second delay (arbitrarily) to see if this would resolve the issue and on my system at least it does. But I need some advice on coming up with a real solution.
View 25 Replies
Aug 10, 2010
I've recently started putting together a Facebook Connect AS3 app and retrieving objects and images through the Graph API.Running anywhere but locally, I receive security errors of the form: SecurityError: Error #2122: Security sandbox violation: Loader.content: xxxx cannot access url...A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.If I add a line of the form:[code]One thing I'd considered was retrieving the crossdomain policy file on a per image basis, capturing the domain from the image URL before making the image request. Unfortunately, at least via the Graph solution (and I haven't looked too closely at the others), their servers resolve the image url after the request is made, from something more generic like: url...Has anyone found a more dependable means of ensuring that images can be retrieved without security sandbox violations? Or do Facebook maintain a definitive list that developers need to keep an eye on?
View 1 Replies
Oct 22, 2009
how bad is this practice? I am having trouble getting to some stuff so i am taking the easy way out
Code:
private static var _interrupted:Boolean;
public static function setInterrupted(value:Boolean):void{
_interrupted = value;
}
View 1 Replies
Aug 25, 2009
Let's say you have the following situation:
1. Static var(an Array) stored in a class.
2. You create a variable reference to the static class in a separate class.
3. Splice some items from the reference variable in the separate class.
4. Trace the static class and the items have been removed from that too.
5. Verify several times.
6. Get confused.
7. Post on Kirupa.
View 3 Replies
Jan 6, 2010
Ok, so I have a bit of a mess here (Which I'm probably not doing right anyway, which could be my problem...). I have a document class, I'll call it as Body.as, that creates an object from another class known as Headgear.as. There are also other objects created from other classes, or will be in the future. Now, amoung all this, Headgear.as and all of the other classes Body.as will use to make objects require the use of dragging functions (starting and stopping dragging). On stopping drags, position checks are then made to compare a particular hidden movieclip with the dragged MC.
To try and save myself some hassle (from making the same functions over and over to ensuring that when the objects are created I don't need to send a complete crapload of variables just to ensure the position checking function would work), I had the functions for the event listeners (Which are set-up on the draggable MCs in Headgear.as) just direct to functions in Body.as
[Code]...
View 6 Replies
Dec 28, 2009
If I created a static method. say I decide to call on other methods within that static method. Do those methods I call on need to be static as well? what If I used some of the properties. Not to store data permanently, but just within that process. Do those properties need to be static ??
View 3 Replies
Feb 21, 2007
Yesterday I found myself wondering, what is the difference between either having a class with methods that are all static, or simply giving your class the static attribute?
View 9 Replies
Nov 22, 2009
Alright, so I have a class that is linked (via the linkage panel) to a scrollbox class. I'll paste the class here:[code]Ignoring the formatting, the commented out functions are the ones causing the issue. Adobe says that it's a static class and I can't use non-static functions. The way I wanted to use it was:
1. Call the page button generating function above.
2. In the main code in my program is this line:scrollbox.setClickFunction(historyContent.generate Page);So when the buttons that are supposed to be generated are clicked, the scrollbox class can call the History pages generatePage function and pass it which page to show. (I did this because there was a lot of text and a limit on how much would display, so small chunks sounded logical).
3. In the onClick function (which I haven't finished yet because the rest wont work), when you click one of the buttons it calls the set function. Its that simple.
View 4 Replies
May 4, 2009
I'm kind off oblivious as to what I'm doing wrong here... I have two classes: - Alley - AlleyCat
[Code]...
View 8 Replies
Mar 31, 2010
I'm building a game of which the interface is one of the first items to load on screen.Sound button, pause and all the bits .During the game - all manor of things are dynamically added and removed to the stage. Therefore my interface goes behind my game scene.How do I ensure the movieclip always stays on top? Can I override the addChild of my Document Class and every time a new child is added, I restack the interface to the top?
View 3 Replies
May 24, 2011
I'm building in flash a house. Now I want when I click on a door it stays open.
I'm using an button for the effect.
I think I need some code to keep te button in the down state after I clicked it
Here's my Actionscript 3
import flash.ui.Mouse;
import flash.events.MouseEvent;
// SOUNDS
[Code]....
View 1 Replies
Mar 31, 2009
good morning, does anyone have an idea of how i can get the buttons to stay in the over state after its clicked. so the user can tell which tab he is on...i have search for tutorials and i could find is AS2 and i need AS3?
View 2 Replies
Sep 1, 2009
I have a test site on: [URL] with a problem that the sound doesn't stop when I removeChild... The playing movie with the music is to stay only on HOME.
My code on the first frame of the label "HOME":
var Xpos:Number=243;
var Ypos:Number=88;
[Code]....
I think I am supposed to add an EventListener but can't figure out where or how...
View 3 Replies
Apr 28, 2004
I made a movie clip that has this code in it
[code]...
The resize works fine but the x and y dont work. The box just stays in its place and does not move.
View 1 Replies
Nov 25, 2004
Have been incorporating XML data into applications for a while now... have now begun using it for medium to large navigation lists.While I can do any method of horizontal, clamshell, expandable, motion-based navigation etc I have a strange problem overall... I cannot, for the life of me, figure out how to code a smart function that will check which nav item was clicked and keep it highlighted until another one is clicked... then that one would highlight and all of the others would be un-highlighted.
I can do rollOvers using references to XML array generated items. BUT-- the smart checker is something I cannot figure out... any ideas out there. Must be simple.
View 1 Replies
Jun 2, 2009
I have a little quirk that I cannot think of why or how to solve. swf1 - I have buttons on stage and in the first frame actions;
med.med_btn.onRollOver = function() { TweenLite.to(med.med_btn, 1, {_x:10, ease:Elastic.easeOut}); TweenLite.to(content_mc.contMed, 1, {_alpha:100});}med.med_btn.onRollOut = function() { TweenLite.to(med.med_btn, 1, {_x:0, ease:Elastic.easeOut}); TweenLite.to(content_mc.contMed, 1, {_alpha:0});}med.med_btn.onRelease = function() { //loadMovie("webPoet.swf", "blank");}
All works fine. This is loaded inside another swf(swf2). Then the parent swf(swf2) calls for the play to go to the next frame of this movie(swf1), where each button(inside its own MC) has onClipEvent(onEnterFrame) action to drop them off the screen. Everything works perfectly except the last button you have rolled over, creates a double and stays there!!! It happens on only the last one you have touched with the mouse. If you dont touch any they all drop off as required.
View 5 Replies
Dec 8, 2011
I just got this problem after I uploaded my swf file online...it work just fine on my local disk. here the link of the website: [URL]
you can see it stay white at the beginning....it should be a FLVPlayback component.
View 5 Replies
Jul 19, 2011
I use this piece of code to create some eyecandy of debree falling. When an object is destroyed i spawn some rubble and let is fly over the screen. But... when i use this a lot, slowdown is there and even when all the objects are gone the slowdown stays. The good old 50fps won't come back anymore
public function destroyBlock(xPos,yPos,nrObjects) {
for (var debree = 0; debree < nrObjects; debree++) {
debreeObject = new mc_ground();
[Code].....
View 2 Replies
Feb 20, 2009
I have built a pre-loader from tutorials that seems to work well except that you can't see it until it hits about 8o% loaded.
this is the code for frame 1 of my movie. (loading is a text box that shows the percentage as it loads)
ActionScript Code:
stop();
onEnterFrame = function(){
var percentLoaded = _root.getBytesLoaded()/_root.getBytesTotal();
[Code].....
why the screen stays blank up until until that 8o% mark when it seems like the whole frame(preloader) loads?
It seems like everytime I get comfortable with some aspect of programming, I attempt another one that makes me wonder why I program in the first place! My mac is lucky I can't afford to throw it out the window.
View 4 Replies
Oct 23, 2009
I used the tutorial here: [URL] to achieve the above, which I did. Then I tried putting AS on the buttons I made to import external clips and they stopped working completely. I've tried putting the AS on the main time line as well as on the btn itself, I've even tried recoding the script from the tutorial and have spent hours searching the net but still cant see what I'm doing wrong.
I've attached the file which should work to me. if the btn code is deleted from the main timeline the menu acts as it should but doesn't link any where. Actually I put the file here: [URL]
View 3 Replies
Nov 25, 2004
Have been incorporating XML data into applications for a while now... have now begun using it for medium to large navigation lists.
While I can do any method of horizontal, clamshell, expandable, motion-based navigation etc I have a strange problem overall... I cannot, for the life of me, figure out how to code a smart function that will check which nav item was clicked and keep it highlighted until another one is clicked... then that one would highlight and all of the others would be un-highlighted.
I can do rollOvers using references to XML array generated items. BUT-- the smart checker is something I cannot figure out..
View 1 Replies
Jun 20, 2007
Having a really nasty problem. Been "googling" for answer for some time, but no solution so far. My flash app is quite simple. A flash app which uses locally stored XML to create UI and stuff. XML is quite large, but still quite manageable (5mb) Loading XML is pretty standard & easy. No problems here. Making a preloader is easy too. But the problem is:
While testing movie on (flash 8 dev) local machine, I cant get no preloader working. Stays at 0 and instantly jumps to 100. Problem can be bypassed on Flash 8 by setting download simulation on, and after that it works fine. But after you have published your application IE does the same as testing the movie in flash 8, basicly the whole browser is frozen for couple of seconds and then instantly jumps from 0 to 100.
If this is not confusing enough I tried my published App in Firefox and voila, preloader worked like a charm. Preloaded smoothly as silk. wonder if there is a solution? Why Firefox and IE differ so much? I been thinking if the problem is that in IE "locally stored" xml is streamed so fast that UI has no resources to update, but why on earth Firefox is not doing the same?
View 2 Replies
Apr 6, 2009
i have a mc with instance name "preload" on the first frame of the main timeline, with a movie clip instace "numbers" inside that, which contains 100 frames, with text 1-100, masking a gradiant. on the preload mc i have the following code:
ActionScript Code:
onClipEvent (enterFrame) {
var bytes = _root.getBytesTotal();[code].....
which goes to the 2nd frame once loaded marvelously... but it just stays at 1% the whole time until loaded... i keep tweaking it but no improvement.
View 3 Replies
Oct 23, 2009
I used the tutorial here:to achieve the above, which I did. Then I tried putting AS on the buttons I made to import external clips and they stopped working completely. I've tried putting the AS on the main time line as well as on the btn itself, I've even tried recoding the script from the tutorial and have spent hours searching the net but still cant see what I'm doing wrong.I've attached the file which should work to me but doesn't. if the btn code is deleted from the
View 3 Replies
Jun 18, 2009
The whole problem is in the title. I have a gallery which looks a lot like coverflow. Each button in it loads a new gallery which is a swf with a new XML. The Problem is it only works on the first time i click on a button. The XML does not renew when i click on another button. It does load the new XML.
[Code]...
View 8 Replies
Oct 23, 2009
I used the tutorial here: [URL] to achieve the above, which I did. Then I tried putting AS on the buttons I made to import external clips and they stopped working completely. I've tried putting the AS on the main time line as well as on the btn itself, I've even tried recoding the script from the tutorial. I've attached the file which should work to me. if the btn code is deleted from the main timeline the menu acts as it should but doesn't link any where.
View 1 Replies
May 14, 2009
I've started with a new Flash file and wanted to toy around with loading images and resizing the UILoader to the size of the loaded image. I've added a UILoader (instance name: loadImage) component to the main timeline and added the following code in the Actions window:
loadImage.source = "bookmark.png";trace( loadImage.content );
The image displays properly after compiling and viewing the SWF. However, loadImage.content returns null, instead of the DisplayObject that contains the image. This way, trying to resize the UIloader according to the loaded image doesn't work, since I can't access variables of an object that hasn't been initialized.
All the documentation states that loadImage.content should contain the DisplayObject that's loaded after setting loadImage.source or using loadImage.load( new URLRequest( "bookmark.png" ) ) (which also has the same problem).
View 2 Replies
May 9, 2010
I'm using some action script code for a slide. The problem is that when a smaller image is loaded, the big one stays behind for one slide more. Maybe this happens with all slides but is only visible when a smaller one is loaded... What could be done? The code is:
[Code]...
View 7 Replies