I officially decided that time had come to move into a new era of programming, Reflektions | miniml will now switch to AS3. The holidays are here and time has come to start thinking of new year resolutions, and I thought this would be a good one.
I have been coding in AS3 for over a year now, although I always maintained that AS3 is too new for the sites audience and might be complicated for beginners. A quick look over to my google stats in conjunction to recent comments and I realized time had come. Anyways I was getting tired of always switching my code to AS3 for internal use.
Bellow is a first experiment, actually its my AS3 slider class. Since I end up using the slider on almost all my experiments, I decided to start by coding it and making it available. All future experiments will use this class for the slider. Instantiation is done as follows, and we get the slider value using the static method sliderVal(). As you will see in the class code, other static methods let us change color, widths, height and init value.
//create new instance
var slider:Slidebar = new Slidebar();
//Add to display list
addChild(slider)
// get slider value (0-100%)
trace(Slidebar.sliderVal)

Campbell Anderson said...
Welcome to the dark side Paul, your powers will be strong ;)
Dustin+Senos said...
Right on. Looking forward to what you come up with taking advantage of AS3.0
Lee said...
Muahahaha, now our transformation is complete! The world will be ours!!! muahahaha!
Yay
Keith Peters said...
Dude, AS3 is not the dark side! Step into the light! :)
Seriously, though it may be a bit more work, once you are used to AS3, working in AS2 will leave a very bad taste in your mouth.
julien said...
Cool, can't wait to see your AS3 code :)
alex said...
Lovely - but, just to let you know i have tried out this class and i am getting the following error - 1151: A conflict exists with definition slider in namespace internal. - i changed the instantiation to …
var myslider:Slidebar = new Slidebar();
trace(myslider.sliderVal)
and now i get the following error…
1180: Call to a possibly undefined method addFrameScript.
Doug McCune said...
I can't believe you've held out coding AS2 for so long. Thinking about going back to AS2 is like thinking about going back to CSS cross browser incompatibilities for me, I shudder at the thought.
Looking forward to some sweet AS3 experiements.
paul+Ortchanian said...
Sorry Doug, I forget to mention, this class is not a document class, as a matter of fact you should not have one set. This is simply and external class that should reside in the same directory as your fla.
alex said...
Cheers paul :-) i figured that out finally, after i got it working as a document class! - however, now i have just used the instantiation as you have written it, i do not get to see the slider - the call to sliderVal works - i get 100 back, but i do not physically see the slider, or line, and cannot see anything in the debug menu - no objects etc - very weird. Any thoughts?
paul+Ortchanian said...
Sorry alex :
addChild(slider);
this should work
alex said...
Thanx paul - all works now - boy do i feel like an idiot :-) No matter how many times i use as3 i keep on forgetting addChild() - it comes from having had to do so much as2 in the past that i just have a blind spot where this is concerned.
Vincent Legault said...
Hey Paul, I'm walking the dark path also. It's been 2 month now and I must admit, AS3 is easier then I first thought. Many thing are simplier but other thing doesn't make much sense after working so much in AS2. Looking forward your next experiment.
Happy Holidays Paul
Lowell said...
Hi paul,
I can get code to work if I comment out the trace statement, otherwise I get a compiler error of 1119: Access of possibly undefined property sliderVal through a reference with static type Class.
Arestic said...
nice script it is usefull.
u-i said...
Hi Lowell,
you get this error coz sliderVal is not static function in this code. Just use slider.sliderval and it will work
alex_s said...
Greate Stuff!!!
Two questions: 1) Hou to pass initVal and other initialization params?
2) Is there code for this (slidebar) class in AS2?
Thank you much!
paul+ortchanian said...
Hi Alex,
The class is in AS3, as you can see above. The init is done via Static setter variables. ex: Slidebar.slideWidth = 200
noponies said...
Nice class, handy and well conceived.
Cheers!
russ said...
hey, first off, thanks, your website is great for those of us learning as3..
but I can't seem to get your slidebar to work.. I get error1170, function does not return a value on line 266... am I making a stupid mistake..
all I tried doing so far was importing it, creating it and adding it to stage.. is there more to it.. thanks again..
paul+ortchanian said...
import com.reflektions.userInterface.*; // import slider
var slider:Slidebar; // Slider
// Set initial value
Slidebar.initVal = 20;
// insantiate
slider = new Slidebar();
// Add slider to display list
addChild(slider);
russ said...
i used the code you just posted above.. and i still get the same error. i didn't change the class at all.. do I also have to set slider x position..? i tried that and i still get the same error.. i'm going to redownload the class and try again.. thanks
çocuk oyunları said...
russ said...
hey, first off, thanks, your website is great for those of us learning as3..
but I can't seem to get your slidebar to work.. I get error1170, function does not return a value on line 266... am I making a stupid mistake..
all I tried doing so far was importing it, creating it and adding it to stage.. is there more to it.. thanks again..
Jolin M said...
I get the same error (1170, when putting the code
import com.reflektions.userInterface.*; // import slider
var slider:Slidebar; // Slider
// Set initial value
Slidebar.initVal = 20;
// insantiate
slider = new Slidebar();
// Add slider to display list
addChild(slider);
in a new .fla file, in the same folder than the as. Anyone know where is the bug?
Steve said...
Having the same problem too. Is this not going to be fixed?
tatil said...
Hi Alex,
The class is in AS3, as you can see above. The init is done via Static setter variables. ex: Slidebar.slideWidth = 200
lelyfay said...
Can these codes be used with Flash 8?
LiFTED said...
Hey Paul... big fan of all your stuff... but this sliderbar does not seem to work... whats the deal??... I am getting the same error as the people above and there doesn't seem to be any real solution posted here?... any input on how to solve this issue(error 1170:function does not return a value)
I have downloaded your classes and not modified them in any way... your help would be much appreciated!
submed said...
var slider:Slidebar; // Slider
// Set initial value
Slidebar.initVal = 20;
// insantiate
slider = new Slidebar();
// Add slider to display list
addChild(slider);
that's error
Jim said...
When I try to use this it says that that the function (the very bottom one) does not return a value.
James Star said...
Hey, I found if you take the second :Number from the bottom function, setSliderX, it works great. Just my 2 cents.
Music Reviewer said...
Nice class, handy and well conceived.
Thanks
Steve said...
Can anybody help me out of the 1170: Function does not return a value.
Rich+Sadowsky said...
There is an error in the code.The method setSliderX should be declared as returning void.I fixed it by changing the method definition to:
private function setSliderX(percent:Number) :void {
//function code unchanged
}
screensaver maker said...
it comes from having had to do so much as2 in the past that i just have a blind spot where this is concerned.
montana said...
hi Paul, thank you for your great experiments. you deserve more than a beer - as soon as I get some extra cash you're on my list. Couple of things,
I'm having some issues with hit points I'm adding to the slider I have a series of points distrubuted along the slider that fire off events (moving some images along a path) but I'm noticing that using shape MOUSE_OVER events seems to have a real lag and the overall effect is a bit damp. I've tried a couple of different approaches including using an array of interval points and testing slider x position, and adding 2x20 sprites distributed at correct points along the line. both are pretty bad. any suggestions?
I can send you the source since I've pretty well chopped the Slider class by now =)
dbam said...
I just gave it a quick try, and obviously the download link above of the "/uploads/com.reflektions.userInterface.zip" file doesn't contain the same source as the "codeviewer" at the final of the post.
Copy-pasting the code from the page although works great / has the setter returning value bug and the slider-rectangle/mouse relation fixed!
You DEFINETLY saved me dev-minutes!
Thanks for sharing!
Ruth said...
Hi,
I'm sorry. I'm totally new to Actionscript 3.0. I'm trying my best to learn it though.
I've been trying your code. I keep getting errors. The first is: 1172: Definition com.reflektions.userInterface could not be found. I copied all your code for the accordian and I made the AS file for the Slidebar class. What am I doing wrong? Please help.