ActionScript 2.0 :: Can't Seem To Grasp The Concept Of Arithmetic In Actionscript
Feb 5, 2009I can't seem to grasp the concept of arithmetic in actionscript.
View 8 RepliesI can't seem to grasp the concept of arithmetic in actionscript.
View 8 RepliesI have been trying to get a grasp on dispatching events and have a few questions I am hoping you will all be nice enough to clearify for me.
Do I have to have a custom Event class to dispatch a custom event?
If so do I have to create a new intance of the event each time I want to dispatch an event. Example:
dispatchEvent(new MyEvent(MyEvent.TASK_COMPLETE));
or can I just dispatch an event once an instance has already previously been created.... example: dispatchEvent(MyEvent.TASK_COMPLET);?
So, I'm a beginning to intermediate Flash and AS guy grappling with some programming concepts.I find that when I create my own functions from scratch, especially to define a generic function to different movie clips, in this case to their onEnterFrame functions, I get unexpected results.The bottom is some code from a new simple website I'm trying to code. My problem is that I can't get the function working in a generic way. I know I may be taking the completely wrong approach and totally missing something, but I am continuously coming up with problems (seems to be a misunderstading of scope at a deeper level, not simple variable timeline scope, but inherant scope within functions, etc..).So, I will just copy paste the code here and try and comment as much as possible. For claritie's sake I will remove button codes except option1 and option2.
//initialization of a few global and one timeline variable. These should
//be self explanatory in the code so I wont go into to much detail
//my probs arent in the detail but in the overall relationship of the
[code].....
I can't make AS2 classes refresh when editing them, in other words, my FLA file doesn't grasp the last version when compiling, I have to shut/restart my flash program for that.
View 6 RepliesSome computationally intensive software are now using the GPU to solve mathematical problems. Now that flash has GPU support, is it possible to use flash to crunch math problems? How would it be done. In other words, does flash expose sufficient low level API to control the behavior of the GPU sufficiently to perform such a task? Example of problems; Find a message with the following hash: 2987432847298374298374982374
View 2 Repliesvar oth:Number = uup[0]+dup[0]I'm trying to find the sum of two array values and I'm just getting a concatenated string of the two numbers. What am I doing wrong?
View 3 RepliesDoes anyone know if it's possible to add objects as a whole together using operators rather than breaking them apart or using object.method() format? Below is a simple example of what I would like.
Want to do:
Code:
var obj1 = new MyClass(1,2);
var obj2 = new MyClass(3,4);
obj1 += obj2;
[Code]....
I have been placing 'numbers' into an array via an input text field. Then on completion, I want them to be added up and the results displayed. However, what seems to be happening, is that the numbers going into the array are being read as Strings .. no good.
Code:
var num_ary:Array = new Array(5,9);
num_ary.push(input_txt.text);
[code]......
I am trying to add two variables, but my AS is joining them
volume1=function(answer1){
aa=wtft*12;
aaa=wtin;[code]....
There is more to this script, but I cut it down to this in order to focus on the error, which results in a joining aa and aaa. i.e. aa=36 aaa=4 results in a=364, where what I want would be a=40
I'm making a simple calculator, where user can enter values into textboxes and then hit the calc button. E.g.
this.sales_txt.text = "8.50"
this.buying_txt.text = "3"
var marginPerLitre:Number = parseFloat(this.sales_txt.text) - parseFloat(this.buying_txt.text)
trace(marginPerLitre) // = 5.5 <--
I need the output to equal 5.50
I'm developing a library + workflow for easy (hierarchical) navigation management inside website or application. From popular - can be somehow compared with Gaia Framework and PageManager from Soma Framework (I do personally don't like these implementations because they quite limit development even if they say they don't). I used to develop website so that each section(sub-section, sub-sub-section...) is an instance of a custom class (that extends DisplayObject: Sprite, MovieClip or whatever Flex container even), that contains logic and data in "single layer" manner... and all the view coponents aswell (texts, thumbnails, whatever).
Each of those sections is implementing INavigableObject interface and has navigationHelper (way of composition pattern), which helps with all navigation stuff. So. This approach was OK. But with my last project I felt need to use MVC design pattern, so I decided to refine my navigation stuff. And so therefore I have a question: how does hierarchy looks like when using MVC (any implementation.. custom one or any popular framework like PureMVC..) for website development?
Is there a concept of pointers or anything similiar to that in as3?
I have used a concept of
var mc1:MovieClip;
var mc2:MovieClip();
var mcCommon:MovieClip = new MovieClip();
mcCommon["myptr"] = mc1;
mcCommon["myptr"] = mc2;
Where would I get to read and learn more about this concept. I'd like to get simple answers, as I am not an expert in as3. I'm still learning.
so I'm still learning the basic concepts. Attached to a movieclip used as a button I have this actionscript:
[Code]...
Which basically causes the movieclips 'leaf1' to shrink, 'vinefade' to go to its first frame, 'artween_mc' to unload, and for all other commands on this button to be disabled. I also want it to check another movieclip called 'leaf9', and see if it's current frame is at less than a particular frame number (73), because if so I want it to start playing forward. Once it reaches this frame number (73), I want to cause linkstween_mc to become visible and hit9button (also a movieclip) to become enabled. My current script does absolutely nothing to leaf9
I'm currently reading the book Learning ActionScript 3.0 and have dificulties understanding some programing basics due to my total lack of prior programing knowledge.For example now I'm looking at this script from the book that traces a list of all display objects on the stage and their children:[code]I understand everything except one thing. When there is an object with children (DisplayObjectContainer), the function traces the object but doesn't proceed and calls itself starting all over again this time analyzing the first child of the object. And if the child also have children itself the list will branch out until there is an object without children.What I don't understand is how the function at this point knows how to return to the last parent object and continue to analyzes its other children if any.For example when the function analyzes the stage of a scene with the following content how does the function know to continue analyzing child0. To me, looking at the code, I would expect the function to exit after listing [object StaticText]. I have hard time understanding what makes the function go back to largeContainer and continues with its child0 and so on.[code]This all what the book says regarding this which is not enough for me to understand this process:the function calls itself again. passing in the object currentlybeing inspected. This concept is called recursion. A function calling itself mayseem redundant, but it can be very useful. In this case, each time the functionis called, it receives a new display object to analyze, so the function reportsthe contents of that specific display object. The result is a complete walkthroughof all display objects, no matter how many children each may have.
View 5 RepliesI have load external swf file with loader. The external swf file have animation with embeded mp3 file . when i click the btn unload the external swf file .external swf file is unload ok. But Problam is after few seconds sound is hearing. I think animation still running in backend when reach the first frame sound is hearing.
var ldr:Loader=new Loader()ldr.load(new URLRequest("test.swf")) addChild(ldr) btn.addEventListener(MouseEvent.CLICK,unloadmovie)
function unloadmovie(e:MouseEvent){ ldr.unload() SoundMixer.stopAll() }
Is polymorphism is allowed in class? I mean without using get and set accessor.
View 1 Repliesi want to make a e-magazines,and i want to create with a flip book concept with flash... can i learn about this? where can i find the tutorial about this?
View 1 Repliesi am quite newbie towards to actionscript 2.0 cos i am now learning on actionscript 2.0
here is the file attachment for you to check.Greetings.zipOutput cannot be worked.I am hoping to see the exact output:Greeting = Hello!Salutation = undefinedSubject: Brick Oven
I'm dabbling in OOP, but I'm nowhere near proficient yet. I have two classes, house() and town(). In house's constructor, I want to define an exit from the house to town. I've set up a Doors and Exits array in the base class, and in house, I add town to it:
Doors = new Array(new trigger());
Exits = new Array(new town());
This way, I can check if the player is colliding with the trigger, and if so, I can set level to Exits[i] or wherever it is. My problem is, including Exits = new Array(new town()); in house's constructor calls town's constructor, and town has an array Exits, which leads back to house and so on. So my question is: How would I get around this problem or structure my level class? Is it possible to use "town" to get to new town(); without manually checking if("town"){ new town(); } etc. Basically, I want to tell flash to create a new town() WHEN I need it, not necessarily during the initial construction, but I don't want to have to manually call "new town();"
I have been charged with creating a rotating billboard for our new company website and I am in the conceptual phase of design.Everyone in the office likes the functionality of the National Geographic home billboard... with its automatic rotating images, pause functionality, and content launching frames.So far I have correctly mirrored the functionality of the National Geographic billboard by physically embedding images into a flash movie and creating mouse click events for buttons and the images themselves.
Design Question:Can Flash emulate the National Geographic presentation? Their images are called upon request, rather than being embedded into a large single movie file like mine. This would allow a non programmer to design a new image billboard and update the website remotely...
Code: Select allimport caurina.transitions.*;
addEventListener(Event.ENTER_FRAME , kop)
function kop(e:Event):void {
dot.x = mouseX ;
dot.y = mouseY ;
[Code]...
What i done there i draw a box and made it to movieclip and instance named it hook and created a invisible dot and called it dot. Then I calculated distance from box to the mouse then i took that number and put it in Math.cos command. And finally i made tweener to change box scale depending what my mouse distance from it.So if my mouse is close the box is big , if far - box is small. Ok, I want to know is there another way to do this ? Cuz , i cant think of other way to change arithmetic positive progression(like 3,6,9,12) to negative progression(like 12,9,6,3) than Math.cos command.
i'm trying to create a game that has a similar concept as Dance Dance Revolution - if shown is a down arrow then press down, if up arrow is shown then press up ...i'm having problems with the "if shown is a ... arrow" part - i managed to get pressed key check working, so if you press the correct key you'll progress but if you press the wrong one the appropriate action will execute.
in frame 1 i have the movieclip that contains the arrow display with the following code:
onClipEvent(keyDown){
if (_global.x = "up") {
if (Key.isDown(Key.UP)){
gotoAndStop("down");
[code]....
looks ok to me, but when i tested by changing the if condition for the mc action to if (_global.x = "down") the thing still executed as if _global.x = "up" .