Quantcast
Channel: Adobe Community : Popular Discussions - ActionScript 3
Viewing all 18626 articles
Browse latest View live

Flash CS6 start and stop button coding AS3??

$
0
0

I need to use Flash for a uni assignment, I have just started using Flash so this is a beginner question.

 

For my assignment I need to create a bouncing ball animation and then add stop and start buttons. So I created the buttons by drawing rectangles and then converted it to a symbol and made it a button. I have tried all the coding snippets that I can find and most of the time comes up as a 1086 Syntax error. The coding I've been using is:

For the play button:

on(release){

  play();

}

 

For the stop button:

on(release){

  stop();

}

 

Can you please tell me what I'm doing wrong?


Looping an externally loaded video - H.264

$
0
0

I would like to know if it is possible using AS3 to loop [ seamlessly or even slightly un-seamlessly! ] an externally loaded video - encoded as h.264

I have searched many leads trying to find out if this is currently viable. It doesn't seem as easy as I imagined it would be.

 

I have member of my team that knows some AS2 - and has very little knowledge of AS3. He wrote scripts for looping functionality in AS2 - however as we need to upgrade to Adobe Animate CC to use 4k video for a large touchscreen application - so we are trying to find out if looping video, loaded externally, can be scripted for in AS3.

 

It actually seems pretty crazy to me that such a feature is so hard to achieve. I would have thought that in today's media saturated world, this would be a basic and simple requirement.

 

If anyone can point me in the right direction I would be grateful. I need to determine whether to upgrade to Animate or to stay with CS5.5, and HD 1080p video.touchscreen.jpg

Stop push from overwriting values in an array

$
0
0

Hi,

I'm trying to create an array containing scores and usernames which I can then sort and display in a table, but I'm stuck on one issue. When I try to push a second score to the highscores array, it saves again at position 0 rather than adding new data to position 1 and so on. In the following code, myScore contains the score that the user just achieves and myName contains their set username.

 

var highscores:Array=newArray();
highscores
.push({score: myScore, player: myName});
highscores
.sortOn("score",Array.DESCENDING |Array.NUMERIC);

for(var i:int=0; i < highscores.length; i++)
{
  trace
(highscores[i].score, highscores[i].player);
}

 

How can I get this to add to the array rather than overwriting current data?

Thanks.

How to stop movieclip from playing?

$
0
0

How do I stop a movieclip from playing? I want the animations in the movieclip to not play from the beginning of my main timeline. this.stop() stop the whole animation. this.mc.stop() is not working. mc.stop() is not working.

Adding Stroke to images

$
0
0
Hi all,

I was wondering how I can add stroke to my images, I want to have a white border (3 pixel) around my images and I am calling my images from a image folder with a TXT or XML file. Is there a way to add the stroke to them using AS3 so it automatically applies the stroke to all my images?

Many thanks in advance
Mitchell

____________________________________
Australian Wedding Directory
http://www.weddingsonly.com.au
Weding Video Sydney
http://www.iconfilmproductions.com

Convert String to ByteArray?

$
0
0
Hello,

How does one go about converting a String into a ByteArray? I was hoping the String class would have a method called&quot;GetBytes() or toBytes()&quot;, but this doesn't seem to be the case.

Thanks,
Mike

PHP+AS3 Problem

$
0
0
I am trying to send data (variables) to a php file. I keep getting an error even though I am using the exact method used in Flash Help (something like Using External Data).

Error #1009 - the most stupid AS3 loader issue ever !!!

$
0
0

Hi,

 

(It's about AS3 / Flash CS4)

 

As a developer I often have no controll what is the content of a movie being runtime-loaded. I must presume I have no control on it at all - movie clips are marketed and sold and the only thing expected is that they play nice. And they are supposed to be runtime-loaded by a simple "progress-bar" style loader.

 

The loader movie itself is fine. Though it's not sort of these tricky "no timeline, document-class only" it used to do the job.

 

The main code is as folllows:

 

FRAME 2:

 

var thisRequest:URLRequest = new URLRequest("movie.swf");
var thisLoader:Loader = new Loader();

var newContent:MovieClip;

 

thisLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, doneLoading);

 

function doneLoading(evt:Event):void{
    newContent = MovieClip(thisLoader.content);

        //stage.addChild(newContent); -- please notice I commented this line !!!
}

 

 

FRAME 3:


thisLoader.load(thisRequest);

 

 

As you may see, it's nothing special - just regular loader stuff here...

 

But the issue is that it throws errors just in case of some loaded SWFs.

Another words - the content and structure of movie.swf impact the loader performance!

 

Too often I notice this kind of error being thrown right after "thisLoader.load(thisRequest);" is execuded:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at movie_fla::MainTimeline/frame8()

 

Right after - that means BEFORE adding loaded movie to the Stage childlist etc.

I said - right after movie.swf is invoked by the "load" command !

 

This is really rediculous!

 

I do not expect this sort of behavior! I expect the loaded movie to be quiet unless explicitly added to stage with:

 

stage.addChild(newContent);

 

But in a contrary - it seems the loaded movie becomes somewhat active right after being loaded - even before being added to stage. And in some cases this prematured activity leads to hard-to-controll errors! Please notice the error is thrown despite line where loaded content is added to stage is commented!

 

I said what I wanted to say - now dear Flash AS3 experts and mastahakas please - give me some advice what to do in this situation.

I am really, really confused as I want to write clean, error-free code and I get run out of ideas how to deal with this nasty issue.

 

Rgs,

Ziggi


How to make a draggable object snap into place?

$
0
0

I'm new to Flash (sort of - I used it a bit back in 1999-2000, but it's changed a LOT since then). I'm making an educational game for my company that involves dragging labels from a word-bank to their correct position on a diagram. I want the kids to be able to drag any one of the five labels and move them to any one of five marked positions on the diagram. I'm using Flash CS5 with Actionscript 3. I used code snippets, so that each individual label has the following code associated with it:

 

 

movieClip_1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);

 

function fl_ClickToDrag(event:MouseEvent):void

{

movieClip_1.startDrag();

}

 

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);

 

function fl_ReleaseToDrop(event:MouseEvent):void

{

movieClip_1.stopDrag();

}

Is there any code that I could add in there to make the objects then snap into positions when dragged near them? Note that there are five possible positions for them to snap to. The coordinates for those are:
XY

299.75

235.90
775.40244.65
421.15447.45
804.15484.85
437.15599.60

Here is a screenshot of the area of the game that this is concerning to give you an idea of what I'm talking about:

 

screencapphotosynth.JPG

 

Thanks for any help you can give me.

Problem with [new Loader()]

$
0
0

Hallo!

 

I have a two movie clips (preload.swf and index.swf).

Starting with preload.swf. Preload movie clip loading index.swf.

But nothing works on index movie clip (stage resizing, mouse events).

Maybe somebody show some examples.

 

Thanks

gotoAndStop to a previous and next keyframe

$
0
0

I'm quite new to flash and am working w/ as3 (Flash cs5)  I've got a 700 frame timeline working w/ 7 different images (each on a different layer) and a 50 frame tween between each.  I can't seem to figure out how to code (one)a forward and back button that once pressed will go to the previous (or next) keyframe.  I tried to code it to + or - 75 frames:

next_forward.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_2);

 

function fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void
{
    gotoAndStop(currentFrame + 75);
}

But that completely depends on where the initial click occurs on the timeline and ends up being in the middle of a tween.

 

Any help would be GREATLY appreciated!

Passing variables from AS3 to PHP

$
0
0

Hi there

 

I am having some trouble in passing variables from AS3 to PHP. I am using flash and php both in the same file [try.php].

I've stuck with this for two days.. Here's what I have done. Please help!!!

 

header.fla [Actionscript in the timeline]

 

stop();

import flash.events.Event;
import flash.display.Sprite;
import flash.net.*;

var url:String = "http://localhost/0000/try.php"; 
var req:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader();
var variables:URLVariables = new URLVariables();

send_btn.addEventListener(MouseEvent.CLICK, sendForm);

function sendForm(evt:MouseEvent):void
{
    // add the variables to our URLVariables    variables.asd = "value";        // send data via post    req.method = URLRequestMethod.POST;    req.data = variables;    loader.dataFormat = URLLoaderDataFormat.TEXT;    // add listener        loader.addEventListener(Event.COMPLETE, onLoaded);    loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);        //send data    loader.load(req);
}

function onLoaded(evt:Event):void
{
    var result_data:String = String(loader.data);    if (result_data)    {        trace(result_data);    }    else if (!result_data)    {        trace("error");    }
}

function ioErrorHandler(event:IOErrorEvent):void
{
    trace("ioErrorHandler: " + event);
}

 

try.php

 

<body><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="563" height="280">  <param name="movie" value="header.swf" />  <param name="quality" value="high" />  <param name="wmode" value="opaque" />  <param name="swfversion" value="6.0.65.0" />  <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->  <param name="expressinstall" value="../Scripts/expressInstall.swf" />  <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->  <!--[if !IE]>-->  <object type="application/x-shockwave-flash" data="header.swf" width="563" height="280">    <!--<![endif]-->    <param name="quality" value="high" />    <param name="wmode" value="opaque" />    <param name="swfversion" value="6.0.65.0" />    <param name="expressinstall" value="../Scripts/expressInstall.swf" />    <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->    <div>      <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>      <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>    </div>    <!--[if !IE]>-->  </object>  <!--<![endif]--></object><?php

if($_POST['asd'])

echo "value of var1 is <b>".$_POST['asd']."</b>";

else

echo "bad luck";

?></body>


BIG THANKS!!

UnloadAndStop(); not working?

$
0
0

Hello and Happy New Year to all forum members.

 

I have a Flash AS3 project. The main menu of the project calls on other swfs the following way:


aone_btn.addEventListener(MouseEvent.CLICK, aonemovie);


function aonemovie(event:MouseEvent) {
var loadera = new Loader();
addChild(loadera);
loadera.load(new URLRequest("demos/demo1a.swf"));

}

 

The loaded swf is a simple window with a UILoader component that in turn loads an swf movie built with Adobe Captivate.

The loaded swf has a close button.

 

I manage to unload the loaded movie with the close button and the following code:

 

exitinteraction_btn.addEventListener(MouseEvent.CLICK, closeI);

 

function closeI(e:Event):void{
    Loader(this.parent).unloadAndStop();
}

 

But as soon as I get back to my main menu and despite removing the visual presence of the loaded swf I can still hear sounds of the loaded clip. Any ideas or help will be appreciated.

 

Att.,

 

Edwin

RSL loader

$
0
0

I get the RSL error everytime I try to export my .fla file. Is there ANY way I can fix this? I got quite alot textwindows, so I could really need help on making a preloader or find another way of fixing this?...

swf in HTML

$
0
0

I used Dreamweaver cs5 to embed my swf file in an html page.  I know that the swf is loaded and running because I can highlight some text in the initial frame.  The problem is that, everything else is blacked out.  the text is black to which is why I have to highlight it.  So it's there, I just can't do anything with it.  I know the swf runs fine in flash or flash player.

 

here is my html code

 

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="825" height="554" id="FlashID" title="Destiny's Realm">
        <param name="movie" value="TownsendFinal/final.ai.swf" />
        <param name="quality" value="high" />
        <param name="wmode" value="opaque" />
        <param name="swfversion" value="6.0.65.0" />
        <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
        <param name="expressinstall" value="Scripts/expressInstall.swf" />
        <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="TownsendFinal/final.ai.swf" width="825" height="554">
          <!--<![endif]-->
          <param name="quality" value="high" />
          <param name="wmode" value="opaque" />
          <param name="swfversion" value="6.0.65.0" />
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
          <div>
            <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
            <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
          </div>
          <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
     </object>

 

 

any ideas would be a really big help.  This is for school and it's due soon


Help with on release gotoAndPlay

$
0
0

Hello -

 

I am working on a Flash project that was using AS2.  I now need to update it to AS3.  This specific item is for a button that will Close when clicked on and then start playing at frame 400.  The button has an instance name of Close.

 

Can anyone teach or tell me how to convert the following code to AS3?

 

on (release) {

    gotoAndPlay(400);

}

 

 

Thank you!!!

Add dynamic text to loader

$
0
0

Hello,

I'm trying to get dynamic text to parent to a loader. I don't get any errors, but once I add the code(commented out below) the text that is rendered through the renderText function stops showing up. Any ideas?

 

//input Text

line1Label.text = "Line 1";

inputTextOne.text = "Custom Text: Line 1";

stage.focus = inputTextOne;

inputTextOne.addEventListener(TextEvent.TEXT_INPUT, renderText);

 

var hasText: Boolean;

function renderText (evt:TextEvent): void

{

 

inputTextRender01.text = inputTextOne.text;

hasText = true;

 

    if(hasText == true)

    {

        //.BGContain.addChild(inputTextRender01); //trying to add the text to the loader BGContain....

    }

}

Loading external swf into Air App

$
0
0

Hi All,

 

I'm building an Adobe Air App for desktop and am having problems loading an external swf. Every time i try to load i get:

 

SecurityError: Error #2070: Security sandbox violation........ cannot access Stage owned by app....blah blah

 

The file that is being loaded is in a local directory, but as i understand its in a different 'sandbox' which is a security risk.


Is there any way around this?!


Any help would be much appreciated


Many Thanks


Matt

AS3 Unloading external SWF piling up problem

$
0
0

I have two buttons on main SWF what loads and Unload two external SWFs back and forth.

 

Also one timer function is calling external Screen saver SWF and unload the existing one when no interaction found.

 

I am using unloadAndStop() function to unload the external SWFs.

 

But after loading and unloading external SWFs, I am facing piling up or stack overflow problem.

 

Any help will be highly appreciated.

 

Thanks

import flash.net.NetConnection;

import flash.net.NetStream;

import flash.media.Video;

import flash.display.MovieClip;

import caurina.transitions.*;

import flash.utils.Timer;

import flash.events.*;

 

var myLoader_Map_1:Loader = new Loader();

var myLoader_Map_2:Loader = new Loader();

var myLoader_Screen_Saver:Loader = new Loader();

 

var Ss:Boolean = false;

var Maps:Boolean = true;

 

//--------------------Screen Saver---------------------------------

 

ScreenSaver();

 

 

  function ScreenSaver():void{

  var url:URLRequest = new URLRequest("screensaver.swf");

  myLoader_Screen_Saver.load(url); 

  addChild(myLoader_Screen_Saver);

  setChildIndex(myLoader_Screen_Saver, 1);

  Maps = false;

  Ss = true;

  

  }

  

  function ScreenSaver_Unload():void{

  myLoader_Screen_Saver.unloadAndStop();

  

  }

  

//--------------------Map Buttons---------------------------------

 

 

function MPstart():void{

  

  Tweener.addTween(MC_Maps_Btns,{alpha:1, x:778.25, y:1070.65, time:1, delay:1, transition:"easeOutCubic"});

  setChildIndex(MC_Maps_Btns, 2);

  

  MC_Maps_Btns.Btn_Map_1.visible = true;

  MC_Maps_Btns.Btn_Map_2.visible = true;

  

}

 

function MPclose():void{

  

  Tweener.addTween(MC_Maps_Btns,{alpha:0, x:778.25, y:1179.85, time:1, transition:"easeOutCubic"});

  

}

  

//--------------------Map 1 ---------------------------------

 

MC_Maps_Btns.Btn_Map_1.addEventListener(MouseEvent.CLICK,OpenMap1);

 

 

  function OpenMap1(e:MouseEvent):void{

  

  

  var url:URLRequest = new URLRequest("Map_1.swf");

  myLoader_Map_1.load(url);

  myLoader_Map_1.alpha = 1;

  addChild(myLoader_Map_1);

  setChildIndex(myLoader_Map_1, 2);

  

  myLoader_Map_2.unloadAndStop();

  ScreenSaver_Unload();

  

  Maps = true;

  Ss = false;

  

  MC_Maps_Btns.Btn_Map_1.visible = false;

  MC_Maps_Btns.Btn_Map_2.visible = true;

  

  

  }

//--------------------Map 1 ---------------------------------

 

MC_Maps_Btns.Btn_Map_2.addEventListener(MouseEvent.CLICK,OpenMap2);

 

  function OpenMap2(e:MouseEvent):void {

  

  

  var url:URLRequest = new URLRequest("Map_2.swf");

  myLoader_Map_2.load(url);

  myLoader_Map_2.alpha = 1;

  addChild(myLoader_Map_2);

  setChildIndex(myLoader_Map_2, 2);

  

  myLoader_Map_1.unloadAndStop();

  ScreenSaver_Unload();

  

  Maps = true;

  Ss = false;

  

  MC_Maps_Btns.Btn_Map_2.visible = false;

  MC_Maps_Btns.Btn_Map_1.visible = true;

  

  }

 

//--------------------Timer ---------------------------------

 

var inactiveTime:int = 10000;

var t:Timer = new Timer(inactiveTime);

 

stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown1);

t.addEventListener(TimerEvent.TIMER, onTimer);

t.start();

 

  function onMouseDown1(e:MouseEvent):void {

  t.reset();

  t.start();

  trace("Interaction detected");

  }

  

  function onTimer(e:TimerEvent):void {

  handleInactivity();

  

  }

  

  function handleInactivity():void {

  trace('You\'re inactive.');

  

  if (Maps == true){

  

  myLoader_Map_1.unloadAndStop();

  myLoader_Map_2.unloadAndStop();

  }

  

  else{

  trace("No Maps");

  }

  

  if (Ss == false ){

  

  ScreenSaver();

  MPclose();

  }

  

  else{

  trace("ScreenSaver already loaded");

  }

  

  

  }

Bubble shooter game in as3

$
0
0

hi ....anyone pls send tutorial for creating a bubble shooter game in as3 ......i am trying to creating a game which look like this bubble-shooter-classic_img2.jpg

Thnks in advance ......

Viewing all 18626 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>