Archinect
anchor

In search of a Flash/ActionScript Guru...

lletdownl

Hey everyone,

So, if youre doing a website with flash... or you enjoy messing with it... or maybe you have some sweet physical computing project in flash...

whatever it is... if you can write or want to write code in AS, post something!

Perhaps a question? or a concept you dont quite get... i know i have many, and will be posting my own.........




now

 
Dec 16, 09 9:47 am
lletdownl

so...

i have some possible topics but im gonna wait to see if anyone does any flash at all... or if i am truly alone in this world...

Dec 16, 09 10:30 am  · 
 · 
tinker10

why you looking for flash guru on archinect is beyond me, since there are tons of tutorials else where, just google.

one of the best place to start is:

http://www.developphp.com/list_flash_video.php

adam is AS3 god!

Dec 16, 09 12:23 pm  · 
 · 
lletdownl

i know there are tons of tutorials out there... trust me... ive seen them all... its how i learned...

i was just hoping there was an architect interested in flash as well... seeing as im already established on this forum, its much easier to have conversations... you might notice that breaking into a forum, and getting positive and respectful responses to questions which might sometimes be rudimentary is very, very difficutl...

i need to get up to AS3 though... im still in AS2

Dec 16, 09 12:40 pm  · 
 · 
tinker10

i didn't know you need to "break" into a forum.
the clearer you ask the question the better chance you will get the right answers. i don't think it has to do with how long you have hung around in a forum... i don't think people will disrespect you just cause you are a newbie at a forum.

i did my site in AS3 with alot of help from developphp.com
i am no guru, but it was at times fun at time painful learning AS3 having done AS1&2 in the past. so give it a shot, what can you loose?

Dec 16, 09 1:00 pm  · 
 · 
lletdownl

its already done... i shooting now...

and yes... people do discount your threads when youre new... there is a break in process when the forum is tight nit...

as for AS3, how closely related are listener functions in AS3 compared to AS2? If they are similar, and you are pretty hand with them, i might have a question for you...

Dec 16, 09 1:06 pm  · 
 · 
tinker10

by that logic, are you discounting my responses?

you are either very shy or terribly polite...

i can not answer w/o knowing the question...

but AS3 is a complete new animal compared to AS2, it would help with the transition a great deal if you know javascript. I would say 50-75% of the old script commands has been replace with this new logic.

Dec 16, 09 1:20 pm  · 
 · 
lletdownl

haha, no im not discounting your responses... archinect is a un-naturally nice and receptive place in comparison to other forums i think...

ive heard that about AS3, and when reading AS3 code, it is some serious work to translate it back to AS2. ok, for instance... in my code here...


var empty = this.createEmptyMovieClip("container", 1);

mc_EC = new MovieClipLoader();
preload = new Object();
mc_EC.addListener(preload);
preload.onLoadStart = function(targetMC) {
_root.mc_projects.mc_projectsLoaded.mc_loadText._visible = true;
};

preload.onLoadProgress = function(targetMC, lBytes, tBytes) {
_root.mc_projects.mc_projectsLoaded.mc_loadText.loadText.text = "% "+Math.round((lBytes/tBytes)*100);
};

preload.onLoadInit = function() {
container._y = 25;
container._x = (Stage.width/2)-(empty._width/2);
};



it works fine, it does exactly what i want it to do, but as is sometimes the case with code... im not exactly sure WHY it works, which makes it more difficult for me to tweak this particular set of instruction.

lines 2, 3, and 4 are things i have difficulty understanding their meaning... what does "preload = new Object()" really mean and what does its being added as a listener to mc_EC actually mean...

Dec 16, 09 1:30 pm  · 
 · 
tinker10

if i am reading this correctly, you are loading a internal clip on to the stage w/ a preloader % display and specified location onto the stage.

for preload & mc_EC you are simple setting up identifiers.

mc_EC.addListener(preload);
here you are setting a perameter to call the object. and when to call the object is identified as onLoadStart.

then you are preloading the clip targetMC, in this case its displayed or =true, the identifier.

like i said i am no guru, but i know that something like this can be done in various ways depending on how easily you want to beable to change things down the line. there is alot of trial and error by changing parameters to see if the code works or work differently. in fact, thats how pros does it too.

the power of AC3 is if the code works and does what you want to do it manipulation can be done w/o doing any key framing.


Dec 16, 09 2:38 pm  · 
 · 
lletdownl

yeah, i try to avoid key framing as much as possible, but for button classes and other movie clips animated in flash, is still do time line work...

as for your statement,.... youre right... thats a pre loader for images im loading dynamically...

_root.mc_projects.mc_projectsLoaded.mc_EC.loadClip("IMAGES_NEW/K STREET/1.jpg","container");

thats an example of how im calling an image after that preloader... so i think i get how this works now...

tell me if this is right...

basically, im attaching this preload object, to mc_EC.... sort of like mc_EC.preload.whatever...

preloads behavior can change depending on what portion of the loading process i am in...

basically, it means that any image of .swf i load into mc_EC will have to go through the preload process....

im still not certain about what exactly the point of the "listener" thing is supposed to do...

is the listener identifier the thing that tells X.jpg being loaded in mc_EC what the current status of the object Preload is?

Dec 16, 09 2:49 pm  · 
 · 
tinker10

i see, so you are doing a "shell preloader" which i tried on my site and didn't like how it show the preloader every time even if the swf is already loaded.

i instead, added preloader onto each individual swfs to gain better control.

you are also doing some sort of random "slideshow" or you want to show different image every time someone visits or click on a button. believe or not i was trying out the same thing, but it involves an XML data file as well. i had it working, but thought it was easier to manage if i find an alternative to do it only in flash, which i did. check here if this is something you want to achieve. (just keep clicking on the "tinker" button)

i just noticed your "addListener" commend is AS2, I believe it is replaced by "addEventListener ()" are you sure you are coding in AS3?

Dec 16, 09 3:46 pm  · 
 · 
lletdownl

yeah, i agree on the downfall of the preloader for every .jpg... that part is a bit inconvenient, though once you click back onto an image thats already loaded, it reloads almost instantaneously...

basically, that code is part of a template... there are about 60 projects were showing images for, and each project gets its own .swf.

this code is in the swf, and links to .jpgs i keep on the server in the same directory. Its great in that each project swf basically ONLY has the opening image and the thumbnails(buttons)... so the project pages load super fast... its bad though that you have to wait a bit for each image to load... for my purposes though, its the best method...

previously, i made 1 swf file per project but included all the images at once... making each .swf pretty hefty... sometimes up to 6mb...

this was great in that once the project loaded, you could view all the images with no lag... but download times were just way too long...

anyway, i like your site... the slider you have set up is interesting as well...

a couple questions... are all those images in one movie clip which youve masked? basically creating a big panel of images that slides back and forth? Also, whats the resolution on your images... pixels and dpi...

as for action script... i thought i mentioned that... i am in AS2... im not familiar or comfortable enough with AS3 yet to do a site in that language... especially not for my work...

Dec 16, 09 4:00 pm  · 
 · 
tinker10

i see, yes you mentioned that your still on AS2, but i interpreted as you want to "get up to AS3..."

anyway, i pretty much skipped AS2 and did the whole thing in AS3.

the whole site is just a container, loading & unloading swfs, but each section is 1 swf with a big "banner". was it pretty smooth loading? it was launched just a couple weeks ago.

the "stage" area is 700x500px, so everything is sliding in the 700px increment. if you "save as web" in Photoshop the dpi is almost a none issue, you control the quality when you save as web, and most of the images are under 50k. when exported from flash, you can again adjust the quality via "publish." the largest swf i have is about 750k with 15-20 images, so i think i optimized to almost the maximum extend.

the randomizer for the various images (tinker button) is so simple to make that i ditched the dynamic loading headach. it contains 16 images which i can add or replace with ease.



Dec 16, 09 4:21 pm  · 
 · 
lletdownl

yeah, im doing the same thing... i think thats how most flash sites a see are set up... one index which handles all the satelite .swfs...

this has turned into a pretty huge project for me... graphically, its easy to underestimate the amount of work that goes into creating a website thats so image heavy... formatting, arranging blah blah blah...

anyway... ill have another flash coding question tomorrow...

Dec 16, 09 5:30 pm  · 
 · 
tinker10

of course! why did you think web design firms can charge 10-30g for them.

btw, i assume you know how to record actions in photoshop? it may help streamline the imagine formating process.

Dec 16, 09 7:06 pm  · 
 · 
lletdownl

yeah, batch processing helps alot... especially when creating thumbnails and what not...

Dec 16, 09 7:23 pm  · 
 · 
chupacabra

wow...what a thread. anywho, ill bite. As some know on here my pre architect incarnation was as a graphic designer and web developer. Flash as been moved to the mode of sexy power point. That said I have moved to custom coding through the slideshow tool...makes for some great non linear diagrams. On top of that I have taken to Googles open source classes that make coding for AS much simpler in regards to creating basic interaction and effects...much better than the classes that come with flash.

The classes are called tweener and work in javascript, actionscript, python, c++. They are very elegant and quite a wonderful tool for those looking to extend their basic interactive toolset

http://code.google.com/p/tweener/

Dec 16, 09 8:23 pm  · 
 · 
tinker10

lletdownl,
i think your help has landed....chupacabra maybe the guru you seek :)

are you a AS3 guru chupacabra? where were your when I was doing my site?

Dec 16, 09 10:14 pm  · 
 · 
tinker10

i see thats where the caurina.transitions i used on my slider came from!

Dec 16, 09 10:18 pm  · 
 · 
trace™

I stopped coding a long time ago, my programmers are just so much better than I have patience for. Sorry, no help.

I can post sites, but I assume you already know them...?


Make sure you look at www.favoritewebsiteawards.com for some of the best Flash work out there.

Dec 16, 09 11:07 pm  · 
 · 
tinker10

trace started it...

a site from the flash glory days which I always liked for obvious reasons:

http://www.eccentris.com/splash.htm

try the none low bandwidth version.

Dec 17, 09 12:12 am  · 
 · 
lletdownl

interesting chupacabra, ill check that out today...

as for tuturial sites... i found the most help for flash stuff at

http://www.republicofcode.com/tutorials/flash/

http://www.gotoandlearn.com/

and of course...

http://www.kirupa.com/developer/flash/index.htm



heres a flash code question for today...


here is a super simple function im using for fading in and out different movie clips...

function fadeIn(target) {
target._alpha = 0;
onEnterFrame = function () {
target._alpha += 7;
if (target._alpha>=100) {
target._alpha = 100;
delete onEnterFrame;
}
};
}



so, my question is... how come when i call it, it can only be called one time from an action...

for instance...

mc_butText.onPress = function() {
_root.fadeIn(_root.mc_menus.mc_MainEmpty);
_root.fadeIn(_root.SomeOtherClip);
}



if i run that code... SomeOtherClip will run the fade in function, but mc_MainEmpty will not execute fadeIn... i dont see what in my original function would preclude me from running it on several movie clips with one press, roll over, roll out...whatever...

Dec 17, 09 9:39 am  · 
 · 
chupacabra

I would presume that it has something to do with how you are referencing the targets. Your scope is singular - you need to prototype it if you want to use it at the class level - such as:

MovieClip.prototype.fadeTo = function(value, speed) {
this.onEnterFrame = function() {
this.aV = Math.floor(value-this._alpha);
this.aV ? this._alpha += this.aV/speed : (this._alpha=value, delete this.onEnterFrame);
};
};

Then I refer to it via the element I want to edit...such as this code that allowed for me to click some keys to fade a movie in and out without need of tweening via the timeline. Tweener does this much better though. You just add the caurina class and you can easily make much more fluid scripted transitions without the need of doing your own prototyping. Why manage your own framework when there is an open source one being developed by a much larger community than one.

here is how I accessed that code:

var keyBtn:Object = new Object();
keyBtn.onKeyDown = function() {
if (Key.isDown(100)){
mov1.fadeTo(0,10);
mov2.fadeTo(100,10);
}
if (Key.isDown(101)){
mov1.fadeTo(100,10);
mov2.fadeTo(0,10);
}
};
Key.addListener(keyBtn);

best of luck!

Dec 17, 09 10:24 am  · 
 · 
lletdownl

hey chupa, i checked out and downloaded that Tweener class stuff... is there a place i can see examples of its use? visually and in code? i didnt see it on that website you linked...

Dec 17, 09 10:24 am  · 
 · 
chupacabra

I would be careful with going to too many flash tutorial sites as there are a million ways to skin a cat and not all are of best practices. I would look at the standard bearers such as colin mock and others associated with flash back when it was still in the hands of macromedia. I started using it when it was pre macromedia and out of a little office in San Francisco and was called future splash. how time flys.

Dec 17, 09 10:26 am  · 
 · 
chupacabra

Here is me loading into my first frame of my root movie

import caurina.transitions.Tweener;
var keyListener1:Object = new Object();
myTime = 2;



keyListener1.onKeyDown = function() {
if (Key.isDown(73)&&Key.isDown(107)){Tweener.addTween(INTRO.Title.blurb.b1, {_alpha:100, time:myTime});}
if (Key.isDown(73)&&Key.isDown(109)){Tweener.addTween(INTRO.Title.blurb.b1, {_alpha:0, time:myTime});}
};
Key.addListener(keyListener1);


It is very much the same as above...but you will notice some semantic differences to how I execute the same effect and also notice the absence of the prototyping code...as I am not using that any further. I is also nice to have these elements attaced to my file externally so as to allow for endless reusing of the tweener code as opposed to developing your own prototype for every movie.

Dec 17, 09 10:29 am  · 
 · 
chupacabra
http://www.webdevils.com/?p=66

you link to the external files...he explains it on the site.

Dec 17, 09 10:31 am  · 
 · 
lletdownl

i really need to get up to AS3... unfortunately... since im already in the middle of a site... it will have to wait...

chupa, thanks for this stuff... its way over my head, but at least now im aware of it...

Dec 17, 09 10:37 am  · 
 · 
lletdownl

so... guys, im hitting a bit of a snag on this fadeIn function...

how can i change this function to opperate only IF target._alpha=0



function fadeIn(target) {
target._alpha = 0;
onEnterFrame = function () {
target._alpha += 7;
if (target._alpha>=100) {
target._alpha = 100;
delete onEnterFrame;
}
};
}


i tried a million variations... and this works, but for some reason the actual fade doesnt occur... it seems to be skipping the incremental fade and setting

function fadeIn(target) {

if (target._alpha<100) {
target._alpha=0;
onEnterFrame = function () {
target._alpha += 7;
};
} else if (target._alpha>=100) {
target._alpha = 100;
delete this.onEnterFrame;
}
}


any suggestions?

Dec 17, 09 1:38 pm  · 
 · 
LML

I'm becoming a fan of tweenlite. AS3

Dec 18, 09 6:54 pm  · 
 · 

Block this user


Are you sure you want to block this user and hide all related comments throughout the site?

Archinect


This is your first comment on Archinect. Your comment will be visible once approved.

  • ×Search in: