ActionScript 2.0 :: Object Created By A Function
Aug 20, 2009why can't i acces the object outside of the function with test1._alpha = 20;[code]
View 4 Replieswhy can't i acces the object outside of the function with test1._alpha = 20;[code]
View 4 RepliesI have a class which works with data and I want to do something after its constructor function is finished and the object has been created. If a class is a MovieClip, I can do this:
[Code]....
I'm trying to dynamically addChild a Sprite to an already tweened MovieClip (tweened on the Flash timeline).
Let's say ObjectA is the tweened object, I published it in my swc and linked it to my Actionscript project in Flash Builder. I make an instance of ObjectA in my class, and then try to do the following:
var objectA:ObjectA = new ObjectA();
var objectB:ObjectB = new ObjectB();
objectA.addChild(objectB);
addChild(objectA);
Now, the problem is, objectB doesn't tween along with objectA. Is there any logical solution to this?
I am using the reflect class at [URL]. It works fine for the first playthrough. Yet, when the movie loops again, it creates another instance and again on the next loop through. There is only one object on the page and the script is: import com.pixelfumes.reflect.*;var r1:Reflect = new Reflect({mc:box, alpha:50, ratio:50, distance:2, updateTime:0, reflectionDropoff:1});
View 2 RepliesI don't really know what is wrong with the script...
ActionScript Code:
port_BTN_0.addEventListener (MouseEvent.ROLL_OVER, rolloverMCfunc);
function rolloverMCfunc(event:MouseEvent):void
{
[Code]..
So, basically I am making a mc to come inside the stage (rolloverMC_0) when I rollover over another MC (port_BTN_0). But when i rollout, it doesn't seem to work and it gives an error.
I have the following code that should set the onPress events for movieclips
Code:
function actionSetter() {
for(var k = 0; k< 5; k++) {
trace(k); //traces correctly
_level0["EventBtn" + k].onPress = function() {
[Code]...
What should I do to correctly define onPress for my movieclips within the loop?
if i have following code :
class Stand {
public static const STAND_LIST:Array = new Array();
STAND_LIST[0] = new Array();
STAND_LIST[1] = new Array();
[code]...
is the STAND_LIST[0] keeps created every new instance of Stand created? or is it created just once?if it's created every new instance of Stand created, how do i make it run just once?(like initializing const)
Is there a way to append an object that has already been created:
CODE:
userobject;
userobject = {uname:username, uage:so.data[username].age}
What if I wanted to add a phone property?
I didn't create that Timer... so this is problably a component I have addedUnfortunately it will be difficult to remove all compenents until if find the "one" ..Yes I should have notice the CPU usage sooner !and yes I will do that if I don't find another solutionI am of course using some components without having their sources...My questions :* How can I find the guilty component ?* I tried to find it using Kap Inspector without success ...any tips for Kap inspector ?
View 2 RepliesI created a canvas in a function, and in his function I have a CLICK eventlistener. On the click I want to manipulate what's inside the canvas. Will referencing the canvas using the Dictionary class work?
View 1 RepliesI'm doing a website in flash and I'm creating sprtite to put image in it (child) when we clic on a link. But when we clic on another link, the child have to be removed but it doesn't. It doesn't reach theirselves (the child), so it can't be removed.em?This is my code:
Code:
function sectIllustrations(event:Event) {
contenu_mc.gotoAndStop("illustrations");
[code].....
[code]...
now when you first look at this code.. it looks perfectly fine right? .. well if you use this exact code and place a clip on the stage with an instance name of 'mc' .. publish and rollover 'mc'... the trace statement does not show.. is there something I never read about with respect of creating functions inside if statements??
I would think you could use the function name(){ syntax.. and not be forced to using variableName = function(){ syntax in creating functions inside if statements..
I am creating a text scroller and am having problems with clearInterval - the text starts scrolling, but it won't stop after I try to clear it upon a button click.
1. I declare a var (uint) equal to a setInterval() call within a function (if the text exceeds the width of the textField)
2. I have a button that "turns off" the mp3 player (swf) and resets all the text fields.
3. I can't seem to access the setInterval ID var from within the click handler.
I have declared the var (uint) at the root level, then set it to setInterval() within the function. Then I tried to access it from the click handler. I thought this would work since it's global at that point, but it doesn't.
Here's a link to the page so you can see how it doesn't work [URL] (you have to click on the last link with the long client name)
Here's the code that's involved with this function (of course this is only the relevant code, but I would post the fla when done for anyone who wants to use it):
Code: Select all//::: SCROLL DISPLAY TEXT
function scrollDisplays():void
{
(trackTextField.textWidth > trackTextField.width) ?
[Code].....
wrote a couple of small games using AS 2.0. One of the things I found easiest about AS 2.0 is that a MovieClip created using _root. attachMovieClip() inside of one function was accessible to every other function. For instance:
Code:
function AddClip() {
TheClip = _root.attachMovie("Object", "TheClip"+ClipCount, _root.getNextHighestDepth(), {_x:30, _y:30})
}[code]....
This causes an error, because the MovieClip variable was declared inside of a function and when the function ended, the MovieClip variable was erased. Is there any way of doing this without declaring the MovieClip variable outside of the function? I want to be able to create an unknown amount of these movieclips on the fly, so I can't just declare them outside of the function.
I am new to AS3 but not to AS2. I have written a simple class and when I import it, I don't see the object that should be created upon calling the constructor. Can you guys tell me where am I going wrong. And I am very puzzled about 'document class'. Yes, I have google numerous threads on "document class" but still very shaky on this matter. Here is my simple class which should place a button object on the stage when I create a new object of this class. Once I have created the BTN class, I have made sure that I have button component in my library, I then instantiate the object by creating a new CS3 file and importing my class:
import com.learning.as3.*;
var b:BTN = new BTN();
When I test the movie, I get the following errors:
1172: Definition com.learning.as3 could not be found.
1046: Type was not found or was not a compile-time constant:
BTN.
1180: Call to a possibly undefined method BTN.
i am not sure on what key i press, but suddenly when i create object (box,line or circle) it become grouped and when i want to edit it, i need to double click. but previously it wasnt like that.
View 6 Repliesi have two swf: a and b, I cannot access the shared object which is created by a.swf from b.swf. I only catch it from a.swf. Is there any way to get it from b.swf.
View 9 RepliesThis is one of those things that seems like it should be really simple but doesn't work.
I'm trying to create a movieClip using the drawing API, but once I do so I can't get it to move with ActionScipt. My code looks (basically) like this:
Code:
drawBox = function (options) {beginFill();
lineStyle(blah);
moveTo(blah);
[Code].....
From the flash help, it says:Method; removes a movie clip instance created with the duplicateMovieclip action, or the duplicateMovieClip or attachMovie methods of the MovieClip object.
But i have movieClips created from createEmptyMovieClip();, so i'm assuming removeMovieClip(); won't work. Is there another way to remove this then?
Im currently creating textfields in a for loop - though in this example only creating one TextField. My questions is, how do I remove the TextField child in another function? What im basically doing is, create a Textfield, addchild to a container - > then the container into another position - > then removechild and another text in the container. I've tried something like:
[Code]...
Do I need to create all objects which i will possible use with itemRenderer in createChildren function, even if the current item must not show some of them ?
View 2 RepliesimportSubtemplate = new XML();
importSubtemplate.ignoreWhite = true;
importSubtemplate.onLoad = function(success) {
[code].....
[code]Then in another function, where I handle a rollover events for the Main Menu, where I want to remove the movieclip "target_mc" after a certain rollOut event [code]doesn't work.Now, I realise this is probably cause it's not in scope, but how would I remove a movieclip that is dynamically created in another function?
View 1 Repliesi wanna write a function for the onPress handler for a movieclip that will be created dynamically.. how do i do it? this is what i'm doing:
only the ending part of this loop is relevant, where i am writing the thisMC.onpress function. The trace text never appears..
Code:
for (var i = 0; i<galleryLength; i++)
{
var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc", i);
loadMovie(gallery_array[i].src, thisMC);
[Code]....
this whole loop is inside the onClipEvent(load) of another clip. So when that clip is loaded, this code is executed..
As the title suggests, I cant get function at end of the code to attach to each MovieClip I create dynamically within a loop.Only the last image will follow the mouse. What am I doing wrong? Im really not sure.
Code:
//now do something with the xml data
PopulateLists = function(final_array)
[code]....
What I'm trying to do is setup a function that shoots through a set of buttons within a subset and creates click code for these buttons.
THe three variables are the identifiers for the actual keyframe i wish to jump to, the movieclip in which i want to perform the action and the actual button to go to the right frame.
Presently the problem I'm having is that the variables aren't stored when the onRelease functions are created, so they all are just calling the LAST variables declared.
Here's a sample of the code I currently have
Code:
//function to load canvas/acrylic
function setSwatches(mySwatchCount:Number, myContainer:String)
{
[Code].....
I have writing a simple class which has a method that gets invoke when the object of the class is created. I am able to view the loaded XML content when I trace it with in my class method, but cannot assign the content to a instance variable using the mutator method. So the process goes like this:
Class object is instantiated Class construtor then calls the loadXML method which laods the XML And then assigns the XML to a class instance variable.
So now if I would like to access the loaded XML through class object, I should be able to see the loaded xml content which I am not able to see. I have spent over few hours and cannot get the class object to display the loaded XML content. .
[code]
package com.as3.app{ import flash.display.*; import flash.events.*; import flash.text.*; import flash.net.*;
public class Cars extends MovieClip { public var _CarList:Object;
[Code]....
I'v been toying with this for a few weeks now and I'm trying to find the best way to animate several instances of an object created by a for loop thru an ENTER_FRAME function.When the function runs only 1 of the 3 instances that were created animates.
var balloonArray:Array = new Array();var balloon: hotAirBalloon;var xVel: Number = -3;var yVel: Number = -4;
addEventListener(Event.ENTER_FRAME, startBalloons)
[code]....
I have is Adobe fl CS4. I succussfully created a scene with all correct layers including a start button action script. No errors works great. Now my next challenge is, how do I cause a word to apear? I created some objects that I want to select and cause a word to appear and color to change, once I hover over the object. It is like the same method when you create a 'start button.' Do I create another sub scene in the action script command?
View 32 RepliesI am drawing some lines in my program using
graphics.lineTo(xx, yy);
The program has a background image over which these lines are drawn.The problem which I am facing is that the image overshadows the lines and the lines are not visible to the user.Since these lines do not have an id, I am not sure as to how I can assign a depth to them?