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




Tween Class Trouble (based On The Tutorial)



Hey hey hey.I was gonna have a fiddle with this tutorial http://www.kirupa.com/developer/actionscript/tween.htmso I downloaded, unzipped, saved and published it. I didn't have a chance to fiddle with anything and it's already broken! I get this:**Error** Scene=Scene 1, layer=actions, frame=1:Line 5: There is no property with the name 'onMotionFinished'. xScaleT.onMotionFinished = function() {**Error** Scene=Scene 1, layer=actions, frame=1:Line 8: There is no property with the name 'onMotionFinished'. xPosT.onMotionFinished = function() {Total ActionScript Errors: 2 Reported Errors: 2Any ideas why guys? Cheers in advance.<"))))><Edit: MX04 by the way.



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 03-05-2006, 01:50 PM


View Complete Forum Thread with Replies

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

Tween Class Trouble
An swf is worth a thousand words, so....

Please go to http://www.datapixel.eu/datapixel.htm

and watch yourself. When you click on "Apri Menu" (Open Menu in english) an animation made with the Tween class shows.

It should enlarge the green panel in order to show the buttons. And IT DOES! .... sometimes.

Instead sometimes the animation stops prematurely and the menu is not correctly viewed. Do you know what's happening?

Thanks.

Trouble With The Tween Class
I'm having trouble with this code, it's for tweening Thumbnails in a photo gallery application I'm building:


Code:
var tween:Tween = new Tween(Thumbnails[Thumbnails.cur_thumbnail], "_alpha", mx.transitions.easing.Strong.easeIn, 40, 100, 1, true);
Thumbnails.cur_thumbnail = new_thumbnail;
What happens is while the tween variable is tweening the value of Thumbnails.cur_thumbnail changes therefore cutting off the tween before it gets started or at least I'm assuming this is what's happening.

How do I get around this? Thanks.

Tween Class Trouble
Well, firstly, excuse my poor english... I guess its not so good, but I hope you can understand me.

Well, I have imported the tween class at my .fla file with:

-------
import mx.transitions.Tween;
import mx.transitions.easing.*;
-------

as everywhere says it must be done. Later, I use:

-------
ROLLOVER:
var tw:Tween=new Tween(plano_mc, "_xscale", mx.transitions.easing.Elastic.easeOut,40, 100, 40, false);

var tw2:Tween=new Tween(plano_mc, "_yscale", mx.transitions.easing.Elastic.easeOut,40, 100, 50, false);
-------

inside a function that i call on the rollover method for the movieClip I want to tween.

The trouble comes in the rollOut method, where I have this code:

-------
ROLLOUT:
var tw:Tween=new Tween(plano_mc, "_xscale", mx.transitions.easing.Elastic.easeOut, 100,40, 1, true);
var tw2:Tween=new Tween(plano_mc, "_yscale", mx.transitions.easing.Elastic.easeOut, 100,40, 1, true);
-------

After the user rolls out, and even after the rollOut tween is well done, it resizes to the 100%, even if I'm out of the hitArea for the rollOver. All this instead of staying at the 40% of _xscale and _yscale, that is what I wanted the class to do (you can see it in the parameters of the tween).

It only happens in the rollOut method, because the rollOver doesn't get resized after is called as well as the rollOut... It should be logical if it should happen at both methods, but it just happens at RollOut, and even, each time I rollOut, is just one (or both sometimes) property which gets resized (sometimes the _yscale, other times the _xscale....). Is there any explanation for this???

I want to erase this error, that I can't find why happens. My only explanation is that Robert Penner did a bad class, but I don't really trust it because he is a Flash master and I'm just a beginner, so, please
pleeeeeaaaase!, anybody help me!
Thank you very much!

Tween Class Trouble
I have 2 tweens. I want my first one to be around 50% completed to start my second one. How do I do that ?


Code:
var Tween_right:Tween = new Tween(_root.mc_holder.mc_backgroundBlue, "_x", Strong.easeOut, 0, 525, 1, true);

var AlphaUp:Tween = new Tween(obj, "_alpha", Regular.easeOut, 0, 100, 1, true);
AlphaUp.stop();

Tween Class Trouble
I don't use Tween class often, so don't scold me if this is an obvious question.

When I set up a simple Tween, it works if I assign a specific object's instance name as the object to tween. But when doing it inside a for loop, it doesn't work. Yet everything else within the for loop works. I've tested every variable, and it's the object name that doesn't work. Here is a simplified version of the code. Someone please tell me what I've done wrong.









Attach Code

import mx.transitions.Tween;
import mx.transitions.easing.*;
for (var k:Number = 1; k<15; k++) {
var dakine = this["letter"+k];
dakine.onPress = function() {
this._xscale = this._yscale=90;
this.startX = this._x;
this.startY = this._y;
startDrag(this);
};
dakine.onRelease = dakine.onReleaseOutside=function () {
stopDrag();
this._xscale = this._yscale=100;
var letterUp:Tween = new Tween(this, "_x", Bounce.easeOut, this._x, this.startX, 2000);
};
}

Trouble With 1st Kirupa Flash 8 Tween Tutorial
Hi,

I'm on a Mac and a Flash MX 2004 user. I attempted to do Kirupa's very basic animation tweening tutorial to get myself going with Flash 8, but I cannot get it to work.

The motion works fine, but when I introduced the alpha part, it started behaving erratically. It just won't fade IN.

I am familiar and comfortable with animation tweens involving motion and fades in MX 2004...

I tried just doing a fade in for a single letter, not even inside a movie clip (as the tutorial has you do), and didn't use motion -- just a fade in: Can't even get that to work.

Any ideas? Some silly thing I overlooked??

Thanks!

SL

Tween Class Tutorial ....?
I'm trying to learn about this whole thing, and am wondering if you know of any tutorials for it.

thanks.

Tween Class Tutorial
Hi all, I've been working through the tween class tutorial and I can't work something out. I may be being stoopid but what do the three values at the end of the third line refer to?

var xScaleT:Tween = new Tween(star, "_rotation", Elastic.easeOut, 10, 360, 40, true);

Obviously '360' refers to the angle of rotation but when I alter the first and the third value they both seem to do the same thing and change the speed.

Tween Class Tutorial?
I'm trying to learn about this whole thing, and am wondering if you know of any tutorials for it.

thanks.

Tween Class Help - (from Tutorial On This Site)
Hi,

I was doing a tutorial from this website... the one on the tween class... I am trying to learn it...

So I downloaded the example... I was trying to add some of my own code and it is not working as I expected. I was wondering if anyone had any insight into this...

the code:

import mx.transitions.Tween;
import mx.transitions.easing.*;
var xPosT:Tween = new Tween(frame1, "_x", Regular.easeOut, -150, Stage.width / -13, 1, true);
var yPosT:Tween = new Tween(frame1, "_y", Regular.easeOut, -600, Stage.height / -62, 1, true);
xPosT.onMotionFinished = function() {
this.continueTo(Stage.width / -13, 1);
};
yPosT.onMotionFinished = function() {
this.continueTo(Stage.width / -62, 1);
};



My movie clip is called "frame one"
The tweening works fine along the x axis... which is what was on the tutorial... the movie clip does not stop where I want it along the _y axis...
I want it to stop at -62 (this is because the graphic is slightly larger than the movie itself)

Instead of stopping at -62 along the y axis, it keeps going from -300 to 0 on the y axis...

does anyone know how this works?
many thanks

Tween/Transition Class Tutorial
FYI




MM - DEVNET Using the Tween and Transition Classes in Flash MX 2004 by Jen deHaan.

http://www.macromedia.com/devnet/mx/...ing_print.html

In Reguards To The "Using The Tween Class" Tutorial.
When i download the file, and open it up in Flash, it tells me "Unexpected File Format".

Um... What the hell is going on? I'm running Flash MX (not sure if its 2004 or not)

Tween Class If Moved Mc Passed Point Start Another Tween
Hey Actionscript Gurus

Now I am using the Tween Class to move some boxes in my movie, now I can move the first mc and then another mc after the first tween has finished with onMotionFinished but I was hoping someone could help with how do I start the second tween when the first mc has passed a certain _x coordinate.

ie starting the second mc moving while the first tween is still moving.

I am trying to do a intro loader for my front page controlling around 7 boxes. So I need to repeat this a few times.

Regs,
Jacko

Tween Class If Moved Mc Passed Point Start Another Tween
Hey Kirupa Flash Gurus

Now I am using the Tween Class to move some boxes in my movie, now I can move the first mc and then another mc after the first tween has finished with onMotionFinished but I was hoping someone could help with how do I start the second tween when the first mc has passed a certain _x coordinate.

ie starting the second mc moving while the first tween is still moving.

Regs,
Jacko

Tween Class Scaling Breaks Motion Tween?
I have a movie clip which uses a motion guide to animate the entry (and eventually the exit) of a bunch of other movie clips. These smaller clips contain buttons, and animate on rollOver and rollOut using the following code:


Code:
on(rollOver) {
this.swapDepths(2);
ParentxScale = new mx.transitions.Tween(this, "_xscale", mx.transitions.easing.Back.easeOut, this._xscale, 100/.6, .5, true);
ParentyScale = new mx.transitions.Tween(this, "_yscale", mx.transitions.easing.Back.easeOut, this._yscale, 100/.6, .5, true);
play();
}
on(rollOut) {
ParentxScale = new mx.transitions.Tween(this, "_xscale", mx.transitions.easing.Bounce.easeOut, this._xscale, 100, .5, true);
ParentyScale = new mx.transitions.Tween(this, "_yscale", mx.transitions.easing.Bounce.easeOut, this._yscale, 100, .5, true);
stop();
}
However, once an object has been moused over, it doesn't exit with the others. Any ideas why it seems to "fall off the track" of the motion guide?

Tween Class: Can One Tween More Than One Property Using The Same Tween
I want to scale both the _xscale and the _yscale properties of a clip, using a single execution of the Tween Class. See example below:


Code:
import mx.transitions.Tween;
var myTween:Tween = new Tween(myMovieClip_mc, "_xscale", Strong.easeOut, myMovieClip_mc._xscale, 300, 5, false);

Since one property at a time must be passed as a string to the constructor, I tried the following code, but it does not work quite as flawless as I expected:


Code:
myTween.onMotionChanged = function() {
//trace( this.position );
myMovieClip_mc._yscale += (300 - myMovieClip_mc._yscale)/12;
};
Any suggestions?

After Tween, Jump To New Frame (using Tween Class)
I need some help with using the tween class (among other things).

See my attached test file. It's clearer than my description.

You're supposed to be able to click the "next" or "prev" buttons and see the movie clip move forwards or backwards. It works, but only on the first click of the button. After the initial click I need the timeline to jump to frame label "2", and after the second click I need the timeline to jump to frame label "3", and so on, so that I can implement a new set of perameters. Is that clear? I'm so annoyed with this. Please help!

Thanks.

Tween Class Problem. Tween Freeze?
I am using the tween class to do an alpha tween on some jpgs that get loaded into a movieclip. Everything thing works great until the user rapidly clicks on the 'next' arrow to jump forward to a new picture. If the user clicks too quickly something happens and the tween function stops working.

Here is the tween code:

Code:
//set up tweening
import mx.transitions.easing.*;
import mx.transitions.Tween;
var tweenAlpha:Tween;
function alphaTween(object,duration){
easeType = mx.transitions.easing.Regular.easeIn;
tweenAlpha = new mx.transitions.Tween(object, "_alpha", easeType, 0, 100, duration, true);
}
http://12dogsofchristmas.com/12_dogs_menu2.swf

You'll notice that if you click slowly on the arrows the pictures load correctly with the story. However, if you click fast they stop tweening.

thanks for the help.

Tween.stop(). Part Of The Tween Class?
I need to know if tween.stop() is part of the Tween class in Flash 8 or if it's related to an extension I installed (ie. TweenExtended).

Tween Class Not Always Fulling Complete Tween
I have a switch statement that is a part of the tween effects found on the header of http://gfxcomplex.com/blog.

the problem is this case will change the rotation of a sprite and then tween it to zero. The funny thing is some times ("not all the time") some of the tween stop in the middle and do not complete leaving the sprite with a rotation somewhere in the middle of 180 to 0. My question is, is there something in my code that could be the reason for this or is this a bug??

You may have to watch the header for a long time to see this bug happen as it seems to be more a fluke then a true code bug.


PHP Code:



case 7 :            var u:uint = 0;            test1.getChildAt(0).rotation = 180;            test1.getChildAt(1).rotation = 180;            test1.getChildAt(2).rotation = 180;            test1.getChildAt(3).rotation = 180;            test1.getChildAt(4).rotation = 180;               intervalId = setInterval(function myFunction(){                                                          myTween1 = new Tween(test1.getChildAt(u), "rotation", Bounce.easeOut, 180, 0, 3, true);                                                          u++;                                                          if(u == 5){                                                                                                                      clearInterval(intervalId);                                                                                                                        }                                                          },                                                          150);break; 

Tween Class Applied In Custom Class Not Working
var sizerW:Object = new Tween(pda_mc,"_xscale",mx.transitions.Tween.None.e aseNone,pdaOrigW,pdaSmallW,3,true);

this code produces and error when applied in a custom class but not in a fla?

the error = There is no property with the name 'None'.

Tween Class In Custom Extend MovieClip Class
I want to use the tween prototype in a custom class that extends MovieClip. I am already including "lmc_tween.as" in my root and I have already replaced the "MovieClip.as" file in my flash directory with the one from the shared/Zigo directory. However, I still get compiler errors if I try to include "lmc_tween.as" in the class file, or without the include in the class it will compile but the tween prototype will not work in the custom class. Does anyone know how to fix this?

Cancel Code-based Tween
Hi,

I am having some problems with Tween behaviour. I have two 'pages' which are DisplayObjects with children. On the first I have an object that has a default position and it can also be tweened to a 'yes' or 'no' position. There is also a skip button which when pressed resets the position of the object to its default position.

If the object has finished tweening fully and I press the skip button to go to the next page and come back, the object is in its default position as it should be, but if I skip while the tween isn't completely finished and then come back, it will still be in the 'yes' or 'no' position.

I have tried using tween.fforward() which seems to speed it to the end of the tween, but the same problem occurs, I am wondering if the tween still runs for the same amount of time but appears as the last frame would?

Is there a way to cancel a tween?

thanks for your time

Help Change MC Size Based On Other MC's Tween
Hiya, a little hard to explain, there's a link to the fla if anyone has time to help.

I have 4 mc's and I'm trying to tween three of them to "avoid" the focused mc. Thought this would be easy, but I'm using a mask inside each mc, and I need the image in each to move a little to. I don't know if I'm making this clear, but here's the code I'm working with, and here's the link to the fla

FLA File

Thanks in Advance if anyone can help.

| judge


Code:
#include "mc_tween2.as"
var clipArray:Array = new Array(top, second, third, bottom);

function init(){
for(var i = 0; i<clipArray.length; i++){
thisClip = clipArray[i];
thisClip.mask.h = thisClip.mask._height;
thisClip.mask.Y = thisClip.mask._y;
thisClip.image_mc.Y = thisClip.image_mc._y;
thisClip.cover.alpha = thisClip.cover._alpha;
thisClip.onRollOver = function(){
moveClip(this);
moveOthers(this);
};
thisClip.onRollOut = function(){
this.cover.alphaTo(this.cover.alpha, .2, "linear");
this.mask.tween(["_y", "_height"], [this.mask.Y, this.mask.h], 1);
this.image_mc.tween("_y", this.image_mc.Y, 1);
};
}
}


function moveClip(mc){
mc.mask.tween(["_y", "_height"],[0, 275], 1);
mc.image_mc.tween("_y", 0, 1);
mc.useHandCursor = false;
mc.cover.alphaTo(0, .2, "linear");
}
function moveOthers(exceptThis){
//????
}

init();

Tween Mouse Movement Based On...
Searched the forum and couldn't find the mouse movement using the ._x/._y tween class to move based on another mc's dimension to give me the idea how to work on it. Could use some help here to nudge me the right direction...

jace

Cancel Code-based Tween
Hi,

I am having some problems with Tween behaviour. I have two 'pages' which are DisplayObjects with children. On the first I have an object that has a default position and it can also be tweened to a 'yes' or 'no' position. There is also a skip button which when pressed resets the position of the object to its default position.

If the object has finished tweening fully and I press the skip button to go to the next page and come back, the object is in its default position as it should be, but if I skip while the tween isn't completely finished and then come back, it will still be in the 'yes' or 'no' position.

I have tried using tween.fforward() which seems to speed it to the end of the tween, but the same problem occurs, I am wondering if the tween still runs for the same amount of time but appears as the last frame would?

Is there a way to cancel a tween?

thanks for your time

Help Recreating Tween-Based Loop In AS3
Hello there:

I am recreating an animation similar to the one seen in use in various parts of the Apple OS (as well as other places) to be utilized as a loop played while loading content. I've built a tweened version, but I know this should be relatively simple to do exclusively through code... I just can't get my head around it. (I am certainly more designer than developer, but I'm working on it...)

Here's what I'm talking about: http://www.gameover.com/tictac/wheel

Would someone be able to provide either hints, or even the exact method to do this? To my mind, it would be fairly straightforward: Draw the line, tween the alpha from 100 to 0 over x number of frames, rotate 30 degrees (using a transformation point a bit below the line), draw, tween, repeat until you get back to the top and then loop. I just don't know to say that using AS3. I am going to get Foundation Actionscript 3.0: Making Things Move soon, though.

Thanks for any help! Mark

Tween Class Vs Custom Tween?
I have searched for info on the Tween class, gave up when I found little to nothing on it, so here I am with some questions.

1 - Can I use this class in MX 2004 or is it in 8 only? If so, what is the invocation script?

2 - How flexible is the easing of the Tween class? Can it do more than just fast/slow in/out (fully customizable time curves)?

3 - Can you specify a finite amount of time in which the current invocation of Tween must be completed, or do you have to calculate and apply values to enforce this?

Thanks,
+Q__

Tween Class - Tween Lines
I have 5 seperate movie clips that each contain 5 lines, which are contained within their own individual movieclips, each with their own instance name.

I have written a function, included below, that uses the tween class to make one set of lines move/morph to the location of the second set, contained within the other movieclip.

It's basically a transition.. it's for the navigation of a site I'm working on. When you click a different navigation link, the lines that the nav & content are based around morph/change.

The problem I'm having is not all the lines tween to the right location/position. I've attached a 2 screenshots to show..

I've tried the function with the addition of the _xscale, _yscale, and _rotation properties, but they don't change anything.

Heres the function:


Code:
function moveLines(begin, end) {
//this moves the MC that holds the 5 lines to the x/y pos of the other MC.
var x_container:Tween = new Tween(_root[begin], "_x", Regular.easeOut, _root[begin]._x, _root[end]._x, 10, false);
var y_container:Tween = new Tween(_root[begin], "_y", Regular.easeOut, _root[begin]._y, _root[end]._y, 10, false);


//this is the loop that gets the start/end variables and creates the tweens
for (i=1; i<=5; i++) {
x_begin = _root[begin]["l" + i]._x;
x_end = _root[end]["l" + i]._x;

y_begin = _root[begin]["l" + i]._y;
y_end = _root[end]["l" + i]._y;

height_begin = _root[begin]["l" + i]._height;
height_end = _root[end]["l" + i]._height;

width_begin = _root[begin]["l" + i]._width;
width_end = _root[end]["l" + i]._width;

var x_tween:Tween = new Tween(_root[begin]["l" + i], "_x", Regular.easeOut, x_begin, x_end, 15, false);
var y_tween:Tween = new Tween(_root[begin]["l" + i], "_y", Regular.easeOut, y_begin, y_end, 15, false);
var height_tween:Tween = new Tween(_root[begin]["l" + i], "_height", Regular.easeOut, height_begin, height_end, 15, false);
var width_tween:Tween = new Tween(_root[begin]["l" + i], "_width", Regular.easeOut, width_begin, width_end, 15, false);
}
}
Now here are the screenshots. The first is before the tween occurs, and the second is after. As you can see, some of the lines don't fall into the right position. Any help is greatly appreciated! I have a deadline for this this week and I'm freaking out!

before tween:
http://sagebrown.com/before.jpg

after tween:
http://sagebrown.com/after.jpg

How To STOP A Tween With The Tween Class?
here's my code....


Code:
function generalTween(mc, attr, begin, end, time, func, easeType)
{
if (easeType == undefined) easeType = mx.transitions.easing.Bounce.easeOut;
var myTween = new mx.transitions.Tween(mc, attr, easeType, begin, end, time, true);
if (func != undefined) myTween.onMotionStopped = func;
}
function onReleaseFunc()
{
myBall.stopDrag();
generalTween(myBall, "_x", myBall._x, (Stage.width / 2), 2, undefined, mx.transitions.easing.Elastic.easeOut);
generalTween(myBall, "_y", myBall._y, (Stage.height / 2), 2, undefined, mx.transitions.easing.Elastic.easeOut);
}
myBall.onPress = function()
{
myBall.startDrag();
}
myBall.onRelease = function()
{
onReleaseFunc();
}
myBall.onReleaseOutside = function()
{
onReleaseFunc();
}
To test this just make a movieclip on your stage and give it an instance name of "myBall"

you'll notice that the problem is, if you try to click and drag the movieclip again before the tween is completed finished, then it doesn't work.

How can you force a stop on a tween?

thank you so very much in advance!!!!

New Fuse-like Tween Engine Based On Go ASAP
Hi,
if you liked Fuse, you should have a look on Tweego:
http://code.google.com/p/tweego/

Tweego is a well structured and powerful engine and can be used like Fuse.
It's based on the Go ASAP by Moses Gunesch (Author of Fuse).
For complex tweens and sequence controlling this system is perfect.


Code:
var t:Tweego = new Tweego;
t.push({target: target, x: 100, y: 200, time: 1, ease: Bounce.easeOut});
t.push({delay: 2});
t.push({target: target, width: 500, time: .5, ease: Elastic.easeOut, func: onComplete});
t.start();


So have a look and please give me feedback Thanks a lot

s

Tile Based Maps Giving Me A Lot Of Trouble..
function createMap(which){
links=[[4, 0x949301, 1]]
arena=new Object()
arena.map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, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
k=0
areaArray=[town, arena]
area=areaArray[which]
for(x=0; x<area.map.length; x++){
for(y=0; y<area.map[x].length; y++){
_root.tile.duplicateMovieClip("tile"+k, k)
_root["tile"+k]._x=x*6
_root["tile"+k]._y=y*6
k++
}
}
}
function remove(){
k=0
for(x=0; x<area.map.length; x++){
for(y=0; y<area.map[x].length; y++){
_root["tile"+k].removeMovieClip()
k++
}
}
}
function cm0(){
k=0
for(x=0; x<area.map.length; x++){
for(y=0; y<area.map[x].length; y++){
if(area.map[y][x]==0){ _root["tile"+k].c=0x999999 } //wall
if(area.map[y][x]==1){ _root["tile"+k].c=0x009900 } //grass
if(area.map[y][x]==2){ _root["tile"+k].c=0xA3C1E0 } //water
if(area.map[y][x]==3){ _root["tile"+k].c=0x949301 } //road
k++
}
}
}
function cm1(){
k=0
for(x=0; x<area.map.length; x++){
for(y=0; y<area.map[x].length; y++){
for(i=0; i<links.length; i++){
if(area.map[y][x]==links[i][0]){
_root["tile"+k].c=links[i][1]
_root["tile"+k].i=i
_root["tile"+k].onEnterFrame=function(){
if(_root.p.xpanel==3){
remove()
createMap(this.i)
cm0()
}
}
}
}
k++
}
}
}
_root.pl.duplicateMovieClip("p", 400)
_root.p.c=0x000000
_root.p._x=40
_root.p._y=50
createMap(1)
cm0()
cm1()


that above are the map functions. createMap() makes the actual mc's. cm0() differentiates between dif tile types. cm1() is supposed to look thru the map to see if there r any 'special' tiles that r in the links array. these tiles are the links from one map to another. once it finds one, it gives the tile the color specified in the array and also tells it to wait for the player to be (in this case, ill make it more dynamic later) directly below it. since my function didnt work, i made it easier for now and said if the player is on the third panel, do the stuff.
heres what i wanted to happen: the areaArray has all the maps availabke. the town would be areaArray[0] and so on. this is how createMap() works. what i wanted is that in links, the actual map u'd be linking to would be ure index in the array. so link[0]=[4, 0x949301]

this means tile of type 4 gets that color and links to map 0 in the areaArray. thats what u see in the cm1() function al the way inside. it says createMap(i) and i has already been defined as the place in links where 4 is. so it should be 0, considering there is only one thing in links, but it isnt. its 1. i dont know how. if i enter createMap(0), it works fine, but i want this function to be dynamic, so i have to enter i as the variable, but it is always 1... can anyone help?

Gallery Based On Xml Like In Tutorial, But....
Hi
I try to make galery based on xml, just like in tutorial http://www.kirupa.com/developer/mx20...otogallery.htm , but i wanna, that preloading will be not before every picture, bu t just one in start. First load all jpg from xml, and then start to looking at it.

Could someone help me with this? I'm begginer in AS, so plese, help.

Sorry if my english isn't as wel, as it should.

Can SetInterval Smooth A Timeline Based Motion Tween?
Is it possible to have setInterval, smooth out a traditional motion tween animation rather than having to animate via actionscript?

I'm a noob with actionscript, plus this is because i need to animate an image along a motion guide.

U guys are clearly pro and im sure you have a solution for me

Thanks Guys.

Xml-based Slideshow - Trouble Pushing Code Into An Array
Hi,

I’m trying to create an xml-based slideshow in flash and am having trouble pushing some code into an array.

The following is an extract showing how my xml file is structured:


Code:
<slideshow>
<garment url="formal01.jpg">
<title>Classic Design Formal Suit</title>
<style>5993</style>
<description>Olorperat illaor sim dio od dolore velit atie modiatem adio et ipit praesectem erit, vel ipsuscip er sit velit ipisciduis nulla.</description>
<price>$???</price>
<colours>Black</colours>
<sizes>87cm to 152cm</sizes>
</garment>

<garment url="formal02.jpg">
<title>Another title goes here</title>
<style>5994</style>
<description>Olorperat illaor sim dio od dolore velit atie modiatem adio et ipit praesectem erit, vel ipsuscip er sit velit ipisciduis nulla.</description>
<price>$???</price>
<colours>Black, White</colours>
<sizes>87cm to 137cm</sizes>
</garment>

</slideshow>
The urls are stored as attributes within the garment tag and the rest of the caption is stored with separate tags nested within the garment tags:

In my .fla file I have the following code:


Code:
var ssx:XML = new XML();
ssx.ignoreWhite = true;

var currentIndex:Number = 0;
var captions:Array = new Array();
var urls:Array = new Array();

ssx.onLoad = function(success) {
if (success) {
var ss:Array = ssx.firstChild.childNodes; //stores pictures as separate elements
for (i=0;i<ss.length;i++) {
urls.push("images/" + ss[i].attributes.url);
captions.push(ss[i].childNodes[0].firstChild.nodeValue);
}
frame_mc.images_mc.loadMovie(urls[currentIndex]);
captions_txt.htmlText = captions[currentIndex];
}
else
{
trace("XML file failed to load.");
}
}

ssx.load("formalwear.xml");
With the for loop I'm trying cycle through the ss array, pull out the url attributes as well as the rest of the caption, and assign the values to the arrays called "captions" and "urls".

Since my url was stored as an attribute, the following line of code works to push the url into the urls array:

urls.push("images/" + ss[i].attributes.url);

...however, the captions line entered as follows doesn’t push the captions into the captions array:

captions.push(ss[i].childNodes[0].firstChild.nodeValue);

It only outputs the information contained in the <title> tag, ie. Classic Design Formal Suit

Since the caption isn't stored as an attribute, I assume I need the following code to be pushed into the captions array, but I don’t know how to do it.


Code:
var caption:String = ""
caption += "<b>"
caption += ss[0].childNodes[0].firstChild.nodeValue;
caption += "

</b>";
caption += "<b>Style Number</b>
"
caption += ss[0].childNodes[1].firstChild.nodeValue;
caption += "

";
caption += "<b>Description</b>
"
caption += ss[0].childNodes[2].firstChild.nodeValue;
caption += "

";
caption += "<b>Price</b>
"
caption += ss[0].childNodes[3].firstChild.nodeValue;
caption += "

";
caption += "<b>Colours</b>
"
caption += ss[0].childNodes[4].firstChild.nodeValue;
caption += "

";
caption += "<b>Sizes</b>
"
caption += ss[0].childNodes[5].firstChild.nodeValue;
Can someone tell me how I can fix the code?

Appreciate any help offered.

Tween Class & Button Class
Sorry I accidently made two threads.. can this be deleted please??

[CS3] Looking For A Simple, Text Based Nav/menu Tutorial.
hi all

i am looking for a tutorial, that is very very simple, but i cant seem to find one! i want to make a left-side, vertical navigation for a personal portfolio site.

doesnt need animating, and just needs to be able to expand, e.g.

about
work
contact
other


work expands to:

about
work
project 1
project 2
project 3
contact
other


about
work
project 1
project 2 PROJECT IMAGE HERE
project 3
contact
other

info
< images >



anyone here know of any tutorials for this kinda thing?

Scroller Based On Kirupa Tutorial Issue...help.
Hello,
I have been playing with the Kirupa scroller tutorial (http://www.kirupa.com/developer/flash8/scrollbar.htm ). I have been able to get it to work as a separate independent movie and swf file, but when I try to use the same steps and embed it within another movie it stops working.

What I have been trying: while in the main timeline of the main movie, I build a new movie clip using the tutorial. When I place an instance of the scroller movie clip on the main timeline, it will not function.

Should I be making some adjustments to the actionscript to get the scroller to work?

I hope I have given enough information for someone to give me a suggestion.
Thanks for your help in advance.

Ray

Problem With Xml Gallery Based On Kirupa Tutorial
Hi
I want to change code from here http://www.kirupa.com/developer/mx20...togallery2.htm that at the end of photos next_btn will change colour for black, or just set alpha=0. Also With prev_btn at the first photo.

Anyone can help?
thank You
Rafal

Flash Based PHP Contact Form Tutorial
Hi

Well here's to the Flash Based PHP Contact Form Tutorial.

I have embedded it on my website using your tutorial. I would like to know whether we can add a status message (Sending Message etc.), while the message is being sent and then the Message Sent Frame. Please do let me know.

Cheers
Deejay T

Mp3 Player Questions (based On GotoAndLearn Tutorial)
Good-day men,

first of all, compliments for your tutorials.. they are great!

I have some "stupid" questions, if you wanna help me:

- how can I start the player from the position "pause" (so without playing a song when I open the flash) (and so with the button in position "play")

- I would like to add the button "previous track".. what code I need to create into the "mp3player.as"? (I think the button is the same of next but with "negative image" and with different names..)

- for a button like "stop" what I have to do? (a button with a simple action like: stop(); or stopAllSounds(); ?) (I've tried but without success...)

thanks to peolple will help me!

_x Tween Trouble
I am unable to tween into a specific position. Here is the code that I am using.
if (_root.arrow._x>330) {
_root.arrow._x-=70;
gotoAndPlay("loop");
} else{
gotoAndStop(1);
}
When I replace "-=70" with "--" I can hit the exact spot that I am going for, but it does not move fast enough.

Any suggestions would be greatly appreciated.

Thanks

AS3 - Class-based Example Of FLV Playback
I'm interested in having a button that resets my FLV to the beginning of the video using the seek(0) syntax. However, I can't seem to find any examples that do it with an AS file.

For example, this code mostly works, but I don't know how to define the netStream so that the other functions can see it.


ActionScript Code:
package {
    import flash.events.*;
    import flash.display.Sprite;
    import flash.net.*;
    import flash.media.Video;
    public class TestEngine2 extends Sprite {
        public var nc:NetConnection = new NetConnection();
        public function VideoTest1Engine():void {
            //var nc:NetConnection = new NetConnection();
            nc.connect(null);
            var ns:NetStream = new NetStream(nc);
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
            var vid:Video = new Video();
            vid.attachNetStream(ns);
            PlayMovie.addEventListener(MouseEvent.CLICK, PlayFLV);
            ResetMovie.addEventListener(MouseEvent.CLICK, ResetFLV);
            addChild(vid);
        }
   
        public function ResetFLV(event:MouseEvent):void
        {
            // Pause the stream and move the playhead back to
            // the beginning of the stream.
            ns.pause();
            ns.seek(0);
        }
 
        public function PlayFLV(event:MouseEvent):void
        {
            ns.play("JapanMovie1.flv");
        }
   
        public function asyncErrorHandler(event:AsyncErrorEvent):void {
            trace(event.text);
        }
    }
}


I'm super close-but my functions aren't aware of my ns variable, and I don't know how to make them aware of it. I can't pass ns as a parameter, so I'm stuck.

Thanks in advance.

Complete Flash-Based Web Site? Book Or Tutorial?
I know the basics of Flash CS3, but would really love to learn how to do a complete Flash-based website. Anyone have any suggestions on a book or online tutorial?

Cycler Tutorial (Array-based Letter Randomizer)
Hey, this is my first tutorial!
Here it goes.

Just recently, I wanted to make my hit counter on my website display random characters before eventually showing the actual hit count. I read the two great tutorials on how to do this, but I didn't want to quite do it the way they did. The difference with my method is that I don't use ascii code, and there's no movie clip duplication. I use strictly arrays of the letters, and randomize it there. My method also offers minimum and maximum number of times to randomize for each letter.

I call this: Cycler.

Attached is the .fla. I would suggest downloading it, but if you're like me and would rather see the code right here; here it is. At the bottom, after the snippet, I have explanations of various critical parts of it.

At this point, it can get rather long, so if you have the patience, please read on.

<Start Snippet>

// Constants, as function literals (so they can't be modified from the outside)
// However, the actual variables used during the cycle CAN still be modified
getDefaultRandomChars = function(){return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ1234567890";};
getDefaultMinCycles = function(){return 5;};
getDefaultMaxCycles = function(){return 45;};

// Don't change any of these from the outside
var cycleName = "";
var randomChars = getDefaultRandomChars();
var minCycles = getDefaultMinCycles();
var maxCycles = getDefaultMaxCycles();
var clipInitialized = false;
var cycleInitialized = false;
var cycling = false;
var aNameOriginal = new Array();
var aNameCycled = new Array();
var aCycles = new Array();

onEnterFrame = function(){
if (!clipInitialized){
// Add any intialization here

clipInitialized = true;
return;
}

if (cycling){
if (!cycleInitialized){
// Initialize letter arrays
aNameOriginal = String(cycleName).split("");
aNameCycled = String(cycleName).split("");

// Initialize the cycle counter
aCycles = new Array(aNameCycled.length);
for (i=0; i < aCycles.length; i++){
aCycles[i] = 0;
}

cycleInitialized = true;
}

for(i=0; i < aNameCycled.length; i++){
// Goal: Cycle through each letter and randomize it
//Must randomize at least n times defined by minCycles
//Must stop randomizing after n times defined by maxCycles
if (aCycles[i] < minCycles){
aNameCycled[i] = randomChars.charAt(random(randomChars.length));
aCycles[i]++;
}
else{
if (aCycles[i] > maxCycles)
aNameCycled[i] = aNameOriginal[i];
else
if (aNameCycled[i] != aNameOriginal[i]){
aNameCycled[i] = randomChars.charAt(random(randomChars.length));
aCycles[i]++;
}
}
}

// Output
mainText.text = aNameCycled.join("");

if (mainText.text == cycleName){
// Reset and do a little cleanup
cycling = false;
cycleInitialized = false;
cycleName = "";
aNameOriginal = null;
aNameCycled = null;
aCycles = null;
}
}
}

function Cycle(pcycleName, prandomChars, pminCycles, pmaxCycles){
// Apply defaults if necessary
if (pcycleName == undefined || pcycleName == "") return;
if (prandomChars == undefined || prandomChars == "") prandomChars = getDefaultRandomChars();
if (pminCycles == undefined || pminCycles < 1) pminCycles = getDefaultMinCycles();
if (pmaxCycles == undefined || pmaxCycles < 2) pmaxCycles = getDefaultMaxCycles();

// Validate
if (pminCycles >= pmaxCycles){
// user error, use defaults
pminCycles = getDefaultMinCycles();
pmaxCycles = getDefaultMaxCycles();
}

cycleName = pcycleName;
randomChars = prandomChars;
minCycles = pminCycles;
maxCycles = pmaxCycles;

cycling = true;
}

<End Snippet>

Usage:
The main occurrence is for the parent to call the Cycle function. The first parameter (required) is the String you want to cycle on. The second Parameter (optional), is the list of random characters you want the cycle to use. The third and fourth Parameters (optional) define how many times you want random characters to cycle (min and max, respectively). That's it, just call that function.

Explanation:
The first 3 lines are function literals, serving as my Constants. Not really sure why there isn't away to define constants and/or protected variables unless I'm missing something.

The next set of lines are just simple variable declarations. The most important of which are the arrays. I have arrays that hold the original and altered letters, as well as, an array to hold how many times each letter has been randomized.

The first function is another function literal. This is the onEnterFrame function. I use this quite a bit, as I try my best to "blackbox" all my movie clips. And in order to "blackbox" it, any initialization of variables and whatnot should be done inside the clip instead by the parent. In this function, this is where most the logic is. As the function is entered x number of frames per second (defined by your frames per second value), it loops through the array of letters (further down, I'll explain how this is set) and randomizes them via randomCharacters variable. It will only randomize if it has not exceeded the maxCycles variable, and if it does, it simply uses the correct letter (from aNameOriginal array). After all characters have been randomized inside the aNameCycled array, it is then outputted to the mainText dynamic text control by calling the join() String function. The join() function joins all elements in the array into a string. The parameter passed in, is what delimits the elements. In this case, we want the characters contiguous; that's why we pass in an empty string (""). After mainText is updated, the function needs to determine whether the next instance of the function still needs to randomize. If mainText equals what you want to be displayed, it turns off the cycling variable.

The next function is Cycle. This is what the parent clip should be calling. Usage is described above. This function takes the parameters, validates them, and applies default values if necessary. If everything is cool, the main variables (cycleName, minCycles, maxCycles) are set, and the cycling flag is turned back on.

Please email me on any comments or questions about this tutorial. When my site is up, you'll be able to access this tutorial there, as well, and hopefully, in a better format than this.

Thanks.
JGo

Multiple Tween Trouble
Ok are you sopposed to have more then 1 dif. kind of tweens on 1 layer....or are u sopposed to make a seperate layer 4 a seperate tween
thx alot 4 the help
this ? is bothering me

Fade In Tween Trouble...
maybe i'm completely crazy... i'm trying to tween a mc symbol... just a simple alpha fade... on the main timeline of a swf... he symbol is made of dynamic text embeded... but of two different text boxes... converted to grapic symbols... on two different layers... in the mc symbol... is there something wrong with me...? it wont tween... i've tried it with one layer... i've tried it grouping them... i need the fonts to be two different sizes in the one symbol...

help... it's probably something silly...

[FCS3] Tween Trouble In CS3
My Flash experience is in using Flash8, and I'm currently using CS3 for the first time. I am however using AS2.0, not 3.0.

I'm using several motion tweens between various keyframes in a layer of a movieclip. Each tween is from a keyframe with a symbol instance set at color: Alpha, 0% and the same symbol with color: Alpha, 100%. These appear to be functioning properly. Below that layer I have a layer with almost identical "static" symbols. The intended effect being part of the swf "fades in."

However, by the second frame as the alpha starts to tween in, the entire image (including the normal static layer) is washed out as if the tween layer has 100% opacity over the static fill layer.

I've done the exact same thing in the past using Flash8, so maybe I'm just forgetting something. Thanks for any help!

Trouble With HitTestPoint And Tween
Hi guys,
I'm having a trouble with hitTestPoint and tween. Well, if you look at the code you will understand what I am trying to archive here.

---------------------
var action:Tween;
target01.alpha = 0.6;
target01.addEventListener(Event.ENTER_FRAME, transition01);
function transition01(event:Event):void {
if (target01.hitTestPoint(mouseX, mouseY, true)) {
action = new Tween(target01, "alpha", Strong.easeOut,0.6, 1, 1, true);
} else {
action = new Tween(target01, "alpha", Strong.easeOut,1, 0.6, 1, true);
}
}
---------------------

Yes, that's right. I'm trying to make the movie clip 'target01' to fade in once the mouse pointer roll-overs, and fades out when roll-out. But tween actions don't work...
Yes, I did MouseEvents instead, but it is not the way I want it.. Please help me outta here guys.

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