Okay, I will begin be mentioning I am pretty new to flash, however I have a decent amount with other programming languages like c++, c#, vb, pl/sql, coldfusion, and some others so I feel comfortable jumping right in.
I do understand a lot of the basics in flash, but I am starting a project in as3 that I am having some issues with.
(I would attach the fla, but it exceeds the file size limit with the png file attached)
//import slider classes
import fl.controls.Slider;
import fl.events.SliderEvent;
import fl.controls.Button;
//instantiate slider
var s:Slider = new Slider();
// control if slider updates instantly or after mouse is released
s.liveDragging = false;
//set size of slider
s.setSize(550,15);
//set maximum value
//position slider
s.move(25,10);
s.maximum = 8;
//set mininum value
s.minimum = 1;
//set tick position interval, you do not have to set this
s.tickInterval = 1;
// this is a listener that broadcasts evertime an event changes
s.addEventListener(SliderEvent.CHANGE, announceChange);
//add slider to stage
addChild(s);
//build the 4 buttons
var uB:Button = new Button();
var dB:Button = new Button();
var lB:Button = new Button();
var rB:Button = new Button();
uB.name = "uB";
dB.name = "dB";
lB.name = "lB";
rB.name = "rB";
uB.label = "UP";
dB.label = "DOWN";
lB.label = "L
E
F
T";
rB.label = "R
I
G
H
T";
uB.width =600;
dB.width =600;
lB.width =22;
rB.width =22;
uB.emphasized = true;
dB.emphasized = true;
lB.emphasized = true;
rB.emphasized = true;
uB.move(0,30);
dB.move(0,608);
lB.move(0,54);
rB.move(578,54);
uB.height = 22;
dB.height = 22;
lB.height = 552;
rB.height = 552;
uB.addEventListener(MouseEvent.CLICK, buttonClick);
dB.addEventListener(MouseEvent.CLICK, buttonClick);
lB.addEventListener(MouseEvent.CLICK, buttonClick);
rB.addEventListener(MouseEvent.CLICK, buttonClick);
addChild(uB);
addChild(dB);
addChild(lB);
addChild(rB);
//idea borrowed from [starsoccer10921](http://www.kirupa.com/forum/member.php?u=97058) in another thread
var img:zMap = new zMap();
img.height = 550;
img.width = 550;
addChild(img);
img.x = 23;
img.y = 55;
//gets called on change
function announceChange(e:SliderEvent):void
{
trace(e.value);
}
function buttonClick(e:MouseEvent)
{
trace("Button: " + e.target.name + " was clicked!");
}
Thats what I am working with.
I have symbols defined for all the items in the library. The zmap is imported png map file I have made and is set as a movie clip and checked off the appropriate export options in linkage.
Now for the problems.
-
The slider Bar
when i move the slider, I get the results I am expecting (trace output) but the slider creates a new handle at any point I stop sliding at. (after transplanting the code into a new project, this error was fixed, so not sure what happened or why but no longer an issue.) -
Not sure the best way to approach the rest of the problem.
I am looking to perhaps re-size the image based on the position of the slider bar. (zoom feature)
I am also looking to move the map around based on the button pressed.
Due to the size of the image I want to limit the drawing to whats on screen as the original image is 2014*2014.
I have seen some great examples of pan and zoom… but none of them have the control I am looking for.
Out of a curiosity I haven’t done much searching on this yet, but someone who knows these forums well, or others, could you link some threads that have good examples of including a psd file. Originally the map I’m working with is done in ps cs4. (and I am working with flash cs4)