STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
228124
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2561 · P5121

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/13825414?noj=FRM13825414-12DN" width="1" height="1"></div>

This is resource EYYW2E1, an Archived Thread.
Discovered:13/1 -2016 22:48:58

Ended:13/1 -2016 22:48:58

Checked:14/1 -2016 03:25:25

Original location: http://boards.4chan.org/f/thread/2998288/for-the-macrom…
Recognized format: Yes, thread post count is 2.
Discovered flash files: 1





File: random text tut.swf-(37 KB, 550x400, Other)
[_] for the Macromedia 8 anon Anonymous 01/13/16(Wed)16:44:54 No.2998288

  (part 1)

  So you want random text.I venture this would be the simplest way:

  * You want the random text when you start the movie, so we'll do this in a blank keyframe in the
  very first frame of the scene. When AS flow of control enters the first frame, it will set up the
  stage, and then execute any script we write in that frame.

  * You need a text output. Use the text tool to make a label somewhere on your stage in the first
  frame, and give it an instance name in the properties panel (like... myLabel). Now you can call
  it in code and assign it text.

  *You need some strings to populate your label. declare an array and give it some strings you want
  to have appear in your label:
  //sample code:

  var myStrings:Array = new Array("this is a random message.", "this is some other thing.", "you
  grandmother sucks eggs");

  * Now we need to pick one of the strings at random and pass it to the label we made.

  A quick function to generate a random number of a desired rage:
  //sample code:

  function getRandomText(limit:Number):Number {
  var randomNumber:Number = Math.floor(Math.random()*(limit+1));
  return randomNumber;
  }

  It returns a random number from 0 to -limit-. You give it the array element number of your last
  text (limit), in our case this will be 2.

  (continued...)

>> [_] Anonymous 01/13/16(Wed)16:46:06 No.2998293

  (part 2)

  * You now have 3 strings in an array, and we can easily get a random number and generate the name
  of one of them to stick in the label. We can now simply assign one of the strings at random to
  the label's text field like so:
  //sample code:

  myLabel.text = myStrings[getRandomText(2)];

  Finally, unless you want the timeline to keep running (or looping back and re-running the first
  frame if your flash is only one frame, or even very short), stop it after executing the script we
  wrote, like so:
  //sample code:

  stop();

  *** ***
  to keep going now, you can use
  gotoAndPlay(frame);

  where frame is the number of the fram you want to start the playhead at.
  Also,
  gotoAndPlay(frame, "scene");

  where scene is the name of a scene in the movie, and frame is a frame in that scene.
  *** ***

  That's it. 5 lines of code, 6 if you stop at the end. :^)

  The flash here is exactly this code, but there's a few more messages, and I've added a click
  handler (BEFORE the stop(); command!) so that every time you click the flash, it re-populates the
  label:
  //sample code:

  stage.addEventListener(MouseEvent.CLICK, repopulateLabel);

  function repopulateLabel(event:MouseEvent):void {
  myLabel.text = myStrings[getRandomText(2)];
  }

  Now it's 8 whole lines, and you got half a Meet 'n' Fuck game built. All you need now is nice
  cartoon tits and a plot that doesn't suck.

  Have fun.



http://swfchan.net/32/EYYW2E1.shtml
Created: 13/1 -2016 22:48:58 Last modified: 14/1 -2016 03:25:35 Server time: 12/05 -2024 19:40:47