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




Scope Trouble... Unregister/ Remove Object / Tween ?



Hi, I hope somebody can help with the following problem.I'm trying to make a powerpoint kind of projector:- Main flash movie: works as a container to load different flash files.reacts on the left and right arrow buttons to go to the next or previous movie, which is loaded in a movieClip. - Several external swf files all exported from the same: slide.fla only adjusting xml node settings make the differences in text and pictures.This works, but after loading into the container I use to show the images the tween of my images gets messed up. (Not in the first loaded movie, but sure after around the third) Please can anybody look at my code and tell me what could be the problem?I'm sure it has to do with the scope after loading into the container.fla, and all the objects having the same name, for the submovies. (exported from the same .fla)Do I have to unregister/ remove these objects after usage - I think this might be it, but don't know how. In the container.fla I already set:clipLoader_mc._lockroot = true;but this doesn't solve the problem.
Code:
/// **************************** ////// START TWEEN METHODS FOR SCREENS ////// **************************** ///var mcl_obj:Object = new Object();mcl_obj.onLoadInit = function(target_mc:MovieClip):Void {target_mc._width = 500;target_mc._height = 395;target_mc._x = 500;var distance:Number = 5;var angleInDegrees:Number = 45;var color:Number = 0x000000;var alpha:Number = 75;var blurX:Number = 7;var blurY:Number = 7;var strength:Number = 1;var quality:Number = 3;var inner:Boolean = false;var knockout:Boolean = false;var hideObject:Boolean = false;var filter:DropShadowFilter = new DropShadowFilter(distance, angleInDegrees, color, alpha, blurX, blurY, strength, quality, inner, knockout, hideObject);var filterArray:Array = new Array();filterArray.push(filter);target_mc.filters = filterArray;var tween_target:Object = new Tween(target_mc, "_y", Back.easeInOut, Stage.height, 300, 1, true);tween_target.onMotionFinished = function() {intervalClearScreenId = setInterval(ClearScreen, 8000, counter);};screenCounter++;//initiated on top of the page. };function ClearScreen():Void {var tween_screen:Object = new Tween(mover_mc, "_x", Strong.easeInOut, mover_mc._x, 1250, 1, true);tween_screen.onMotionFinished = function() {if (screenCounter<screenMaxCount) {ShowScreens();} else {screenCounter = 0;ShowScreens();}clearInterval(intervalClearScreenId);};}ShowScreens = function ():Void {// Create a movie clip instance.this.createEmptyMovieClip("mover_mc", getNextHighestDepth());var img_mcl:MovieClipLoader = new MovieClipLoader();img_mcl.addListener(mcl_obj);// Load an image into the movie clipimg_mcl.loadClip(imageArray[screenCounter], mover_mc);};//load XML voor screens on the left:function loadScreensXML(loaded) {if (loaded) {_rootNode = this.firstChild.childNodes[imageNodeNr].childNodes[0];trace(_rootNode);total = _rootNode.childNodes.length;for (i=0; i<total; i++) {//add images to imageArray:imageArray[i] = _rootNode.childNodes[i].firstChild.nodeValue;}screenMaxCount = imageArray.length;//initiated on top of the page//Show the screens:ShowScreens();} else {content = "file not loaded!";}}xmlScreens = new XML();xmlScreens.ignoreWhite = true;xmlScreens.onLoad = loadScreensXML;xmlScreens.load(urlImagesXML);/// **************************** ////// END TWEEN METHODS FOR SCREENS ////// **************************** ///
I'm trying all day already to solve this so please can anybody help?Thanks in advance!



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 10-18-2005, 12:01 PM


View Complete Forum Thread with Replies

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

Tween Scope
I'm using tween animations imported in.

Most of my code is on my root, however there is a MC which gets dupilcated and loads in seperate xml data

atm I'm just using one alpha tween in the mc, but so far I seem to lose scope unless I load the tween class in to the MC, which is daft, seeming it gets duplicated.

.....

the MC in question, loads in XML and displays a thumbnail gallery, the tween is onLoadComplete function and alphas the file in.

var myAlpha:Tween = new Tween (targetMC,"_alpha",Strong.easeOut,0,100,3,true);

is there a simple way of just referring to the imported tween on the root

or would I have to call a function on the root, referring to targetMC?


....

thanks

Scope Trouble
Code:
item_bin = [];
Myfunction = function () {
var service = new WebService("A service");
serviceResultObj = service.FetchSomething(this);
service.onLoad = trace("Loading");
serviceResultObj.onResult = function(result) {
for (h = 0; h < result.length; h++) {
title = result[h].attributes.title;
var ob = {title:title};
item_bin.push(ob);
}
trace("VerzamelBin " + verzamel_bin); // Succes
_global.verzamel_bin = verzamel_bin;
};
};
Myfunction();
trace("Global_item_bin " + _global.item_bin); // No Succes
I need this object "item_bin" outside my function.
It has been told to me to use 'Array:concat()' to copy the object.
Can anyone help me with this?

TIA

Scope Trouble
item_bin = [];
Myfunction = function () {
var service = new WebService("A service");
serviceResultObj = service.FetchSomething(this);
service.onLoad = trace("Loading");
serviceResultObj.onResult = function(result) {
for (h = 0; h < result.length; h++) {
title = result[h].attributes.title;
var ob = {title:title};
item_bin.push(ob);
}
trace("VerzamelBin " + verzamel_bin); // Succes
_global.verzamel_bin = verzamel_bin;
};
};
Myfunction();
trace("Global_item_bin " + _global.item_bin); // No Succes

I need this object "item_bin" outside my function.
It has been told to me to use 'Array:concat()' to copy the object.
Can anyone help me with this?

Big ==> TIA

Using Tween Class Changes Scope?
i have a custom class which implements the tween class. I'm just shrinking and enlarging a box.

when I just set the variables:
box_mc._width = boxOrigW;
box_mc._height = boxOrigH;

it changes the box to the correct size
but when i apply the same variables in the folling tween code, the size change is totally wrong

var boxSizerW:Object = new Tween(box_mc,"_xscale",mx.transitions.easing.None. easeNone,boxSmallW,boxOrigW,3,true);

var boxSizerH:Object = new Tween(box_mc,"_yscale",mx.transitions.easing.None. easeNone,boxSmallH,boxOrigH,3,true);

Scope In Tween Class
Hello all!

Can any one tell me why cant i control objects inside MovieClip play by tween class.

Thanks.

Trouble With Function Scope?
do functions have a scope?
i can call a function when its in the same clip
but if i declare it outside of the clip i want to use it in
it doesn't work!
aren't functions global...that is ..cant i declare and call from anywhere
i'm very frustrated..help please

Scope Trouble With LoadVars
[AS1][loadVars] Scope trouble with loadVars !

Hi everybody,

I'm new on this server !
You will find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.

The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).

For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.

Here is the script of frame 2, some of you may understand quickly what's wrong :

//var maxVinNum = 6;
var vignetteVars = new LoadVars();
vignetteVars.onLoad = function(ok) {
if (ok) {
trace(this.loaded);
maxVinNum = this.maxVin;
trace("maxVinNum = " + maxVinNum);
}
};
vignetteVars.load("externalVar.txt");
//
function buildArray (arrayLength) {
FileArray = new Array();
for (var i=0; i<maxVinNum; i++){
FileArray.push ("v_"+(i+1)+".jpg");
}
trace("FileArray : " + FileArray);
};
//
function buildSlide(){
vinKern = 1;
preloadSlide = new Preloader(load_indicator);
for (var i=0;i<FileArray.length;i++){
//Construction du slide
slide.vignette.duplicateMovieClip("vignette"+i,i);
slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);
// ajoute à la file du preloader
preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");
}
slide.vignette._visible=0;
};

buildArray(maxVinNum);
buildSlide()
stop();


I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !

Scope Trouble With LoadVars
[AS1][loadVars] Scope trouble with loadVars !

Hi everybody,

I'm new on this server !
You will find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.

The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).

For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.

Here is the script of frame 2, some of you may understand quickly what's wrong :

//var maxVinNum = 6;
var vignetteVars = new LoadVars();
vignetteVars.onLoad = function(ok) {
if (ok) {
trace(this.loaded);
maxVinNum = this.maxVin;
trace("maxVinNum = " + maxVinNum);
}
};
vignetteVars.load("externalVar.txt");
//
function buildArray (arrayLength) {
FileArray = new Array();
for (var i=0; i<maxVinNum; i++){
FileArray.push ("v_"+(i+1)+".jpg");
}
trace("FileArray : " + FileArray);
};
//
function buildSlide(){
vinKern = 1;
preloadSlide = new Preloader(load_indicator);
for (var i=0;i<FileArray.length;i++){
//Construction du slide
slide.vignette.duplicateMovieClip("vignette"+i,i);
slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);
// ajoute à la file du preloader
preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");
}
slide.vignette._visible=0;
};

buildArray(maxVinNum);
buildSlide()
stop();


I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !

Scope Trouble With LoadVars
[AS1][loadVars] Scope trouble with loadVars !

Hi everybody,

I'm new on this server !
You will find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.

The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).

For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.

Here is the script of frame 2, some of you may understand quickly what's wrong :
ActionScript Code:
//var maxVinNum = 6;var vignetteVars = new LoadVars();vignetteVars.onLoad = function(ok) {    if (ok) {        trace(this.loaded);        maxVinNum = this.maxVin;        trace("maxVinNum = " + maxVinNum);    }};vignetteVars.load("externalVar.txt");//function buildArray (arrayLength) {    FileArray = new Array();    for (var i=0; i<maxVinNum; i++){        FileArray.push ("v_"+(i+1)+".jpg");    }    trace("FileArray : " + FileArray);};//function buildSlide(){    vinKern = 1;    preloadSlide = new Preloader(load_indicator);        for (var i=0;i<FileArray.length;i++){            //Construction du slide            slide.vignette.duplicateMovieClip("vignette"+i,i);            slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);            // ajoute à la file du preloader            preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");        }    slide.vignette._visible=0;};buildArray(maxVinNum);buildSlide()stop();

I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !

Scope Trouble With LoadVars
[AS1][loadVars] Scope trouble with loadVars !

Hi everybody,

I'm new on this server !
You will find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.

The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).

For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.

Here is the script of frame 2, some of you may understand quickly what's wrong :
ActionScript Code:
//var maxVinNum = 6;var vignetteVars = new LoadVars();vignetteVars.onLoad = function(ok) {    if (ok) {        trace(this.loaded);        maxVinNum = this.maxVin;        trace("maxVinNum = " + maxVinNum);    }};vignetteVars.load("externalVar.txt");//function buildArray (arrayLength) {    FileArray = new Array();    for (var i=0; i<maxVinNum; i++){        FileArray.push ("v_"+(i+1)+".jpg");    }    trace("FileArray : " + FileArray);};//function buildSlide(){    vinKern = 1;    preloadSlide = new Preloader(load_indicator);        for (var i=0;i<FileArray.length;i++){            //Construction du slide            slide.vignette.duplicateMovieClip("vignette"+i,i);            slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);            // ajoute à la file du preloader            preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");        }    slide.vignette._visible=0;};buildArray(maxVinNum);buildSlide()stop();

I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !

Trouble With Variable Scope Or Reference (AS2)
Hello !

The simple code below maps onRelease functions to 8 buttons.
The goal is to load the corresponding image into a single central imagePanel whenever a button is clicked.

There are 8 instances of the same MC on the scene (named g0 to g7), each containing a button (btnShow)

The "downloadImage()" function loads the image when triggered by the onRelease event.
The path to each image file is taken from the _global.paintings Array (url property).

The problem:
It looks like that, during the assignment, a link is made to the "reference" of the 'i' variable, instead of its VALUE.
So, at run time, 'i' equals 8 (value at the end of the loop) for EVERY downloadImage function, instead of the incremented value ( 0 to 7)...

Thus resulting on every button loading the same image, instead of the corresponding image (taken from the url property in _global.paintings[0] to [7])

Well, not easy to explain properly, I hope you'll understand what I mean...

Thanks a lot for your help, I'm pretty lost here !
Cheers
Luca

=======









Attach Code

function formatGal() {
// I've removed all unecessary code...

for (var i:Number = 0; i <8; i++) {

_root["g"+i].btnShow.onRelease = function() {

downloadImage(_global.paintings[i].url);
trace(i);
}
}
}

Trouble With Scope And Delegate,load XML
Hi All,

I'm sure this is a common error, and I've tried searching around for the answers, but after a whole day of unluck yesterday I've decided to post it on the forum.

I'm having a hard time with a scoping issue. I have a mc that is to load some XML. I want to grab the info from the XML, stick it in an array, and have the array be accessable in my class.

Simple right??!??!

Getting the XML and parsing it is no problem. I can't get it to retain the correct scope and let the class variable reflect the results from the XML file.

I've read all the posts as well as kirupa and some other sites. I can't seem to figure out what's up with the delegate and why the scope is not working.


Please help I have been trying this all day long. Thanks!!!

Here it is in a class::


HTML Code:
import mx.utils.Delegate;

dynamic class mc_random_img extends MovieClip{
public var images:Array;
private var _xml:XML;
private var xml_source:String;


function mc_random_img(){
images = new Array();
xml_source = new String();
_xml = new XML();
_xml.ignoreWhite = true;
_xml.onLoad =Delegate.create(this, onLoadEvent);
_xml.load("random_img.php");
}

function onLoadEvent(success:Boolean):Void{
if (success) {
xml_page_node = xml_source = _xml.childNodes[0];
my_images = xml_page_node.childNodes;
for (var i=0; i<my_images.length; i++) {
rand_pic = my_images[i];
rand_file = rand_pic.attributes.thumb2;
trace(rand_file) //prints file OK
// add the value to the images array!
images.push(rand_file);
}
trace("IMAGES FINAL:" + images.length); // prints out the correct length
} else {
trace("xml NOT loaded ok");
}
}


function get_images(){
trace("get images" + images.length); // prints 0...
trace("get images" + xml_source); // prints undefined...

}



}
.... and I call it like this::


HTML Code:
test = new mc_random_img();
test.get_images();
Man it's frustrating, if someone would be kind enough to explain what I'm missing I would really appreciate it. Thanks again and THANK YOU KIRUPA, your tutorials are excellent.

Frizzo

Object Scope From MC
How can you call an Object method from an embedded MC onEnterFrame Event. Its another problem with scope that i cant figure out

Code:

function newTarget()
{
this.MyClip=attachMovie( "fly", "fly1",100);
this.MyClip.onEnterFrame=function()
{
//'this' here refers to the MyClip Instance, i need to target its object parent
this.Update()
}
}

newTarget.prototype.Update=function()
{
trace("called")
}

newClip=new newTarget()

I've tried various different solutions and cant get it to work. Any help or pointers appreciated.

Cheers

Object Scope Help
postObj = {};
postObj.me=this.postObj
postObj.page = 10;
postObj.lastPage=this.page/2
trace(postObj.lastpage)

how come it doesnt trace out the correct number. Is it got to do with scope? how do i solve this prob?

Get Scope Of Object
How is it possible for a Class to obtain the scope on which it was instantiated without passing a 'this' reference?

I need my Class to know whether it was instantiated on the root timeline or inside another MovieClip. Is this possible?

Trouble With Drop Down Menu: HitArea? Scope? (slowly Going Insane…)
I'm trying to build a set of drop down menus (.fla attached below).

I had to separate the header movie clips from the submenus to work around a stacking issue and then use an alternate and invisible hitArea to keep the submenus down when I rolled off the heads. Everything works except for the submenu clips which do not respond to rollovers (they work fine in other test enviroments).

Is the alternate hitArea shape (which is above the submenu clips) interfering with rollover? The player can see nested mouseEvents, no?

Something else I'm missing?

It seems to me like I was having similar troubles before the hitArea fix (at about 4 am) and I'm still having trouble with relative and absolute paths (relative paths tend to work less often). But I could generally sort those out after a bit.

stumped, dead in my tracks, and slowly becoming insane

How To Remove Motion Tween
Anybody can tell me if we accidently create a motion tween and then remove it then what is the procedure.

Is It Possible To Remove A Button When You Tween It Away?
I was wondering if its possible to remove a button once its faded away. Or if its possible to make it inactive just during the time its alpha = 0?

Im going to make a control panel that I want to fade in when over and fade out when move the mouse away but if I put a layer over the control panel the control panel wouldn't work even though I don't have a onPress/Release function on the layer over.. I cant really come up with a good solution for this if its not possible to make an alpha = 0 layer inactive.. any ideas?

Object Scope Question
obPath=_root.pane.list.arrayTree[sIndex][rIndex];

i have a clip that requires quite a bit of data from a series of load var objects embedded in an array in another movie clip. i figured i could save a little typing for myself if i took the common part out and assign it to a var. the debug shows that obPath=[object #16 'LoadVars']

is this a reference to that object or has obPath become a complete copy of object # 16?

Super, Scope, Object
Having problems writing a class that includes the XML object via prototype.
I call the constructor for the XML via super(), but this overwrites any properties or methods in the child Object.Why?

The object is a manager for loading all data and SWFS etc.. into my site, thus requires extended properties and methods beyond the scope of the XML object alone.

Really annoyed as thought i had scope sorted but in my head but.......

the code is below ( any xml file to load will do)

SiteManager.prototype=new XML()


function SiteManager()
{
//if super() is commented out and you list variables on test movie this.textvariable has a value, however without it disappears and the Object doesnt inherit XML methods!!!!

super()
this.textVariable="i am a Value"
this.load("menus.xml")
this.onLoad=this.checkStatus
}
SiteManager.prototype.checkStatus=function(success )
{
if(success)
{
trace("done")
}else{
trace("failed")
}
}


webmanager=new SiteManager()



Hope someone can help me think my way through this.

Cheers

Scope Of Created Object
using this code to create 4 instances of the loader component and fill it with a jpg.

it works.. except none but the last instance created remains.

i would understand if i the instance names were the same (and with each iteration was being overwritten), but they are not.

so how to make the newly created instances permanent??


Code:
for (i=1;i<=4;i++)
{
vartmpLoader:mx.controls.Loader = _root.createObject("Loader", "loader" + i, 0);
tmpLoader.move(100*i,200);
tmpLoader.contentPath = "images_folio/folio_00" + i + ".jpg";
}

Shared Object Scope
Hi,

I am trying to find out how to allow multiple users on a Windows machine to all use the same shared object data.
What I need to be able to do is have data saved by one machine user visible by another machine user logged in to Windows under a different user account.
Here is an example of what I am trying to do:
User 1 logs in to Windows as User 1, runs a Flash Projector program from a CD that saves data to a shared object.
User 2 now logs in to Windows as User 2, runs the same Flash Projector program and is able to retrieve the data saved by User 1.
This seems like it should be a pretty basic requirement but I can't seem to get it to work.
Can anybody tell me what I need to do to get this to work?

I have tried using shortcuts from User 1 placed in User 2's Application Data path but this doesn't work.
I have tried Placing User 1's data in the "All Users" Application Data path also to no avail.

The shared objects are all saved in a directory named for the CD under the root for that user.

Any help in getting this working would be greatly appreciated.

Thanks,

Colin

Object Scope Question
Hello. I haven't asked for help in a long time so I'll get to the point.

I have:


Code:
MyPlayer = function()
{
this.n = 0;
};

_global.player1 = new MyPlayer();
in layer 1 of my movie.

later, in clip1 of layer 2 i have


Code:
onClipEvent(load)
{
_global.player1.n = 300;
trace(_global.player1.n);
}

onClipEvent(enterframe)
{
_global.player1.n += 3;
trace(_global.player1.n);
}
I am coding in flash mx, and when I run the movie it traces


Code:
300
303
3
3
3
3
I read the Variable scope tutorials and I understand most of it, but I dont know why _global.player1.n doesn't increase by 3 like I want it to?

thanks!

Scope Problem With An Object Within A Class
Hi folks,
i hope someone may help me out with this one:

i have a Class, let's say SomeClass:

PHP Code:



class SomeClass {
    var someObject:Object;
    var someString:String;
    
    function SomeClass() {
        someString = "i am the string that can not be reached 
from within 'someObject', why?";
        someObject = {
            scopeProblem: function() { trace("->"+someString+"<-"); }
        }
    }
    
    public function dynamicFunction(s:String) {
        someObject[s]();
    }







My aim is, to call a function with a string as parameter, which then calls that function in the Object, known from the string. That appears to be okay:


PHP Code:



import SomeClass;
var test:SomeClass = new SomeClass();
test.dynamicFunction("scopeProblem"); 




it traces "->undefined<-"

The thing is that the function is actually called, but it can neither reach a member var of that class, in this case "someString", nor a member method.

please help , or tell me about another method to gain succes =)

thanks in advance.

Function/object Scope Problem?
From what I have read it's best to keep all Actionscript on a single empty layer at frame 1 of the timeline. I did just that and I'm having some problems.


I have on other layers a set of animated buttons that appear one after the other, one starts to fade-in at frame 1, the second at frame 15, the third at frame 30, and so on. Each animation lasts for about 20 frames.

The problem I'm having is that the actionscript tha controls "OnRelease" and other events related to those buttons only works if I move the "actions layer" containing the actionscrip code to the same position in the timeline where a button "appears".

For example: If my actions layer is at frame 1, the events for button 1 will work. If the actions layer is at frame 45 the button 4 will work but the others won't.

To sum up: The actionscript only works if at a specific position in the timeline, how do I "initialize" the buttons so that I can place all my actionscript in frame 1?


Thanks in advance,

AS 2.0 Object Scope/load Problem
I have a AS2.0 file that describes a page in a book (Page.as). The class page contains private variables that define things like the background image and hotspot locations on the page. I have a "pre-processor" that takes the action script file inserts the page specific images and then builds the page using the Motion Twin compiler. The output SWFs all load correctly by themselves. However when I load the page SWFs from my viewer each data has the data from the first page. It appears to be a scoping problem that only the class Page from the first SWF is being loaded. If I change the name of the class/file to something unique and recompile it works.

Is there a solution to this without renaming each file and class?

XML Object OnLoad Scope Problem
Hi All,

I've got a very frustrating scope issue here, probably quite simple, but it's got me stumped.

I have a class which loads up some XML into an XML object, on loading the XML I want to fire a function in the class.

I'm obviously doing something wrong because processXML is not happening. I have tried calling _root.instance.processXML(this) in the onLoad function, and that works, but I can't use _root because I don't necessarily know where this is going to be used.

Any thoughts?

Many thanks
Kevin

My code:







Attach Code

class classes.availability extends MovieClip {
var my_xml:XML;
var feedURL:String;

private function init(){
trace("Initialising office availability");
feedURL = "http://addressofmyxmlhere.xml";
my_xml = new XML();
my_xml.onLoad = function(success){
trace("loaded XML");
processXML(this);
};
my_xml.ignoreWhite = true;
my_xml.load(feedURL);
}

public function processXML(xml){
trace("processing XML");
}
}

Object/function Scope Question
Hello.

I have what I can only assume is a stupid question, but I can't find a satisfactory answer.

I need to bring an AS 1.0/2.0 project up to AS 3.0 standards in a reasonable timeframe. In the original project, it was common practice to group related functions under descriptive parent objects, such as chatO.pushMessage(), chatO.displayPrompt() and so on.

However, I'm running into a problem where the very simple definition (formatted to be concise):a:Object = {};
a.f1 = function() { var i:Number=1; trace(i); };
a.f2 = function() { var i:Number=2; trace(i); };
generates this error upon compiling:1151: A conflict exists with definition i in namespace internal.
Assigned named functions seem to work...function f1() { var i:Number=0; };
function f2() { var i:Number=0; };
var b:Object = {};
b.f1 = f1;
b.f2 = f2;
... generates no errors.

I know that the two types of function declaration are not equivalent. But I don't understand why the two different functions in the first example share the same scope. Tests with our code suggest that going ahead with assigning named functions should work, but I already feel uncomfortable proceeding with a weak understanding of what was broken in the first place.

Any insight would, of course, be greatly appreciated.

Thank you,
-Lowpass

XML Object OnLoad Scope Problem
Hi All,

I've got a very frustrating scope issue here, probably quite simple, but it's got me stumped.

I have a class which loads up some XML into an XML object, on loading the XML I want to fire a function in the class. Here is my code:


Code:
class classes.availability extends MovieClip {
var my_xml:XML;
var feedURL:String;

private function init(){
trace("Initialising office availability");
feedURL = "http://addressofmyxmlhere.xml";
my_xml = new XML();
my_xml.onLoad = function(success){
trace("loaded XML");
processXML(this);
};
my_xml.ignoreWhite = true;
my_xml.load(feedURL);
}

public function processXML(xml){
trace("processing XML");
}
}
I'm obviously doing something wrong because processXML is not happening. I have tried calling _root.instance.processXML(this) in the onLoad function, and that works, but I can't use _root because I don't necessarily know where this is going to be used.

Any thoughts?

Many thanks
Kevin

Scope Of Object In Library Issue
I am working on an application that dynamically populates the program with assets from the library. I have a simple need to call a function from the root timeline. so in the AS layer of the Object I have the following

pr_01_01_pdf.addEventListener(MouseEvent.CLICK, sendPDF);
function sendPDF(event:MouseEvent):void {
root.openPDF(event.target.name);
}

I get the following error: 1061: Call to a possibly undefined method openPDF through a reference with static type flash.displayisplayObject.

I have about 45 of these that go in the application and I basically need the hyperlink to call a function with the targeted name.

Tween Class To Move An Object Called From Within The Object
I have a custom class that I want to move with the Tween Class
I am calling the Tween constructor from within that class but when I pass the keyword "this" as the object of that constructor , it doesnt move at all the code is as follow


PHP Code:



package{import fl.transitions.Tween;import flash.display.MovieClip;public class PortViewer extends MovieClip{var _twn:Tween;public function PortViewer(){    _twn = new Tween(this, "y", None.easeNone, 0, 100, 2, true);}}} 




how do I reference the object from within itself is there another keyword?
There are no errors it just doesnt move

Thank you Kirupa forums

What Is The Scope Of Shared Object Variables On A Network?
If for example one computer on the network changes one variable stored in shared objects, does the change affect all other computers that access the program?, OR Does each computer keep its own space?

What is the scope of shared objects on a network? The whole network or individual computers?

Thanks

Bizarre Sound Object / Scope Problem
I set up a var : Sound = new Sound()
type sound object, and it works great... in the movie I set it up in. The way the site works, that movie is loaded in with loadmovieNum into a root movie...
and, when I test the movie like this, it refuses to play. Now I can still get sounds to play just by dumping them on the stage in the root level, but even by transfering the code that creates that sound object all into the root movie, I still can't get it to work.
Any ideas?
--Erik
ebkortz@yahoo
Erik@kortzcrystal.com

Bizarre Sound Object / Scope Problem
I set up a var : Sound = new Sound()
type sound object, and it works great... in the movie I set it up in. The way the site works, that movie is loaded in with loadmovieNum into a root movie...
and, when I test the movie like this, it refuses to play. Now I can still get sounds to play just by dumping them on the stage in the root level, but even by transfering the code that creates that sound object all into the root movie, I still can't get it to work.
Any ideas?
--Erik
ebkortz@yahoo
Erik@kortzcrystal.com

Scope In Object Class File Using LoadVars - Help
Hi guys,

please help, i'm pulling my hair out!! i can't seem to get my head around scopes within a class file i've tried to create..

the aim of the class file is to go and retrieve a news article form a mysql database and store data such as "headline" and "textBody" etc in it so that i can then display it in a dynamic text box later in the movie file.

here is the code on the flash file creating the flash:

Code:

import as.*
trace("step 1");
var testING:newsArticle = new newsArticle(3);
trace ("step 2");
trace ("head = "+testING.headLine + " &id = "+testING.aID);
here is the actual class file newsArticle.as...

Code:
import mx.utils.Delegate;
class as.newsArticle {


var aID:Number;
var table:String = "sales_headlines";
var returnPage;
var graphic:String = "";
var headLine:String;
var bodyText:String = "";
var mainText:String = "";
var catID:Number = 0;
var displayAsNews:Number = 0;
var articleDate;

var $loader:LoadVars;
var $url:String = "http://www.xyz.com/flash/getdata.php";

var thisObj;

function newsArticle($id) {
//----------------------------------------------
// article is being created so go to the
// database and get all the details
//----------------------------------------------
aID = $id;
var thisObj:newsArticle;
_global.thisObj = this;
init();
execute();

trace ("sweet "+headLine);




} // end of constructor



function init () : Void {
$loader = new LoadVars();
$loader.onLoad = Delegate.create (this, onLoad2);
}
function execute () : Void {
$loader.load($url);
}
function onLoad2 (success:Boolean) : Void {
if(success) {

_global.thisObj.headLine = $loader.headline0;
trace ("ok ----- "+headLine);


} else {
trace ("bad !");
}
}

} // end of class file
and finally here is the trace output..

Code:

step 1
sweet undefined
step 2
head = undefined &id = 3
ok ----- The world's first 100Mbps Hotel Internet Pipe
Please can anyone advice on what the heck i'm doing wrong??? I want to be able to call "testING.headLine" anywhere in my movie file.. how do i make it a global object? and how do i populate the class variables so they can be accessed from the .fla file.... the aID works but not the headLine arrghhh!

Thanks in advance for any advice...

Object Lifespan Within A Scope (Garbage Collection)
Hey all,

So take this basic function:


Code:

public function createNew() {

var myObj = new AwesomeObject();

myObj.setX(30);
myObj.setY(30);

}
Since i'm using the "new" keyword, I'm creating a new Instance of my AwesomeObject and then i'm accessing some of the properties.

However, once i exit the function, I have no way to reference my AwesomeObject instance. Does Flash then consider this garbage? And will then clean it up at some indeterminate time?

Or do I have to explicitly put in another line such as:

myObj = null;

Thanks!

Xml OnLoad And Scope Delegating And Maybe Proxy Destroys The Xml Object
realy want to avoid using root but cant get to the parent. I cant get jessies proxy to work propery, cant even import it for some reason. Here is the code, this isnt easy, delegate destroys the xml and maybe proxy does as well.


Code:
var xmlOUT:XML = new XML("<root><node1></node1></root>");
var xmlRTN:XML = new XML();
xmlRTN.ignoreWhite = true;
//------------------------------------------------------------------------------
//xmlRTN.onLoad = Proxy.create(this, assignText, "arg1", "arg2");
xmlRTN.onLoad = myOnLoad;
//xmlRTN.onLoad = Delegate.create(this, myOnLoad);
//------------------------------------------------------------------------------
xmlOUT.sendAndLoad(this.path, xmlRTN);
//xmlOUT.sendAndLoad = Delegate.create(this, myOnLoad); //this breaks the xml-not good!!!!
function myOnLoad(success:Boolean) {
var xmlpath = "/abc/xyz";
var someXML = mx.xpath.XPathAPI.selectNodeList(this.firstChild, xmlpath);
if (success) {
if (String(someXML[0].firstChild.attributes.success) == "1") {
//assume this is the case
_root.errorBox.errorMessage.text = "GOOD LOGIN SPORT !";
//dont want to use _root here but have to
}
}
}

How To Remove An Object?
Hi Guys

I've got an object which is used as part of a function to track the operation of the wheel mouse. How can I remove this object if i wanted to?

Here's my code to create it:

Code:
var mouseWheelListener:Object = new Object();
mouseWheelListener.onMouseWheel = function(delta) {
.......
}
Problem, is that when I reload this frame, a new instance of this object is created making it execute twice, so what I want to do, is remove this object before the frame reloads........

How Do I Remove This Object?
I've output my displayList shown here:


Code:
[object BaseCode]root1

[object Screen_title]instance4
[object Backgrounds]instance7
[object TextEasier]instance5
[object MovieClip]instance49
[object MovieClip]instance50
[object background3]backScreen
[object Shape]instance52

[object Q_multChoice]instance9
[object Backgrounds]instance12
[object TextEasier]instance10
[object MovieClip]instance65
[object MovieClip]instance66
[object background3]backScreen
[object Shape]instance68


Basically I'm in a class ("Q_multChoice" which is instance9) and I need to move back one and then down into "Screen_title" or instance4 and remove instance 49. The problem is that I won't know the index of "Screen_title" as that can change but I can know it's 'name' property. How do I remove 'instance 49'?

I've tried the following but it gives me an error:

Code:
parent.getChildByName("instance4").removeChild(getChildByName(mcName));

How Do You Remove An Object
how do you remove an object? and also remove it from the child list?
(after u typed addChild()

Remove And Object Fra An Array
How do I remove an object from an array like, if I have an array like this:

myArray[0,1,2,3,4,5,6]

and I remove myArray[2] the result will be:

myArray[0,1,3,4,5,6]

Is there an easy way to do this?

[F8] How Do I Remove A Listener Object?
I have created a listener object this way:

_root.cmbCatListener = new Object();


Code:
_root.cmbCatListener.change = function(evt_obj:Object):Void {
// do something
}
How do I remove that?

I tried:


Code:
_root.cmbCatListener.removeListener(this);
_root.cmbCatListener = undefined;
No one worked, and the listener still keeps there.

Thanks.

Completely Remove Object
Hi,

I've been having some problems with these scripted transitions I wrote.
Basically I'm using actionscript to attach a movie clip, stretch the movie clip across content in the movie to create a masking effect and then go to the requested frame.

the new frame has actions to unload the movie clips I attached previously.

The problems occur when I go back to the frame I started from. I'm reattaching movie clips with the same names they show up fine but it seems like the function to stretch them out is unable to manipulate the reattached movie clips.

I think this is because they have the same names as the previously unloaded MCs.

When I go to debug > list objects when I'm on the next frame where it unloads the MCs the clips I unloaded are still listed as objects. I've also tried using delete to get rid of these objects but they still show up in the list.

Is there a way to completely kill these objects?

Remove Property From Object
Hi,

I have an ObjectCollection class which I need to allow me to add and remove props from an object.

The adding is easy, and I can remove a property's value, but how do I remove the prop itself:


Code:
delete myObject["prop"]
... removes the value, but if I iterate through the object, the property still remains, just with the value of null. So how do I get rid of the property?

Thanks

Remove Object After HitTest?
Hello all! This is my first post in this community and I plan on becoming a regular member of it in the coming months.

Quick question for you all and a bit of hope that you'll be able to help me fine tune what I've written.

Basically I have a circle (the player) on the screen and two squares, one speeds the circle up and one speeds the circle down. I wanted to test out the idea of powerups and I have it working wonderfully except I can't seem to figure out how to make the squares disappear after being "hit".

Also, if there's anyway one of you AS3 gurus could evaluate my code and possibly show me a more refined way of writing it, that would be awesome to! (This is the very first bit of code I've ever written in any language.)

Here's my code:



Code:
var leftKeyDown:Boolean = false;
var upKeyDown:Boolean = false;
var rightKeyDown:Boolean = false;
var downKeyDown:Boolean = false;
var mainSpeed:Number;

mainSpeed = 10;

stage.addEventListener(Event.ENTER_FRAME, moveChar);
function moveChar(event:Event):void{
if(leftKeyDown){
player_mc.x -= mainSpeed;
}
if(rightKeyDown){
player_mc.x += mainSpeed;
}
if(upKeyDown){
player_mc.y -= mainSpeed;
}
if(downKeyDown){
player_mc.y += mainSpeed;
}
}

stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeysDown);
function checkKeysDown(event:KeyboardEvent):void{
if(event.keyCode == 37 || event.keyCode == 65){
leftKeyDown = true;
}
if(event.keyCode == 38 || event.keyCode == 87){
upKeyDown = true;
}
if(event.keyCode == 39 || event.keyCode == 68){
rightKeyDown = true;
}
if(event.keyCode == 40 || event.keyCode == 83){
downKeyDown = true;
}
}

stage.addEventListener(KeyboardEvent.KEY_UP, checkKeysUp);
function checkKeysUp(event:KeyboardEvent):void{
if(event.keyCode == 37 || event.keyCode == 65){
leftKeyDown = false;
}
if(event.keyCode == 38 || event.keyCode == 87){
upKeyDown = false;
}
if(event.keyCode == 39 || event.keyCode == 68){
rightKeyDown = false;
}
if(event.keyCode == 40 || event.keyCode == 83){
downKeyDown = false;
}
}

player_mc.addEventListener(Event.ENTER_FRAME, speedUp)
function speedUp(event):void
{
if(player_mc.hitTestObject(speedUp_mc))
{
mainSpeed = (mainSpeed + 5);
}

}


player_mc.addEventListener(Event.ENTER_FRAME, speedDown)
function speedDown(event):void
{
if(player_mc.hitTestObject(speedDown_mc))
{
mainSpeed = (mainSpeed - 5);
}

}
Thanks in advance!

Remove Data Object :s
if

Code:
var user = SharedObject.getLocal([_global.rqstid]);
//update!
user.data.y = user.data.y+3;
user.data.x = user.data.x+6;
user.flush();
comment est-ce que vous faisez le enlevez?

Remove Object From Array
Hi, I am trying to create a flash application to randomly output 10 names that I have in an array.
I will be doing this through a button. Once I click the button it reveals one name in a dynamic text field, when I click again, it repeats another name. I have all this working including it being random, but I do not know how to not repeat a name. For example, if After the first click the name Joe comes out, the name Joe should not come out again. If any one knows if there is a way to delete or remove that object please let me know. Thanks









Attach Code

var a_names:Array = new Array("Billy", "Chris", "Gregg", "Steve", "Scott", "Kevin", "Tim", "Joe", "Alex", "John");

Remove Object On Button Press
I have a simple text saying "Click to Play" that tells a user to click the play button below he/she needs to click it.

All I want to do is make that text disappear once the user has clicked the actualy play button. I have tried a million way, many I'm sure would have worked if I had known what I was doing. I'm very inexperienced at flash and even less so at the coding. Please Help It is now 450AM EST and I have been up since midnight trying to figure just this out. I know many of you have very easy ways to do it so any help is very much appreciated.

Remove Child Is Really Dispose The Object
is remove child in AS 3 really dispose a movie clip, cos' I still can trace the instance after...

By the way, I invite you to watch my first flash 3D experiments in AS 3: www.icesflash.com

Thanks.

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