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




Confusion...I'm In (dis)array....some Clarification Please?



i'm not very familiar with the use of arrays, however i have found myself in a spot where i need to use one (i think). I'm trying to condense my code, which is easily done using "for" loops, but i need to add labels to buttons through AS, and i think that an array is the best way of doing that (if i'm wrong...please correct me and save me from another headache!)

Let me see if i can explain...I have a series of mc's (buttons) and each button contains an empty dynamic textfield. i need to label each button through AS. I used for loops to assign events to the buttons, but how do i label them in a similar fashion.

For example, let's say my button code is the following:
Code:
for (i=1; i<6; i++) {
theButton = _root.menu["but"+i];
theButton.thisNum = i;
//
theButton.onRollOver = function() {
_root.menu["but"+this.thisNum].gotoAndPlay("over");
};
//
theButton.onRollOut = function() {
_root.menu["but"+this.thisNum].gotoAndPlay("out");
};
//
theButton.onRelease = function() {
if (_root.section != _root.menu["blah"+this.thisNum]+".swf") {
_root.section = ["blah"+this.thisNum]+".swf";
_root.transition.gotoAndPlay("end_of_example");
}
};
}
the textfield contained within the buttons has the instance name btnLabel . if i was to use an array to label the buttons, from the tutorials i've worked my way through, i would define the array like this:

Code:
btnLabels = ["blah1","blahblah","blah1blah","test","testblah"];
//or
Labels = new Array();
Labels[0] = "blah1";
Labels[1] = "blahblah";
Labels[2] = "blah1blah";
Labels[3] = "test";
Labels[4] = "testblah";
//
//
// I TRIED THINGS USING EVERY COMBINATION OF THESE ELEMENTS (not nec. all together, but bits and pieces of this mess)
theButton = _root.menu["btnLabel"+this.thisNum].text = ["Labels"+i];
// BUT THAT SURE AS HELL DIDN"T WORK
should the name of the array be the same as the instance name of the text box??? how do i assign the value of the first element in the array, to the the textbox in the 1st button, the 2nd element, to the 2nd button, etc

if i were to write it out the long way, it would look like this":
Code:
_root.menu.but1.btnLabel.text = "blah1";
_root.menu.but2.btnLabel.text = "blahblah";
_root.menu.but3.btnLabel.text = "blah1blah";
_root.menu.but4.btnLabel.text = "test";
_root.menu.but5.btnLabel.text = "testblah";



FlashKit > Flash Help > Flash ActionScript
Posted on: 04-10-2005, 02:50 AM


View Complete Forum Thread with Replies

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

Array.sort( SortFunction ) Clarification Please
The sort function you can pass to Array.sort is a bubble sort right? That is the basic algorithm it uses? I tried looking on the docs and also at some ECMAScript-262 specifications but couldn't find any definite answer as to the type of sorting algorithm it uses. I am assuming yes, but wanted to be sure.

thanks, J

Array Confusion
I have no idea what happens in AS when you try to give an array a value. This is a test program for a larger project. There is a quirk obviously which i don't get.

I just want to assign an array value inside an event but it fails . I am using arrays of values to make it look messy.

I can't assign an array inside an an event ?


var tt:Array=new Array();
var mLoad:MovieClipLoader = new MovieClipLoader();


//trace(tt.toString());
this.createEmptyMovieClip("my0",this.getNextHighes tDepth());
my0.createEmptyMovieClip("myy0",my0.getNextHighest Depth());
mLoad.loadClip("98img1.jpg",my0.myy0);

this.createEmptyMovieClip("my1",this.getNextHighes tDepth());
my1.createEmptyMovieClip("myy1",my1.getNextHighest Depth());
mLoad.loadClip("98img1.jpg",my1.myy1);
my1._x=100;



var j:Number;

for (j=0; j<2; j++)
{
// tt[j]=j;/////// This works when i assign it outside the event

this["my"+j].onPress = function(){

tt[j]=j;///////////////////////////// THIS FAILS to assign values in array as I get undefined why?

//this._parent.tt[j]=j;

}
}
trace(tt.toString());

Array Confusion
I have no idea what happens in AS when you try to give an array a value. This is a test program for a larger project. There is a quirk obviously which i don't get.

I just want to assign an array value inside an event but it fails . I am using arrays of values to make it look messy.

I can't assign an array inside an an event ?


var tt:Array=new Array();
var mLoad:MovieClipLoader = new MovieClipLoader();


//trace(tt.toString());
this.createEmptyMovieClip("my0",this.getNextHighestDepth());
my0.createEmptyMovieClip("myy0",my0.getNextHighestDepth());
mLoad.loadClip("98img1.jpg",my0.myy0);

this.createEmptyMovieClip("my1",this.getNextHighestDepth());
my1.createEmptyMovieClip("myy1",my1.getNextHighestDepth());
mLoad.loadClip("98img1.jpg",my1.myy1);
my1._x=100;



var j:Number;

for (j=0; j<2; j++)
{
// tt[j]=j;/////// This works when i assign it outside the event

this["my"+j].onPress = function(){

tt[j]=j;///////////////////////////// THIS FAILS to assign values in array as I get undefined why?
//this._parent.tt[j]=j;

}
}
trace(tt.toString());





























Edited: 01/16/2007 at 07:51:19 PM by jagguy99

Array Confusion...
managed to get it working

Array.length Confusion
Hi,

This problem is part of a problem described in this thread:http://www.flashkit.com/board/showthread.php?t=663722 But it's worth looking at by itself...
I've created a test multidimensional array like this:

Code:
a = "a,b,c,d,e,f,g,h,i,j";
a_array = a.split(",");
b_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
combi_array = new Array();
big_array = new Array();
for (i=0; i<a_array.length; i++){
temp_array = new Array();
temp_array.push(a_array[i]);
temp_array.push(b_array[i]);
// create an array that combines a and b //
combi_array.push(temp_array);
// create one array that holds 10 combi_array's //
big_array.push(combi_array);
}

Then I remove one item from one array and one item from another array:

Code:
trace ("array2 "+big_array[2]);
trace ("array2 len 1="+big_array[2].length);
big_array[2].splice(0,1);
trace("splice 1 item");
trace ("array2 len 2="+big_array[2].length);
trace ("array2 "+big_array[2]);
big_array[1].splice(0,1);
trace("splice 1 item");
trace ("array1 len 1="+big_array[1].length);
trace ("array1 "+big_array[1]);
trace ("array2 len 3="+big_array[2].length);

This is the output:
array2 a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8,i,9,j,0
array2 len 1=10
splice 1 item
array2 len 2=9
array2 b,2,c,3,d,4,e,5,f,6,g,7,h,8,i,9,j,0
splice 1 item
array1 len1=8
array1 c,3,d,4,e,5,f,6,g,7,h,8,i,9,j,0
array2 len 3=8

You can see that splicing an item from big_array[2] also affects the length of big_array[1] and vice versa.
Hope so flash guru can tell me what's happening here.
Thanks in advance for your help, Danielle.

BeginGradientFill Color Array Confusion
I am a little lost!

I have created a class which draw a gradient and I am trying to dynamically set the colors of the gradient but when I swap the rgb values for variable names the gradient shows as black to white.

Here's my code:


Code:
public function drawGrad(colour2:Number, colour1:Number) {
_root.container_mc.createEmptyMovieClip("gradient_mc", 300);
with (_root.container_mc.gradient_mc) {
fillType = "linear";
var colors:Array = [colour2, colour1];
trace(colors);
alphas = [0, 100];
ratios = [127, 255];
matrix = {matrixType:"box", x:369, y:288, w:572, h:80, r:-45/180*Math.PI};
lineStyle(1, 0x000000, 0);
beginGradientFill(fillType, colors, alphas, ratios, matrix);
moveTo(369, 288);
lineTo(941, 288);
lineTo(941, 368);
lineTo(369, 368);
lineTo(369, 288);
endFill();
}
}

///call to action

var setGrad = new gradientFill();
setGrad.drawGrad(colour2, colour1);
Thanks in advance..

Clarification...
Just figured I'd post a message to clarify my last request... I have a movie clip, two attached panoramic images that are "background" objects, so to speak... I have them tweened to scroll from one end of the canvas to the other, then on the loop, the cycle restarts. I'm looking for a way to control the direction that they scroll via keyboard input, ie, a user presses the left key, the movies stops it's present motion and reverses, press the right key, well, you know... I have a pretty decent grasp on Flash scripting and I see my answer having something to do with the goto and play previous frame, though I cannot seem to iron out a plan of attack on this one. Please feel free to email if you can help, graphon@elite-expressions.com.

Thanks again,
Dan

A Little Clarification, Thanks...
Hi,

If I am to have .jpg images load dynamically into an empty movie clip.

Is it so that within the coding of my next & back buttons, I need to indicate each & every .jpg title so it will be aware...as well as indicating the instance name of the empty movie clip?

For example, within the code on those buttons, include: "image01.jpg", "image02.jpg", "empty_mc" so on and so forth?!

Thanks!

Christine

Coding Clarification
Hello all,

I was wondering what the following meant:


Code:
/:selection = ../:_name;


Isn't this just telling the movieclip 'selection' to be equal to the previous mc called name? I guess what is confusing me is the slashes. I'm used to writting code with _root and _parent and seem to get confused when trying to learn from code like this.

Thanks for your time,

Ok I Got Clarification Now I Need An Explaination
ok I my last post I asked what a Preloader was thanks for the answer from that guy I know.

Now I need to know how to make a PRELOADER

1) what is that code behind it
2) how do I build it

thanks alot for all the help thus far need a bit more thanks

[edit]footer removed - please read the guidelines in the FAQ. thanks![/edit]

Clarification On Timelines
Hey guys, I'm new and just learning ActionScript. I've been reading tutorials and sources from a bunch of different places and so I just wanted some clarification on some code.

There is an instance (named ball) of a movieClip object on the stage:

Block 1:

Code:
ball._x = 100;
ball._y = 100;

ball.onEnterFrame = function()
{
this._x += 5;
}


Block 2:

Code:
ball._x = 100;
ball._y = 100;

function onEnterFrame():Void
{
ball._x += 5;
}


Both of these bits of code seem to do the same thing on the screen, so here's my question. Are they both affecting the same timeline? From Block 2 it's clear to me, that it's affecting the root timeline, but when looking at Block 1 I can interpret it two ways:The ball object is handling the enterFrame event of the root timeline.Since ball is itself a movieClip, it is affecting it's own timeline (because movieClip objects have their own timeline, right?)So which is the correct way of interpreting the code?

And if ball is handling the enterFrame event of the root timeline, how can I get ball to handle the enterFrame even of it's own timeline?

Thanks guys.

[CS3, AS2] Quick Clarification
Should i be using this code EACH AND EVERY TIME i perform some tween action??

Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;


Example, i am using the above two lines of code in frame#2, before i make some tween., and then i am going to make some tween in frames 6 and 9, and then later inside some of my MC's... so each and every time do i have to import tween class before initiating a tween?? Is it possible i just import the tween ONCE for all??

[F8] [AS2] Need Clarification On Using Objects
I'm a little new to Objects, though I've probably made use of them unbeknownst to me... I need a little clarification about some scripts I've been using and how to improve.

When I create a movieclip this way, is it just storing a string reference to the clip in "clippy" or is "clippy" essentially an object (though not declared)? :

var clippy = this.SCROLL_CARDS.viewer_mc.content_mc.createEmpty MovieClip("SLOT" + i, jj++);

I want to change the way I track this clip, via an object I already have. I fetch the object out of my array like this:

obj = my_cards[i];

How would I assign the movieclip (either at creation time, or after) into the object for easy reference later?

Font Clarification
I must admit I've been away from flash for a few versions. I've had to catch up pretty quickly this month. I have a quick few questions regarding fonts.

1. If I embed a font into one movie and load it into the main movie, will it be available to use in any text field I wish to apply it to?

2. To reference a font loaded in using the above method, should I use its linkage name or the full font name or do I have to reference it from within the movieclip it is embedded in?

I hope this makes sense.

Chris

Clarification On SWF Files
Hi, having an FLA file which holds init script which react differently between one user and another (for example: an asp which holds an SWF file which decides what content to bring from DB according to the user - Personalization) refering to the SWF file:
does the SWF file holds in it script? when i imported swf file into a new FLA file i didn't see any script BUT since the file is personalized i know there is something in there... is there a way to get to it?

Thanks in advance,
Maya.

SetInterval Clarification/help
Hi guys, can you take a peek at this and tell me why the setinterval doesnt seem to be working. Im trying to call a function every few secs and also pass an object into that function, is this possible do you know.

what i need to do is within the enterframe of a movieclip call a function at random times (i know its not random at the moment but i can't seem to even get the setinterval to work)

Here's what i'm thinking:- cheers guys

var bubbling:Boolean=true;

function showBubbles(numberBubbles,tempObject) {
//Do something here
bubbling=false;
clearInterval(myInterval);
}

diver_mc.onEnterframe = function() {

if (!bubbling) {
myInterval=setInterval (showBubbles(10,Diver_mc),1000);

}
}

Clarification On Doing A Killing...
deleting, killing objects and functions.

There seem to be a few different ways to achieve to completely get rid of unwanted objects and functions(which are in turn objects as well, no?)

Just to refresh:

objects:

Code:
object = undefined // does the job
object = null // does the job
exception: if the object is referenced anywhere else in the application, the object is still in memory, unless the object's reference is killed as above.
also: if you attempt to try cleaning up and object , which has objects itself, (e.g. object.subObject = new Object()), then those subObjects are still alive.

To properly clean up the object with subObjects, the subObjects have to be killed off seperately.

Am I right so far?

I am just writing this, because, yet again despite quiet some experience by now I had some setIntervals running in some objects, and they somehow kept appearing somewhere, because again somewhere, I didn't clean up the intervals and accompanying objects.

Can anyone comment on the above being right/wrong, best practice, etc.
Please be detailed, tell me in machine code if you must.
Mainly developing interactives for exhibition spaces which have to run for hours, memory leakage, is something not everyone has to take that serious, yet I do.

Cheers,

uncleunvoid

GetURL Clarification
Im a newbie in flash. Im trying to make my buttons open a different local URL when they are clicked. I want them to open in the same window. I have tried using the code: getURL("boutUs.html",_self) but it doesnt open in the same window instead it opens the link in same window but in a tab. I want it to overwrite the current window that is open. Can someone please help me. Sorry if thsi is astupid question

Clarification Regarding Broadcast
We are doing a project in Flash of developing an elearning application.In this project we need a solution for how to broadcast stored/prerecorded video through flash media server.We ve done live video broadcast using web camera but we ae not able to for the stored video. Please help us if u can.

Need Basic OOP Clarification
I've created a button graphic in the Flash IDE called buttonBar. In my document class (called Main.as) I've instantiated several versions of the button. I also added an event listener to test some basic functionality on the first button.
Everything works fine, but I suspect I'm adding too much to my document class & constructor function. I feel like I should create a Button class that will dictate how the button behaves when rolled over. The question is, would the button class handle the event listening for itself(within the Button.as file), or should all event listeners be run from the document class.







Attach Code

package com.joeMusella {

import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;



public class Main extends Sprite {

private var _btnBarHome:buttonBar;
private var _btnBarBio:buttonBar;
private var _btnBarNews:buttonBar;
private var _btnBarGear:buttonBar;
private var _btnBarMusic:buttonBar;
private var _btnBarContact:buttonBar;

private var _buttonWidth:Number = 117;
private var _buttonHeight:Number = 31


public function Main () {

//-----------------------------------Instantiate buttons---------------------------------------------------------



_btnBarHome = new buttonBar();
addChild(_btnBarHome);
_btnBarHome.x = 155;
_btnBarHome.y = 345.4;
_btnBarHome.width = _buttonWidth;
_btnBarHome.height = _buttonHeight;

_btnBarBio = new buttonBar();
addChild(_btnBarBio);
_btnBarBio.x = 292;
_btnBarBio.y = 345.4;
_btnBarBio.width = _buttonWidth;
_btnBarBio.height = _buttonHeight;

_btnBarNews = new buttonBar();
addChild(_btnBarNews);
_btnBarNews.x = 426.6;
_btnBarNews.y = 345.4;
_btnBarNews.width = _buttonWidth;
_btnBarNews.height = _buttonHeight;

_btnBarGear = new buttonBar();
addChild(_btnBarGear);
_btnBarGear.x = 562.1;
_btnBarGear.y = 345.4;
_btnBarGear.width = _buttonWidth;
_btnBarGear.height = _buttonHeight;

_btnBarMusic = new buttonBar();
addChild(_btnBarMusic);
_btnBarMusic.x = 700;
_btnBarMusic.y = 345.4;
_btnBarMusic.width = _buttonWidth;
_btnBarMusic.height = _buttonHeight;

_btnBarContact = new buttonBar();
addChild(_btnBarContact);
_btnBarContact.x = 832.6;
_btnBarContact.y = 345.4;
_btnBarContact.width = _buttonWidth;
_btnBarContact.height = _buttonHeight;


//---------------------------------Button Functionality-----------------------------------

_btnBarHome.addEventListener(MouseEvent.ROLL_OVER, onBtnRollOver);
_btnBarHome.addEventListener(MouseEvent.ROLL_OUT, onBtnRollOut);
}


private function onBtnRollOver(event:MouseEvent):void {
_btnBarHome.width = _buttonWidth * 1.1;
_btnBarHome.height = _buttonHeight * 1.1;

}

private function onBtnRollOut(event:MouseEvent):void {
_btnBarHome.width = _buttonWidth;
_btnBarHome.height = _buttonHeight;
}

}

}

Basic Clarification
Think this is probably dead simple but I cant get my head round it.
In the first frame of a movie I call:

new com.jj.core.Application();

I want my Application class to create some empty movie clips to use as containers and then add them to the stage. I declare a static var (containerVar) to store the container reference in and call a method of my Application class that should create the clips themselves:

private function createClips():void
{
containerVar = new MovieClip();
addChild(containerVar);
}

This comes back saying that addChild is an undefined method and the only way I can get it to work is by passing a reference to Application through the constructor and then calling addChild on this reference:

new com.jj.core.Application(this);

private function createClips():void
{
containerVar = new MovieClip();
passedRef.addChild(containerVar);
}

Is there any way of getting a reference to the main timeline (like AS2 _root) or is the way I described how it has to be done these days?

Also, if anyone feels like explaining a bit about AS3s 'root' and 'stage' properties or knows of some good material on them I would love to get a better idea of how they work.

Cheers all

'compc' Clarification, Please
I am a little confused about syntax for the command-line component compiler, compc. Let's say I would like to build a .swc library from the following packages:

components/directory1/package1.as
components/directory1/package2.as
components/directory2/package3.as
components/package4.as

What necessary compiler options should I include? Could someone give me an example compc command based on the above package tree?

Thanks

LoadMovie Clarification?
I'm just getting into the "loadMovie" thing and after searching books and this forum on the "how-to's" I must misunderstand something...

I'm just trying to load into a target MC a one-framed purely AS driven .swf. The target MC is the exact size of the .swf. When the .swf loads there's no AS interaction as there is in the original .swf... it just sits there. Any way to loadMovie an .swf and keep all it's little AS effects?

Follow my question? oh yeah and is there anyway to keep a loadedMovie from looping?

Quick Clarification On [AS]
Hey.

Just need a small clarfication on this [as].
Decription: On the first frame consists of LoadNumVar

Code:
loadVariablesNum("C:/Documents and Settings/Owner/Desktop/text1.txt", 0);
If Statement:

Code:
if (text ne "") {
gotoAndStop("end");
}
I know whats happening but what is (text ne "") ?

Class Clarification
Ok, I just had a few things I need clarified.

1. I can have one public class per package?
2. package "name" { ... "name" refers to directory? Because I tried giving my package a name and got an error.
3. When extending a class, say we have class Shape {
and I want to extend class Square {
I would then create a... var myShape:Shape = new Square(12);
or var myShape:Square = new Square(12);

Anyhow, those are some things I'm not understanding right now. Thanks if you get help me, I've been going through the help files and I'd like to get past some of this stuff so I can get on to the better stuff.

Need A Little Clarification On The Embed Fix
Hello all,
I found the page on "fixing the flash embed issue" and am going to implement it in my already built site. My site has many pages all with a common flash navigation menu at the top and some with an additional Flash animation below. All pages also have a lot of HTML, I mean it's not an all flash web site.

I built the site in Dreamweaver and all the flash movies are already put in them with, what looks like, the embed code that I assume Dreamweaver generates.

Do I need to strip code out before putting the new code (generated by the flash object generator) into the page?

All my flash movies are in 1 folder, but the HTML pages are in multiple folders. The fix page says to put the flashobject.js in "the same location as your HTML page that will display your Flash animation." Does that mean one instance of the flashobject.js file for each page or one instance of it in each folder of pages, or something else??

Being fairly new to this, I'm really afraid of this turning into a nightmare.

Any help, direction, or advice will be VERY much appreciated.

Best regards, Scott

CacheAsBitmap Clarification
Hey all,

So just a quick question about the cache as bitmap property.


If i have a movieclip that contains another movieclip which is an animation in it.

So Mov1 -> Mov2 -> 8 frames of .png files.

If i set Mov1.cacheAsBitmap = true, and then play the animation in Mov2. Is the whole thing still cached as a bitmap?

I'm just trying to figure out when i'd need to reapply a cacheAsBitmap property. Does it ever revert back to false by performing some sort of action on the movieClip?

Thanks!

[AS 2.0] Var Definition Clarification
hey guys:

what, functionally, is the difference between:

Code:
var someVar:Number;
and
Code:
var someVar:Number = new Number();
i'll sometimes use them interchangably in a script without any seeming ill effect, so i just wondered what the difference was from a functional point of view. and yes, it's late and i'm waxing philosophical... must be the flat Coke Zero...

one thing i do know, is that the second version allows you to set some properties right off the bat, rather than use a second or third line to do it:

Code:
var someOtherVar:String = new String('bananas');
... but other than that... ?

danke mein volks!

WR!

LoadMovie Clarification?
I'm just getting into the "loadMovie" thing and after searching books and this forum on the "how-to's" I must misunderstand something...

I'm just trying to load into a target MC a one-framed purely AS driven .swf. The target MC is the exact size of the .swf. When the .swf loads there's no AS interaction as there is in the original .swf... it just sits there. Any way to loadMovie an .swf and keep all it's little AS effects?

Follow my question? oh yeah and is there anyway to keep a loadedMovie from looping?

Quick Clarification On [AS]
Hey.

Just need a small clarfication on this [as].
Decription: On the first frame consists of LoadNumVar

Code:
loadVariablesNum("C:/Documents and Settings/Owner/Desktop/text1.txt", 0);
If Statement:

Code:
if (text ne "") {
gotoAndStop("end");
}
I know whats happening but what is (text ne "") ?

Functions Clarification
Last edited by r_bartoli : 2004-12-13 at 14:19.
























Hi all. I've some code like this and it works.


ActionScript Code:
// myData
var myData:LoadVars = new LoadVars();
myData.load("view.asp");
myData.onLoad = function(bSuccess:Boolean) {
    if (bSuccess) {
        var NumRowX:Number = 5;
        var NumRowY:Number = 20;
        McRowProperties = new Object();
        // Db records
        for (var i = 0; i < this.cant; i++) {
            McRowProperties._x = NumRowX;
            McRowProperties._y = NumRowY * i;
            McRowProperties.TxLink_txt = myData["Link" + i];
            attachMovie("McRow", "McRow" + i, i, McRowProperties);
        }
    }
};


I need to add some functionality: I want to control the time of the attachMovie function. But it doesn't work. I'm 99% sure that it depends on the i var.


ActionScript Code:
// populate function
function populate() {
    McRowProperties._x = NumRowX;
    McRowProperties._y = NumRowY * i;
    McRowProperties.TxLink_txt = myData["Link" + i];
    attachMovie("McRow", "McRow" + i, i, McRowProperties);
}
// myData
var myData:LoadVars = new LoadVars();
myData.load("view.asp");
myData.onLoad = function(bSuccess:Boolean) {
    if (bSuccess) {
        var NumRowX:Number = 5;
        var NumRowY:Number = 20;
        McRowProperties = new Object();
        var intervalID:Number;
        // Db records
        for (var i = 0; i < this.cant; i++) {
            intervalID = setInterval(populate, 500);
        }
    }
};

Clarification On Timelines
I just wanted some clarification on the following bits of code. There is an instance (named ball) of a movieClip object on the stage:

Block 1:
Code:

ball._x = 100;
ball._y = 100;

ball.onEnterFrame = function()
{
    this._x += 5;
}

Block 2:
Code:

ball._x = 100;
ball._y = 100;

function onEnterFrame():Void
{
    ball._x += 5;
}

Both of these bits of code do the same thing on the screen, so here's my question. Are they both affecting the same timeline? From Block 2 it's clear to me, that it's affecting the root timeline, but when looking at Block 1 I can interpret it two ways:The ball object is handling the enterFrame event of the root timeline.Since ball is itself a movieClip, it is affecting it's own timeline (because movieClip objects have their own timeline, right?)So which is the correct way of interpreting the code?

And if ball is handling the enterFrame event of the root timeline, how can I get ball to handle the enterFrame even of it's own timeline?

Thanks guys. (Sorry for all these random questions. I'm reading from various sources.)

LoadVariables: Usage Clarification
I've kinda got the overall usage, but can't quite get it to work right.

In _level4 I have a button action that does

loadVariablesNum ("content.php", 0, "POST");

This send all variables in _level0 to content.php, correct?

Then, in _level7 I have a text field with the variable "body", which is one of the variables that content.php returns, in a movie clip named "container".

I've tried a couple different things at this point...

frame 1 does loadVariables ("content.php", _root.container);

Then tried moving the text field to the _root level and frame 1 to:
loadVariables ("content.php", _root);

Then changed the text field name to _level0.body and removed loadVariables, thinking that the initial button action also simultaneously loaded the variables from the php into level 0.

Basically, I'm very confused on what does what and tutorials are confusing me even more! Please, for my sanity help me find my way!
;p
Thanks!

MC Link Code Clarification....
Have an MC, it animates when one rollsover it with the mouse.

I need it to now link to another webpage within this site if someone clicks on the same animated MC.

On the last frame of the animated MC, on the invisible button,
I have:
on (press){
_root.gotoAndPlay("portfolio");
}

That animates but it doesn't transition to the corresponding webpage within the site?!
Why? (portfolio is the frame label name of the page it needs to transition to when the MC is clicked upon)

Many thanks!

Volume Slider Clarification
...Sorry to bug you again, it's just that my concern is fairly urgent: What I purpose is creating a volume slider that doesn't just work with background music, but also with sounds that are produced when (for example) clicking on buttons (etc.)
Thanks for taking the time!

Original message:

Quote:




Hi, Just created a nifty Flash-presentation, featuring all kinds of classy effects and sounds. It holds a number of movie-clips and buttons, all/most of them feature attached sounds. NOW that I'm finally (almost) done, I am thinking of adding a volume-slider, which appears to be a major problem: all of the tutorials I've come across so far deal with volume sliders which you have to additionally attach the sound to. Is it at all possible to create a slider that simply responds to the sounds that already exist in your .swf-file? THX!

Clarification On SetInterval To Pause
I recently discovered via this forum how to use setInterval to pause the playhead, saving me thousands of empty cells in my timeline (thankyou).

I've used this successfully for a while, but now I have a file that seems to be ignoring my stop commands in frames. I know you are supposed to clearInterval.

On the first frame of the movie I have this code:

function pause(){
play();
clearInterval(timer);
}

Does this code mean that after the designated pause time, the movie plays and the setInterval is cleared?

Then where I want the movie to pause I have this code:

stop();
timer = setInterval(pause, 1000);

As I said this works most of the time, but recently I have started using some action script on the end of sound objects (narration) to start playing after the playhead is stopped with a stop() command.

So here is basically what I'm doing. I start the narration as a soundObject, during the narration I have several pauses using the setInterval method, then towards the end of the narration I put a stop() in a frame and use this code:

voice19.start(0,1);
voice19.onSoundComplete = function() {
play();
}

to start the playhead again. Only the stop() command is just being ignored.

I've spent days trying to figure this out and would appreciate any help.

thanks,
Dennis

Clarification Of SO Security Policy, Please?
The Flash 8 manual states: "By default, Flash Player 7 and later versions prevent a SWF file served from one domain from reading data, objects, or variables from SWF files that are served from different domains."

By default.

After reading and reading on this topic, I am still utterly unclear as to whether it is possible to share "shared objects" across domains.

Has anyone achieved this?

-Keegan Miller

Function Naming Clarification Plz
Hi could somebody give me a link on how to properly write a function and why......I usually write a function like


PHP Code:



function nameOfFunc(){};




but i see some people writing a functions name like.


PHP Code:



nameOfFunc = function(){}




what is the diffrence between the way I write the function and the other way?

I want to beable to call my functions from anywhere within my scripts so I'm wondering.

A tutorial or explanation would be very helpful plz.

Clarification Question For Particles
quick (i hope) question about particles:

say i have a movie clip called "marble", i want to use a particle system and say i have nothing on my stage. i can pull instances of the move clip "marble" on to my stage by creating a variable holder which will serve as the instance of my movie clip, followed by an addChild method.

ie:

Quote:




var theMarble:marble = new marble;
addChild(theMarble);






now if i understand this correct "theMarble" is now the instance name of the movie clip "marble", which i have pulled on to the stage.

so if i wanted to add properties and functions to the marble, now pulled on to my stage when previewed as a swf, i can.
ie:

Quote:




theMarble.x = stage.stageWidth/2;
theMarble.y = stage.stageWidth/2;
//places marble in center of stage






but say i create an array and add multiple marbles- say 20- to my stage? what are the instance names of first "theMarble" and the subsequent ones after that? are they all "theMarble" or does flash label them something like "theMarble1", "theMarble2", "theMarble3", etc?

thanks for satisfying my curiosity!
`shields

NetStream.time Clarification
AS3 Doc

Basically I want to trigger certain effects during specific times of a video stream. The as3 documentation states:

Quote:




When the server begins sending data again, the value continues incrementing from where it left off plus the time that elapsed while no data was sent.




From what I understand this is less than ideal because if the video starts buffering then plays again wont the timing of my effects be thrown off?

Example
If it starts buffering at 2.05 then resumes playing a second later I want netstream.time to trace 2.05 instead of 3.05

Clarification Of Splice Method
I was looking through some example code of a particle system, specifically the "rubbish/trash removal" method that was being used;


Code:
for(var i:uint = 0; i < particles.length; i++)
{
particles[i].update();
if(particles[i].alpha <= .01)
{
trash = particles[i];
container.removeChild(particles.splice(i,1)[0]);
trash = null;
}
}
I understand the principle but the line that is baffling me is the "splice(i,1)[0]" bit.

What is the significance of the "[0]"?

Thanks,

Neil

Clarification On Using Timers For Animation
Hello,

I am using timers to animate my sprites. Each sprite has has a different timer. Every time a timer fires for a sprite, I update sprite with a new bitmap image. Considering all of this, how does Flash take care of buffer updates? That is, will the update to the screen buffer be done all at one time even though the timers are firing independently? Or would the screen buffer be updated at different times, for example when Flash is drawing to the screen? I've read different accounts on this.

Thanks.

Embed Fonts Clarification
Just wanted a quick clarification regarding embedding fonts. I am working on a project that consists of about 180 movies. Each movie loads in a .txt file with variables that dynamically fill text fields w/in each .fla. At this point I have been using "bulletText6_txt.embedFonts = true;" or some variation there of. However this requires embedding the font w/in the library of every single page, increasing the file size about 24kb/page.

Correct me if I am wrong but wouldn't my approach be easier just to embed the font in a dummy text field on the _root. timeline that all of the other files will be loaded into? This will save me about 24kb per page x 180 pages as the font will be have to be embedded only once and will be stored in and accessible from the users memory correct?

thanks

broD

My You Tube Site -Clarification
Hi all,

Am developing an "youtube.com" kind of website where we can upload anyformat of files and view it online in a flash player.
The functional flow for this is as follows
1. Upload video file
2. FLV Conversion of the same
3. Placing it in my Flash Media Server
4. Streaming video to flash player.

For this i have already come up with a prototype for doing this

Though am ready to buy Flash Media Server(FMS), I have doubts in the following things

1.Is there any FMS API to do FLV conversion from my webserver to Flash Media Server? that is a upload component which converts and stores an FLV file in the FMS during upload? The documentation is not speaking clear about flv conversion.

2. Server streams folder holds all the instance folders where we store our FLV files. for example if am creating a instance folder for each and every users. How much folder instances can be created as a whole for the same application? Sure it will be dependent on the File System right? ( million folders cannot be created inside a windows folder. Right? )

3. Can we able to have any much amount of FLV files in our stream folder? If there any specific size upto which FMS can tolerate.Please specify.

4. Can u please say how youtube is organising those flv converted files in media server? so that my retrieval time will be reduced

5. If am loading a new FLV file to my FMS which already has no space in it , is there any way to redirect those streams to some other location for storing?

6. If am having my FLV converted file, will the media server take care of placing it in its appropriate application folder?

Please help me out in this regard by providing tips, suggesstion and reference urls

Thanks in advance,
Siva
mail: sivashankar.r@allfon.com

Flash Logging Clarification
Hi All
I am doing the logging feature for my project. I am doing that by writing onto a text file. The problem is I am able to see the logfile.txt generated only when I debug a movie. When I try to run the flash movie,I wont be able to able to generate the logfile.txt..!

Can anyone help me in this..??

Thanks in Advance
Nirmal.

MovieClip.loadSound Clarification
Hi all.

When I do a loadSound on a Sound object created before that has already completely played another mp3 file (IsStreaming = true), the sound.position increment with it's loading?

Why?

Thx to all and sorry for my english.

Script Problem Clarification (swf / Html)
My flash movie has some simple actionscripting in it attached to the buttons.
When I roll over or out from a button, I have some simple animations (mc's) that
appear to be rollovers to the user. I named all of my instances, nested the
buttons into clips with the other movie clips they're affecting, and followed strict
dot syntax.

Here's the kicker. When I test the movie, the SWF works fine & all of the
actionscript works great. However, when I publish the movie to an HTML file and
try to make it work in a browser, the buttons are still recognized by the mouse,
but none of the scripting works, and there appers to be no rollovers.

Any clue as to why the SWF works fine but the HTML file sucks booty???

I even tried reinstalling the 5 player (thanks sem)...

Need Clarification Of Movie Clip Hierarchy
I'm hoping someone can explain this to me well, as it's been an area of confusion for me for some time...

I don't understand the difference between putting actionscript code on a movie clip (a clip attached to the main timeline) and putting it on the timeline inside the movie clip. If I put the script on the movie clip and reference the parent, it's a reference to the main timeline. But if I put the script on the timeline for the movie clip and reference the parent, what does it reference? The main timeline also? I've figured out that code written in MX format seems to go best on the movie clips themselves, while code in Flash 5 format seems to work best on the actual timeline for the movie clip itself. What is the difference between the two locations, and what rules should one follow in knowing where to attach the code?

Thanks,
aaroneousmonk

Form Data - Repost For Clarification
I am reposting this because I don't think I was very clear. I have searched forums and tutorials for two days and don't see anything like I am trying to do.

I have to send information to an asp script, that was written by a third party and resides on a completely different server than the flash movie will reside on. Basically, the flash movie has one input box that will accept a users telephone number. When they hit the submit button, several pieces of information will go to the asp script, which will send a text message to the users cell phone.

If embedded in an html page, the form looks like this....
<FORM name="MessageForm" method="post" action="http://www.example.com/adserver/campaignstudio/SendPromo.asp?PID=SCALL01">
<INPUT type="Hidden" name="From" value="joe@email.com">
<INPUT type="Hidden" name="CampaignID" value="SCWIRELESS">
<INPUT type="Hidden" name="ErrorURL" value="http://www.joeshmo.error.htm">
Cell: <INPUT type="text" size=10 name="WN">
<INPUT type="submit" name="submit" value="Send!">
</FORM>

I am a complete Actionscript dummy, so I need to know where to put the actionscript also. The input box and submit button will reside on the root level of the movie

Any help would be greatly, greatly appreciated.

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