kirupaForum

kirupaForum (http://www.kirupa.com/forum/index.php)
-   Flash ActionScript (http://www.kirupa.com/forum/forumdisplay.php?f=9)
-   -   ActionScript 3 Tip of the Day (http://www.kirupa.com/forum/showthread.php?t=223798)

senocular 09-22-2006 07:33 AM

System.totalMemory
 
The System class (flash.system.System) in ActionScript 3 has a new property called totalMemory (flash.system.System.totalMemory). This property provides the current memory usage of the Flash player in bytes. Examples:
ActionScript Code:
var o:Object = new Object();
trace(System.totalMemory); // 4960256
 

ActionScript Code:
var o:MovieClip = new MovieClip();
trace(System.totalMemory); // 4964352
 

ignitrix 09-22-2006 05:55 PM

Quote:

Originally Posted by senocular
ActionScript 3 lets you easily obtain any instances class name using a new function called getQualifiedClassName (flash.utils.getQualifiedClassName)...

Similarly, is it possible to acquire a reference to a Function object from a String with the function's name?

~JC

senocular 09-22-2006 07:12 PM

finish reading that post :crazy:

senocular 09-25-2006 07:40 AM

Closing Net Connections
 
Previous versions of the Flash player could not close connections to the internet once a download into the player has started. For example, if you started loading a 50 Meg swf into the flash player but wanted to stop it once the user requested different content, you couldn't. The only way to prevent Flash from continuing to load that SWF would be to close the player (i.e. navigate away from that web page).

In Flash Player 9, using ActionScript 3, you can now stop connections and abort loading requests made by the player. Consider the Loader class (flash.display.Loader). Its a displayObjectContainer class that loads external content into the player acting like a cross between a MovieClip and a LoadVars class (from AS1 and AS2). You can load content into this class using the load method. To abort that loading process, you would use the close method. Example:
ActionScript Code:
var loader:Loader = new Loader();
var request:URLRequest = new URLRequest("image.jpg");
loader.load(request);
addChild(loader);

// abort loading if not done in 3 seconds
var abortID:uint = setTimeout(abortLoader, 3000);

// abort the abort when loaded
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, abortAbort);

function abortLoader(){
    try {
        loader.close();
    }catch(error:Error) {}
}
function abortAbort(event:Event){
    clearTimeout(abortID);
}


Notice that the close() method was placed in a try..catch block. This is because close will throw an IOError if you use it on a Loader instance when there is no connection open (this should never happen in this case, though, since once loading is complete, the timeout is cleared - good practice none the less).

pet-theory 09-25-2006 10:43 AM

loader "interrupt" then "resume" possible?
 
After reading this tip, I looked up the loader and the sound class in the Adbobe documentation, trying to understand if it is possible to resume a download after the loading has been closed.

It doesn't look like it, but I'm still not clear. What do you think? Will Flash now save partially downloaded data, like a browser? (For that matter, I'm not that clear on the relation between browser memory and Flash memory).

The practical implications: if you could partially download pictures or sound in the background, then resume downloading when the users makes a choice, you could make some very snappy interfaces. (Let's say iTunes preloads half a second from twenty focused songs--the songs could start streaming immediately when the user chooses them. Losing that half a second makes for a whole new experience.)

Loving the tips.

Balala 09-25-2006 12:37 PM

Quote:

Originally Posted by Sen
For example, if you started loading a 50 Meg swf into the flash player but wanted to stop it once the user requested different content, you couldn't. The only way to prevent Flash from continuing to load that SWF would be to close the player (i.e. navigate away from that web page).

What if overwrite the MovieClipLoader class?

ActionScript Code:
var mc_load:MovieClipLoader = new MovieClipLoader();
mc_load.loadClip("large_file", target); // start download a 50mb SWF
mc_load.loadClip("small_file", target); // start, and complete download of 200kb SWF
 


It will be, the 50mb SWF download, interrupted?

senocular 09-25-2006 01:31 PM

It is my undestanding that that will not close the original connection.

senocular 09-25-2006 03:24 PM

Timer Class
 
ActionScript 3 introduces a new class to ActionScript called the Timer class (flash.utils.Timer). This class is kind of like a suped-up setInterval (flash.utils.setInterval()) that sends event messages out over a period of time measured in milliseconds. Because it uses events (flash.events.TimerEvent) and not a callback like setInterval, a single Timer instance can be used to call many different functions as long as they are made listeners of that instance. Additionally, Timer gives you the ability to control how many times it repeats, unlike setInterval which repeats indefinitely until clearInterval is used to shut it down, as well as the ability to start and stop the timer on command.

Example:
ActionScript Code:
var timer:Timer = new Timer(500, 10);

timer.addEventListener(TimerEvent.TIMER, notifier);
timer.addEventListener(TimerEvent.TIMER, stopper);
stage.addEventListener(MouseEvent.CLICK, continuer);

function notifier(event:TimerEvent):void {
    trace(timer.currentCount);
}
function stopper(event:TimerEvent):void {
    switch (timer.currentCount) {
        case 5:
            timer.stop();
            break;
        case timer.repeatCount:
            timer.reset();
            break;
    }
}
function continuer(event:MouseEvent):void {
    timer.start();
}

timer.start();

This timer instance sends a TimerEvent.TIMER event every 500 milliseconds and repeats 10 times. There are 2 event listeners responding to these events, one tracing the current count of the timer and the other which will either stop (on current count of 5) or reset the timer (on current count of total count) based on the timer's current count. A mouse click to the stage will allow you to restart the timer as a result of it being stopped in the stopper listener. What you end up getting is
Code:

1
2
3
4
5
(pause; click to continue)
6
7
8
9
10
(pause; click to continue)
1
2
3
4
5
...


senocular 09-25-2006 04:01 PM

AVM2 (AS3) to AVM1 (AS2/AS1) Communication via LocalConnection
 
The ActionScript virtual machine that runs ActionScript 3 code (AVM2) is completely different from the ActionScript virtual machin that runs ActionScript 1 and ActionScript 2 code (AVM1). Because of this, you cannot call commands in an AVM1 movie from and AVM2 movie or vise versa. The virtual machines just are not compatible in that respect and mostly run in their own kind of shell that allows it to only interact with code being played back in that same virtual machine. What that boils down to is that ActionScript 3 cannot talk to AS1 or AS2 - at least not directly.

One thing these two virtual machines have in common is their implementation of LocalConnection. Both virtual machines deal with local connections in essentially the same way - enough that local connections in AVM1 can receive events from AVM2 and vise versa. So should you come into a situation where you would need a movie published in ActionScript 3 to communicate with a movie published in ActionScript 1 or 2, using local connection is the way to go.

Example:
ActionScript Code:
// ActionScript 2 file, AS2animation.fla
// one movie clip animation named animation_mc on the timeline

// local connection instance to receive events
var AVM_lc:LocalConnection = new LocalConnection();

// stopAnimation event handler
AVM_lc.stopAnimation = function(){
    animation_mc.stop();
}

// listen for events for "AVM2toAVM1"
AVM_lc.connect("AVM2toAVM1");

ActionScript Code:
// ActionScript 3 file, AS3Loader.fla

// local connection instance to communicate to AVM1 movie
var AVM_lc:LocalConnection = new LocalConnection();

// loader loads AVM1 movie
var loader:Loader = new Loader();
loader.load(new URLRequest("AS2animation.swf"));
addChild(loader);

// when AVM1 movie is clicked, call stopPlayback
loader.addEventListener(MouseEvent.CLICK, stopPlayback);

function stopPlayback(event:MouseEvent):void {
    // send stopAnimation event to "AVM2toAVM1" connection
    AVM_lc.send("AVM2toAVM1", "stopAnimation");
}


The AS3 movie loads the AS2 movie into a Loader instance and places it on the screen. As it plays, the user can click the animation which calls stopPlayback sending the "stopAnimation" event to the local connection named "AVM2toAVM1". The AS2 movie is then able to receive that event in its stopAnimation event handler and tell the animation_mc clip to stop.

ven 09-26-2006 03:37 AM

How do i turn off strictmode for mxmlc.exe?

In mxmlc.exe -help -list i see compiler.strict and in -help -compiler.strict it says:

-compiler.strict
alias -strict
runs the AS3 compiler in strict error checking mode.


I guess im supposed to understand what to do now, but i dont...

I have tried various ways to edit in the lines in "Myclass.bat" made from senoculars "Make.bat", but nothing seems to work sofar.

icio 09-26-2006 04:25 AM

It would appear that, yes, you are supposed to just know what's happening now. When I read that it sounds like compiling with -strict turns on strict mode and without -strict, strict mode is off. ie, it is off by default.

icio 09-26-2006 04:27 AM

When I read that it sounds like compiling with -strict turns on strict mode and without -strict, strict mode is off. ie, it is off by default.

senocular 09-26-2006 07:50 AM

-strict should be followed by either true or false to set whether or not strict is being used

senocular 09-26-2006 08:43 AM

ByteArray Class
 
ActionScript 3 adds to the Flash player support for working with binary data through use of the ByteArray class (flash.utils.ByteArray). The ByteArray class is a special kind of an array (though is not a subclass of Array (Top level Array)) which holds data (bytes) that relates to data as found in computer memory.

Though the details of this class can go well beyond "tip" status, this tip will simply contain links to examples using ByteArray in interesting ways:

ignitrix 09-26-2006 01:29 PM

Congratulations on reaching your 100'th AS3 tip Senocular. And although I am bummed to hear that they will no longer be released daily, I can't thank you enough for all of your work--it has certainly been an immense help to me and my workflow.

~JC

morri2metri 09-28-2006 03:31 AM

For in _root
 
Hi, All

The for in Statement in flash 8 work fine , in Flash 9 not!!! Why?

for (i in _root){
trace(i); // Moviclip istance in the _root
}

i tired this....but not work Why? :hurt:

for (i in root){
trace(i);
}

Thank's

ignitrix 09-28-2006 07:41 AM

Quote:

Originally Posted by morri2metri
Hi, All

The for in Statement in flash 8 work fine , in Flash 9 not!!! Why?

for (i in _root){
trace(i); // Moviclip istance in the _root
}

i tired this....but not work Why? :hurt:

for (i in root){
trace(i);
}

Thank's

for...in still works just fine. See:
http://livedocs.macromedia.com/flex/...s.html#for..in
However, root no longer exists. See the earlier posts about the "stage".

~JC

morri2metri 09-28-2006 08:39 AM

Quote:

Originally Posted by ignitrix
for...in still works just fine. See:
http://livedocs.macromedia.com/flex/...s.html#for..in
However, root no longer exists. See the earlier posts about the "stage".

~JC

Thank IGNITRIX but....

I have in the stage 3 MovieClip named: mc1, mc2, mc3

In AS2 this work fine es:

for (i in _root){
trace(i); // traced = mc1 ,mc2, mc3
}

in F9 As3 i tried this....

for (i in stage){
trace(i);
}

but not work Why?

Please help me: i want the name of all movieClip in the stage with AS3.

Thank's

senocular 09-29-2006 02:14 PM

properties in classes (which your movie clips are) are not inherently enumerable.

ignitrix 10-03-2006 08:36 AM

Quote:

Originally Posted by senocular
ActionScript 3 introduces a new class to ActionScript called the Timer class (flash.utils.Timer). This class is kind of like a suped-up setInterval (flash.utils.setInterval())...

One of the beautiful things about setInterval was (and is) that you can pass arguments to the activated function when the timer expired:

public function setInterval(closure:Function, delay:Number, ... arguments):uint

Is there a simple way to achieve this same functionality with the Timer class and EventListeners?

~JC

senocular 10-03-2006 09:06 AM

Not really. Ideally you'd just be using this in a class where all the arguments would instead just be variables within that class and accessible from the event handler

dougsha 10-04-2006 10:46 PM

Mr. S,

Thanks much for this thread. Learned a lot.

Here is a bug that's been biting me for a couple weeks. Here's a screenshot of Flex when it errors.
getChildAt_RangeError

The program croaks when measureContentArea (in package mx.containers.utilityClasses, file CanvasLayout.as ) loops through the target's children from 0 to target.numChildren. When the program errors: n == 112, i == 111, and target.numChildren is now 111, when it was 112 before the loop. target.numChildren has changed while the loop is running. It's as if a child was removed by some side effect of calls in the loop.

This baffles me because I don't see how I can debug it. I do add and remove and insert children in my game code, but unless ActionScript is threaded I don't see how my code can reach into a loop in CanvasLayout.as .

The bug is consistent, but I am baffled.

HELP!

D

cr125rider 10-05-2006 02:49 PM

No more "_root"!?!?!? I am gonna mistype that 1000 times before I get used to that! I am gonna write a whole bunch of code an do Find And Replace to have to change it LOL! Thanks for all the tips Sen!

dougsha 10-06-2006 05:37 PM

I found the bug. I was adding a child that already had a parent. I had to release it from it's previous parent first.

Is there a cleaner way of doing it than:
if( newThing.parent ){
CWRoom( newThing.parent )._numKids--;
}
this.addChild(newThing);

dougsha 10-06-2006 05:47 PM

um - that should be:
 
if( newThing.parent ){
newThing.parent .removeChild( newThing );
}
this.addChild(newThing);

visva 10-09-2006 07:24 PM

Synchronous handling of events - is it possible?
 
In Actionscript 3, is it possible to wait till an event occurs - effectively converting an asynchronous call such as a request/response on an HTTPService to a remote procedure call where we only return after the response is received?

Thanks in advance.

jpardoe 10-10-2006 03:17 PM

Off on a slight tangent, but how would I add this class to an existing document?

Say I had 2 AS files - Test.as and Other.as - how would I include them both?

visva 10-10-2006 03:36 PM

Thanks to senocular's sequence class, I found an answer to my previous question about synchronous execution of actions. But I guess there is no real way to 'wait' or 'sleep' in Actionscript, right? If so, is there a reason why they have not provided it.

Regards,
Visva
Quote:

Originally Posted by visva
In Actionscript 3, is it possible to wait till an event occurs - effectively converting an asynchronous call such as a request/response on an HTTPService to a remote procedure call where we only return after the response is received?

Thanks in advance.


Krilnon 10-10-2006 04:22 PM

Quote:

Originally Posted by jpardoe
Off on a slight tangent, but how would I add this class to an existing document?

Say I had 2 AS files - Test.as and Other.as - how would I include them both?

You don't really need to add them to the document, they just need to be in the same folder as your .fla file, or in your classpath. In that case, you could just call both constructors:
ActionScript Code:
new Other();
new Test();


Quote:

But I guess there is no real way to 'wait' or 'sleep' in Actionscript, right? If so, is there a reason why they have not provided it.
Nope, Flash isn't meant to have the sort of low-level control that those methods would give, since those terms are usually associated with threaded applications.

gone2far 10-23-2006 08:19 AM

Edit: Flash 9 Public Alpha doesn't come packaged with these new classes.

Hi,

I've been trying to do some code with the Flash 9 Public Alpha. I've come into some trouble using the Sprite class and the new Display package classes in that they do not exist!!

The compiler keeps throwing an error saying that it can't load the flash.display.Sprite class.

I tried to search for the class and I can't find it. Does anyone else have this issue? I can use the Sprite type in a FLA doc but not in an AS3 class.

Any help appreciated,

ignitrix 10-23-2006 12:24 PM

Quote:

Originally Posted by gone2far (Post 1983698)
Flash 9 Public Beta doesn't come packaged with these new classes.

Yep, it sure does come with them; I use them every day. Use:
ActionScript Code:
import flash.display.Sprite;

For more information, see:
http://livedocs.macromedia.com/labs/...ge-detail.html
and
http://livedocs.macromedia.com/labs/...ay/Sprite.html

Btw, the Player is in Beta mode, the Flash IDE is in Alpha (not Beta).

~JC

K2xL 10-25-2006 09:56 AM

Follow up
 
Quote:

Originally Posted by senocular (Post 1886034)
The Dictionary class (flash.utils.Dictionary) in ActionScript 3 is a new addition to ActionScript. Dictionary objects exactly like generic Object objects aside from one thing: Dictionary objects can use any value as a property name or key as opposed to a string.

Generic objects in ActionScript use string keys (names) for property definitions. If a non-string value is used as a key, the key interpretation is the string representation of that value. Example:
ActionScript Code:
var obj:Object = new Object();
obj["name"] = 1; // string key "name"
obj[1] = 2; // key 1 (converted to "1")
obj[new Object()] = 3; // key new Object() converted to "[object Object]"

for (var prop:String in obj) {
trace(prop); // traces: [object Object], 1, name
trace(obj[prop]); // traces: 3, 2, 1
}



If you attempt to use different objects as keys in generic objects, what you'll get iare string conversions that match each other. That means that though you have used separate objects as keys, to the object container, its the same key and they will reference the same value.
ActionScript Code:
var a:Object = new Object();
var b:Object = new Object();

var obj:Object = new Object();
obj[a] = 1; // obj["[object Object]"] = 1;
obj[b] = 2; // obj["[object Object]"] = 2;

for (var prop:String in obj) {
trace(prop); // traces: [object Object]
trace(obj[prop]); // traces: 2
}




The Dictionary class is not restricted to this limitation. You can have any value as a key and that value will fully represent that key as opposed to the object using its string representation. So in the above example, if a Dictionary instance is used, you would have two separate keys, one for each object.
ActionScript Code:
import flash.utils.Dictionary;

var a:Object = new Object();
var b:Object = new Object();

var dict:Dictionary = new Dictionary();
dict[a] = 1; // dict[a] = 1;
dict[b] = 2; // dict[b] = 2;

for (var prop:* in dict) {
trace(prop); // traces: [object Object], [object Object]
trace(dict[prop]); // traces: 1, 2
}




Though you still get [object Object] in the trace, this is a result of the string conversion in the trace command; it is a unique object key in the Dictionary instance.

Note that prop here is typed as *. This is important as the keys in the dict object can be of any type. If you used String for prop's type, it would cast the a and b objects as Strings when finding them in the loop making prop "[object Object]" instead of actual references to a and b which they would need to be to correctly obtain the values 1 and 2 through dict. For generic objects, regardless of the type used for prop, you will always get a String.

Just a follow up on some info about this Dictionary object. It is exactly the same as the Java equivilanet HashMap. The generic object is smaller in size since the key is always a string. HashMap/Dictionary class is generally larger because the object has to contain an actual object instead of a string.

The reason passing an object above won't work because Object's toString() function returns [object Object] instead of the memory address (which it really should do instead, like java does). Generally in perfect OO no two objects should have the same toString.

-Danny

Kisi 10-26-2006 03:38 PM

Flash 9 SWFs as assets
 
Hello!

I've been trying to create MC's with tweens/animations with the Flash 9 IDE and use the SWF's/MC's in my ActionScript Project in FlexBuilder.



An Example:

Using the AS3 Drawing API i let a vine "grow" dynamically.
Now i want to let grow blossoms. the animations should be drawn in Flash IDE by hand.
i place a "stop();" at the end of the hand drawn growing animation,thus avoiding a repetition of the animation once it has run.


I do the following:

Create the Animation in Flash9 and load the swf via:

Code:

[Embed(source="../../../sources/bluete.swf", symbol="bluete1")]
        private var bluete1:Class;
        private var bluetenContainer:Sprite =new bluete1();

now i can get hold of the mc and use it. the problem: he doesnt recognise the "stop();" , resulting in a loop of the animation.

i could use this ugly workaround:

Code:

private function doEnterFrame(event:Event):void {
        if((bluetenContainer as MovieClip).currentFrame>=55){
        (bluetenContainer as MovieClip).gotoAndStop(56);
        }       
        }

but it only works on the embedded mc's main timeline.


How would you approach this problem? i am sure there must be a better way...

regards,
Kisi

ignitrix 10-26-2006 03:45 PM

Quote:

Originally Posted by Kisi (Post 1986232)
...
Code:

[Embed(source="../../../sources/bluete.swf", symbol="bluete1")]
        private var bluete1:Class;
        private var bluetenContainer:Sprite =new bluete1();

now i can get hold of the mc and use it. the problem: he doesnt recognise the "stop();" , resulting in a loop of the animation.
...

If you're doing things with the Flash IDE (instead of Flex), you should use the Loader class instead of [embed]: http://livedocs.macromedia.com/labs/...ay/Loader.html

Kisi 10-27-2006 06:51 AM

thanks
 
Thanks!

It works.

first i create a swf in flash 9 IDE ,with "stop()"

via

Code:

myLoaderURLRequest=new URLRequest("bluete.swf");
            myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
            myLoader.load(myLoaderURLRequest);

and

Code:

private function completeHandler(event:Event):void{
            myLoader.scaleX*=Math.random()*5;
            myLoader.scaleY=myLoader.scaleX;
            (myLoader.content as MovieClip).gotoAndStop(2);
            trace(myLoader.content);
            myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,completeHandler);
       
        }

i load/control the swf.

seems to work fine, but i am open for suggestions that improve my code.


kisi

emu604 11-11-2006 11:59 AM

SENOCULAR:
Your Stage detection class is nice, but do you have any idea how to detect if a keyframed object gets removed from the stage, say with a blank keyframe? So far, if I don't use actionscript at all, but simply use frames in the timeline, only Event.ADDED gets called (and NOT for all), and Event.REMOVED is never called. Do you know any way to get around this limitation? It seems that once a MovieClip has been keyframed, it doesn't get "removed", but rather gets put into some sort of storage area. And calling stage.contains() on that movieclip, even though it is no longer keyframed, still returns true, so it IS a child or grandchild (or more distant descendent) of the stage. So how to whether a DisplayObject is on the stage IN THE CURRENT FRAME?

I think adobe should give us more insight into the workings of the timeline object, whatever that may be. assets seem to come and go visually, but we get little indication of this via actionscript. Perhaps I have to write my own contains() function, taking numChildren and getChild() as my basic method, since contains() can be misleading when dealing with frames.

Kisi 11-14-2006 06:20 AM

getDefinitionByName and EMBED
 
Hi everyone!


I am trying to use getDefinitionByName in order to create a new instance of an embedded class. i get a runtime error, complaining that :

Code:

ReferenceError: Error #1065: Variable BluetenBild1_3 is not defined.
    at global/flash.utils::getDefinitionByName()
    at de.kismael.bio::Bluete$iinit()
    at de.kismael.bio::RankeKlein/::doEnterFrame()

Code:


package de.kismael.bio

{
import flash.utils.getDefinitionByName;

public class Bluete extends Sprite{
   
        [Embed(source="/sources/animierteBlume1.swf")]
        private var BluetenBild1_1:Class;

        public function Bluete(){
        var nameTemp:String="de.kismael.bio.Bluete::BluetenBild1_"+Math.ceil(Math.random()*4);
                    var tempClass:Object =getDefinitionByName(nameTemp);
                    dasBluetenBild=new tempClass();
        }
}}


how should i use those embedded classes, ive got many of them and don't want to write a SWITCH ...

any tipps?

thanks a lot,
kisi

Fingers 11-20-2006 03:04 AM

Quote:

Originally Posted by Senocular

You should be able to use the classes from the Flex SDK. Just download them somewhere on your computer and specify the location of the folder with the mx directory in your Flash preferences class path.

Quote:

Originally Posted by devonair
Just gave that a go... I had to comment out the includes and delete all references to the mx_internal namespace (Senocular probably knows a more elegant method of "fixing" these things, I'm more a slash and burn kinda guy) and came up with this:

http://www.onebyonedesign.com/flash/f9/tween/ (click on the circle)

Code:

package com.onebyonedesign.tests {
 
 import mx.effects.*;
 import flash.display.*;
 import flash.events.*;
 import mx.effects.easing.*;
 
 public class TweenTest extends Sprite {
 
  private var _circle:Sprite;
 
  function TweenTest() {
  stage.frameRate = 31;
  init();
  }
 
  private function init():void {
  _circle = makeCircle();
  _circle.addEventListener(MouseEvent.MOUSE_DOWN, tweenMe);
  }
 
  private function makeCircle():Sprite {
  var s:Sprite = new Sprite();
  s.graphics.beginFill(0x660000);
  s.graphics.drawCircle(20, 20, 20);
  addChild(s);
  return s;
  }
 
  private function updateTween(vals:Array):void {
  _circle.x = vals[0];
  _circle.y = vals[1];
  }
 
  private function endTween(vals:Array):void {
  trace ("ending coordinates: " + vals);
  }
 
  private function tweenMe(e:Event):void {
  var myTween:Tween = new Tween(_circle, [_circle.x, _circle.y], [275, 200], 1000, 31);
  myTween.easingFunction = Elastic.easeOut;
  myTween.setTweenHandlers(updateTween, endTween);
  }
 }
}

the cool thing is that we can now add arrays of properties instead of doing one at a time.. Disco...

EDIT:
Thank you for these tips, Senocular.. Great thread and some great info...

Please forgive my ignorance as I've only just started learning AS 3.0. I have been experimenting with Flex Builder 2 the last few days, trying to write pure actionscript projects, which is rather alien to me as my experience with OPP up to now has been minimal. One thing that strikes me as odd is the extra steps you have go through in order to do tweens. I was hopelessly stumped until I read this thread.

The above code works, so long as two swc files are added to the Flex's actionscript library build path, which I only just discovered. Anyway, on to my question. What I am wondering now is how to rewrite the code so that I can simply pass as a reference any display oject I want to tween to the the tweenMe function (and related functions).. I'd like to be able to say something like.. _circle.addEventListener(MouseEvent.MOUSE_DOWN, tweenMe(this)); or... _someOtherCircle.addEventListener(MouseEvent.MOUSE _DOWN, tweenMe(this)); Can someone please explain?

Fingers

Fingers 11-20-2006 11:45 AM

I've started a separate thread about my last question, if someone would still like to help.

:)

tpspoons 12-24-2006 06:06 AM

Is there an alternative to previousSibling and nextSibling in as3?


All times are GMT -7. The time now is 10:34 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.
Copyright 2004 - kirupa.com