Buttons and ActionScript Code
Hi everyone just signed up to this forum today, really need help, would appreciate your help.
Basically I have created 5 buttons on one single layer. I am now trying to link each button to a website, but to no success as of yet.
I realised that maybe in order to make it easier for myself I need to put each button in its own layer and insert the following actionscript code I've inserted for one of my buttons:
stop()
home_btn.addEventListener(MouseEvent.CLICK, mouseClick);
function mouseClick(event:MouseEvent):void
var request = new URLRequest("http://www.sign-technologies.net/");
navigateToURL(request,"_blank");
This code links my first button "home_btn" to my site, which is still underconstruction. When I run it in flash it works, but when I click the button in the actual web browser it will not go to the webpage, so I'm stuck.
Another question: For convience sake is there a way I can have all the buttons in one layer, but insert code that can seperate one button from the other? Anyone have that code?
You can place all of your buttons in one layer and all of your code preferably in another layer. What you will need to do is have differently named functions for each button. You can not name them all "mouseClick"... I'll suggest you name the function in relation to the button, as in....
home_btn.addEventListener(MouseEvent.CLICK, homeClick);
function homeClick(event:MouseEvent):void
var request = new URLRequest("http://www.sign-technologies.net/");
navigateToURL(request,"_blank");
As far as the file not working when testing in a browser, it should. There is nothing wrong with the code.
There are other ways of coding where you can have the same function shared by all the buttons, but that might be a better lesson for another day.
Similar Messages
-
Resources,tutorials, samples and actionscript code free
Hello:
Do you know some cool webs, samples, resources, code and
tutorials to
download?
Thank you.Hi,
I'm a little lazy right now, and I can't add "www." and ".com" to every link. So please bare with me. You can paste the data here in a browser, and click CTRL + [enter]. (Links other than ".com" are mentioned, so dont worry).
techiwarehouse
flashkit
kirupa
acrionscript.org
flash-db
flashadvisor
flashbuttons
poqbum
flzone
flashguru.co.uk
flash-creations
tutorials.flashvacuum
swftools
tutorialdash
permadi
flashjester
flash-applets
peachpit
flashscript.biz
webwasp.co.uk
experiments.flashmatics.co.uk
flvskins
vtc
flashloaded
theflashblog
communitymx
flashwanted
designorati
flash8.betaruce
fumiononaka
flashvalley
tutorialized
3dnirvana.blogspot
Some of my favorites. There are more online. -
Mute and unmute button is actionscript 3.0
Hi,
I am wondering how to make a mute and unmute button is actionscript 3.0. I did it before in actionscript 2.0 but not in 3.0.
Here is my actionscript 2.0 code.
var sound = 1;
var slashMC = _root.attachMovie("slash","slash01",99);
slash01._visible = false;
slashMC._y = btn._y;
slashMC._x = btn._x;
var s:Sound = new Sound();
s.attachSound("Gravy");
s.start(1,999);
btn.onPress = function(){
if(sound==1){
s.stop();
slash01._visible = true;
sound = 0;
else if(sound==0){
sound = 1;
slash01._visible = false;
s.start(1,999);
ThanksTry this:
import flash.display.MovieClip;
import flash.events.*;
import flash.media.*;
import flash.net.URLRequest;
var isPlaying:Boolean = false;
var snd:Sound = new Sound();
var channel:SoundChannel = new SoundChannel();
var pos:Number = 0;
var soundVolume:Number = 1;
snd.load(new URLRequest("something.mp3"));
btn_Stop.addEventListener(MouseEvent.CLICK, stopMusic);
btn_Stop.buttonMode = true;
btn_Play.addEventListener(MouseEvent.CLICK, playMusic);
btn_Play.buttonMode = true;
function stopMusic(evt:Event):void
channel.stop();
pos = 0;
isPlaying = false;
function playMusic(evt:Event):void
if(!isPlaying)
channel = snd.play(pos);
btn_Play.visible = false;
btn_Pause.visible = true;
isPlaying = true; -
Photoshop Elements 12
Adobe Photo Downloader has encountered a problem and needs to close. We are sorry for the inconvenience.
Error Code: c0000005
Address: 75e32f71
I clicked on the OK button and the downloader closed.
I did a search on this error code (c0000005) and there seems to be a workaround but no solutions, why is this? I ask that because this problem seems to be years and years old, going back to at least 2005 (do the math that is 10 years).
I don't even have the Camera hooked up and I get this error on download. I redownloaded everything and reinstalled. I allso saw the AVI issues reported with this proble so i updated Quicktime though without the camera being hooked up when I get this error I didn't expect that to work. I tried support and they wouldn't help because I bought it in March this year. Pretty frustrating as I have re-purchased Elements about every 2 years. I think I might need a new CODEC? I had this problem on an Earlier version And I seem to remember that being the Fix but this may be something completely differentI finally found that it was missing a picture so the Catalog was "corrupted". I just deleted the picture and it started working.
I hate Adobe and their total lack of support - thanks for nothing Adobe . Also get this - they offered me to upgrade to 13.0 ( My 12.0 is only 6 months old but they still don't support it on errors. Only install errors!
I have upgrade and repurchase this product 4 times now. I will find something else next time! -
The display on my iPod Touch is HUGE and I have no idea why. I tried the HOME button and power button at the same time.....no help. I cannot enter my unlock code because I can't scroll without entering a wrong number! HELP!!
Using three fingers, double-tap the screen.
http://support.apple.com/kb/TS3129 -
Facebook like button is not working, I have used the muse widget and created code from facebook. Does anyone know how to get this to work?
Hi connally25,
Below is a link to a video tutorial on how to add a Facebook Log button, please check if you have followed the same steps to add the video.
http://tv.adobe.com/watch/learn-adobe-muse-cc/adding-a-facebook-like-button/
If you have followed the steps correctly and the button still does not work; here is a link to a forum thread which might help solving the issue:
Facebook Follow Widget not working
Regards
Sonam -
Trying to use Buttons and keep getting an error code
I am trying to use buttons and I keep getting the error code ReferenceError: Error #1074: Illegal write to read-only property graphics on flash.display.MovieClip.
There is one button that doesnt appear when I view it live/in browser/ in flash professional
I have created this button the SAME way, about 36 times, as the other buttons that work fine. What am I doing wrong?
PLEASE HELP ASAP...The error appears to involve trying to assign a value to the graphics property of a MovieClip. Do you have code that uses something.graphics =
-
Action script 3 and adding code to buttons
When I open a new doc and selct action script 3 it won't
allow me to insert code by selcting the button on the stage. It
does if I select action script 2. All my old pages update ok but if
I make new buttons it wont take the code. CAn someone tell me what
is going on???
Thanks a lotIf your in a bind at the moment, I would suggest not
attempting to learn AS3. The system is very different, good, but
different, the syntax structure is much more strict and most things
have been revised to use a listener/broadcaster (or event
dispatcher) model, as well as most coding being class oriented,
additionally the graphic display structure is quite different.
Now did you change your publish settings back to AS2? If so,
you should still be able to apply the above code to a button
instance. However, as Dave stated, even in AS2 the code is best
used from the timeline, to do so with the code above (which the on
handler above is meant for Object attachment) you need to write it
like this:
my_btn.onPress = function() {
_root.loadMovie("graphic_arts/graphic_arts.swf");
I would also consider using a MovieClipLoader and the
loadClip method forloading swf files, as it gives you more control
over the load targeting, progress reporting, and event
notifications.
All this said, to use a button and load a file in AS3, you
need to add an event listener to the button instance and construct
a responding function to the event, in this case the loading of a
swf file. Additionally, in AS3 the MovieClipLoader class, as well
as the loadMovie methods have been replaced by the Loader classes
and must be used to load swf files. So construct a button in AS3
you must write something like the following: -
Code beautifier for MXML and ActionScript?
How do people reformat ugly code in FlexBuilder? I can eaisly
format my Java, JSP, and XML in the same Eclipse environment, but
why not MXML and ActionScript? I am very surprised this feature is
missing. It's quite common that I copy code snippets from somewhere
to FlexBuilder which are not well formatted.Hey guys, Be patient...
Don't forget the years of Java development that have advanced
Eclipse, not counting the 40 mil or so in prior development that
IBM donated when they ported and open sourced their Visual Age
product line. I used VA it back in 96 and it was slow and clunky,
and never would have sold against Borland's Java products.
I'm sure the decision was consciously made by Adobe product
management to get core feature functionality out and concentrate on
other stuff for the next release.
The FLEX team has done a great job and for some who have ever
been under their delivery schedule for the size of this
undertaking, many can appreciate how well they have done.
Also, considering that many eclipse plugins that are free are
worth what you pay for them (I have tested quite a few), the paltry
$700 bucks for FLEX and the fact that it has a great debugger and
profiler makes it worth it.
One final opinion, no matter what anyone says, software is
not free. You pay in time, learning curve, more time, and
sometimes, just plain old tail chasing!
I'm not really being critical, both of you have valid points,
just be patient, they'll get there. -
Problem in shuffling the button and puting image on button in the same code
I'm trying to make 16 block puzzel game. The following code is showing desired output when I'm running it in textpad but it's showing the output in eclipse. Please tell me the reason behind it.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class Puzzel extends JFrame{
JButton[] arr = new JButton[15];
public Puzzel(){
Image image;
Toolkit toolkit= Toolkit.getDefaultToolkit();
image=toolkit.getImage("icon.jpg");
ImageIcon icon=new ImageIcon("icon.jpg");
setIconImage(image);
setTitle("Puzzal");
JMenuItem pic = new JMenuItem("Solved");
pic.setMnemonic('a');
JMenuItem pict = new JMenuItem("Solved");
pict.setMnemonic('a');
JPanel jp = new JPanel(new GridLayout(4,4));
ArrayList list = new ArrayList();
for(int x = 0; x < arr.length; x++)
arr[x] = new JButton("Button "+(x+1));
list.add(arr[x]);
Collections.shuffle(list);
for(int x = 0; x < list.size(); x++)
jp.add((JButton)list.get(x));
getContentPane().add(jp);
pack();
public static void main(String[] args){
new Puzzel().setVisible(true);}
}I want to add image on these buttons and I have tried it using the following code but its not running on eclipse but working fine when run through textpad. I dont know how to use it with shuffel.
setLayout(new GridLayout(4,4));
JButton img1 = new JButton("1.jpg", new ImageIcon("1.jpg"));
getContentPane().add(img1);In the future Swing related questions should be posted in the Swing forum.
I have tried it using the following code but its not running on eclipse I have no idea what "not running" means, but I'm assuming you are having trouble reading the image files.
Read the section from the Swing tutorial on [How to Use Icons|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html] for the proper way to read images so that is works in all environments. -
My ipod has a black screen. I have tried to hold the sleep/off button and menu button at the same time with no luck. I connected to my computer and tried restore on itunes - still with a black screen a voice said "screen locked' code 542
Is the iPad charged? Plug it in with the charger/wall outlet for half an hour and try again to reboot by holding both the power and home buttons until the apple logo appears.
-
How to set an icon of a Button in ActionScript ?
A need to create at runtime some buttons and set their icons.
I found a problem to do that in ActionScript. In MXML is easy
to set the icon just use a syntax like this: <mx:Button
label="some text" icon="images/ok.png"/>
But in ActionScript how I can set the icon ?
I need to create the icon by a path passed as a parameter.
Example:
The user want to create a button with a label and an icon so
call a method like this (that return and instance of Button):
createButton("Update","images/update.png");
Thank at all for the help.
Marcosupahsain08 wrote:
Well i did this
Triangle.setLocation(50, 100);
(where Triangle is a buton)
it doesn't do anything, stays at the same placeIt's all about context here and there are still many unknowns here that can effect your result and that you have not told us or shown us. My suggestion to you is to consider posting an SSCCE (Short, Self Contained, Correct (Compilable), Example, a condensed program similar to your current program in that it demonstrates the problem at hand, but is the smallest bit of code that still compiles and has no extra code that's not relevant to your problem. For more info on SSCCEs please look here:
[http://homepage1.nifty.com/algafield/sscce.html|http://homepage1.nifty.com/algafield/sscce.html]
Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, you can will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. You may want to click on the Preview tab to make sure that your code is formatted correctly. Another way is to place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:
[code]
// your code block goes here.
// note the differences between the tag at the top vs the bottom.
[/code]or
{code}
// your code block goes here.
// note here that the tags are the same.
{code}good luck, pete -
Adding text to a button, and related button fun
Ok, I'm new to AS3 (only been doing it for a couple weeks
now, never really learned AS2), so help would be great, especially
as the deadline was more then a week ago (not all my fault there)
I put a text field inside a button and tried to put text in
that button's text field via the following:
hmm.. I'm new to the forum I guess... don't know if it added
the code, the code is: instancenameofbutton.textfieldinstance.text
= "play";
Well that seems not to work... so how do I make it obey my
auth-or-a-tah?
Am I perhaps just slash dot syntax impaired?
Trouble seem to be that putting text over the button blocks
the event.. Is there another way to skin this cat?
A related problem I haven't been able to fix is.. I have a
text field with dynamic text.. numbers, and I want it to be bold.
Where I'm at in trying to figure out the solution is that bold
dynamic text needs to be specially embedded.. Well, I follow what
the help system tells me to do.. and nothing seems to actually
work. Is there a bug here or something?
Ok, one last related thing.. I'm following the book on
"things thou shalt not do" in that I have a good amount of moving
transparent gradients... well 2 of them actually.. but then other
transparent stuff all over the place that.. could be pushing things
a little far. The frame rate's about 14 fps, screen size is only
about 600x450, I am on an 8 core mac pro with a better then
standard graphics card... seems to me that I've been able to get
away with worse on older version of Flash on a G3 power mac bad in
the day....
Well when I tried to dynamically load mp3s, that's when
things started going down hill! now buttons blink, sometimes aren't
responsive at all.. I'm thinking maybe its that I've over laded the
player and ought to think pulling back...
I have on gradient spinning shape thing that I was
controlling by actionscript using the enter frame thing.. when I
disabled the code.. well things worked fine again... accept that
one of my buttons stopped working.. which is mysterious... cause as
far as I know the code wasn't touching that at all.. so I went back
to buggy vill, cause at least then my buttons work! (most of the
time).
So the only thing I can think to try and do is to try and
optimize stuff... the projects a bit of a rush job.. so it's "a
little hack-e" ( well I confess that at my best things are probably
"a little" hack-e, so this is really bad)
So I'm thinking of just changing the code over to a timer
thing, will that make it all groovy? I mean do you think? I seem to
remember hearing something, somewhere, about the enter frame thing
as having some issues somewhere...
What's also kind of strange is that stuff gets strange when
the mp3s are loaded.. There's only 4 of them, small little
snippets.. which probably total only about 1MB or so.. so why
should that make it trouble? Admittedly there's not a lot of
compression on them, and there stereo but?
Anyway.. I guess I'm just wondering if any of this sets of
any red flags for anyone who actually knows what they are doing..
probably not describing things well enough.. but you know, any help
is appreciated :)same questions, same answers
I'm new to AS3 too. I know the kind of frustration you face,
especially when it comes to finding out the how's. So I'm giving
answers rather than telling people where to look for them (for
now). -
Buttons in ActionScript 3 ?!?!?!
hi...
I'm trying to make a sound controller in actionscript 3. I
used to do this nicely in actionscript 2, but know it seems that
nothing works as in "the old days"...
I created a button and tried to add actionscript to it but it
doesn't let me :-(
How can i apply code to a button on flash CS3 to start and
stop a specific sound?ActionScript 3.0 was designed for advanced Object-Oriented
programmers. Even though this approach is a lot more powerful, it
requires a lot of knowledge and re-learning. Like for example that
every on() event is not only deprecated in this version but
completely removed. So, as the same documentation says. If your
project is not a giant monster, there is no need to learn this
programming approach, which will take you a considerable time. You
can still export as Flash Player 9 to use its improvements but
select ActionScript 2.0 as the ActionScript version on the publish
settings panel.
Take into account that the object structure in ActionScript
3.0 was completely redesigned. So every proccess, from a sinple
event to movie clip creation has changed radically. -
Animating a button with actionScript
I'm fairly stumped on this one - but probably quite simple to fix.
I need to animate the scale of a button with actionScript 2.0. I've inherited a project that was done with actionScript 2.0 and have decided to stay with this generation rather than rewrite the whole project. Anyway - I've created a sound object, it plays audio from the library and 3 seconds after it starts playing, I want to animate the "next" button and make it pulse to attract the users attention.
Doing this by putting the button in a movie clip is not working as I am losing it's button states and besides it's probably far more tighter to program it.
When the user rolls over the button it stops pulsing but still retains it's up, over and down states.
Any easy answer?Thanks for your help Ned.
I ended up making an advanced button with movie clips and using programming for all the states.
Movies are so much easier to control than buttons.
But you have raised something I had overlooked...setTimeout( )
I was using setInterval( ) and then doing clearInterval( ) within the function so it would only loop once, which of course was problematic if the user beat the 'clearInterval' code by clicking on the button too early.
Actually used setInterval( ) to delay all sound on the project - now going to re-program all that.
Thanks
Maybe you are looking for
-
Refernce Nav igational Attribute is not getting the data in Infoprovider
Hi, I am facing the issue with Reference Characteristic which is a navigational attribute for which data is not getting populated in the cube.Please find the below scenario. We have three characteristics 0RECV_WBS_E , 0WBS_ELEMT, ZPSBUSA .Char 0REC
-
Hi Experts, I have created File to Soap syn Scenario. I am getting following error in RWB (CC monitoring):: SOAPFault received from Integration Server. ErrorCode/Category: XIProtocol/WRONG_VALUE; Params: SOAP:Envelope(1)SOAP:Header(1)sap:DynamicConfi
-
How do i set my email up on my dock
The stamp on my dock does not bring up the correct email account, how do I change this? I would like to change it so when I select this icon it brings up the entire email account. As it is now it is only partial, like "old school" off line mode for c
-
Play book bluetooth unable to receive files
I have just started using my playbook but i am having trouble sending files e.g music, pics and videos to my playbook via bluetooth. i have successfully paired my devices to my playbook but when i try to send via bluetooth i get the message "failed t
-
Hi, I would like to link to photos in museum mode. Can I do that, using to link to a photo instead of another note? It's possible to link to songs, so why not photos? Thanks, Beth