FORUMS: list search recent posts

Works in CS5, works in Windows Projector, but not in FlashPlayer!

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Terry Allen
Works in CS5, works in Windows Projector, but not in FlashPlayer!
on Mar 14, 2012 at 7:03:15 pm

I'm new at this, and probably know only enough to be dangerous...

The following code may be clumsy and inelegant, but it's the best I can do right now, and it's way more than I could do a month ago.

All the external files are in the same directory as the SWF file attempting to load them. The Flash Player is 11x32 downloaded from today (although the titlebar claims it's version 10). All external SWF files are written using ActionScript 3.0. O/S is Windows Vista Ultimate, 32bit, 4GB RAM, AMD 2.8GHz dual core processor.

Pressing Ctrl-Enter in Flash Pro CS5 gives me a fully functional application. Publishing to a windows projector also works as expected, but with Flash Player, nothing works after "removeEventListener(Event.ENTER_FRAME, insert_clip);", just a row of tiny dots animated across the very centre (I'm Canadian, we spell funny) of the screen.

import flash.display.Loader;
import flash.display.Sprite;

addEventListener(Event.ENTER_FRAME, insert_clip);

function insert_clip(event:Event):void
var deadlights:Sprite = new Sprite();

var loader01:Loader = new Loader();
loader01.load(new URLRequest("dead_light_3.swf"));

removeEventListener(Event.ENTER_FRAME, insert_clip);

stage.addEventListener(KeyboardEvent.KEY_DOWN, advance);

var flashRed:Sprite = new Sprite();
var flashYellow:Sprite = new Sprite();
var flashGreenSlow:Sprite = new Sprite();
var flashGreenFast:Sprite = new Sprite();
var greenFlashGreen:Sprite = new Sprite();
var redFlashGreen:Sprite = new Sprite();
var amberAfterArrow:Sprite = new Sprite();
var dontWalk:Sprite = new Sprite();
var laneRed:Sprite = new Sprite();
var laneYellow:Sprite = new Sprite();
var laneGreen:Sprite = new Sprite();

function advance(event:KeyboardEvent):void
if(event.keyCode == 49 || event.keyCode == 97) // keyboard or keypad "1"
var loaderRed:Loader = new Loader();
loaderRed.load(new URLRequest("flashing_red_3.swf"));

if(event.keyCode == 50 || event.keyCode == 98) // keyboard or keypad "2"
var loaderYellow:Loader = new Loader();
loaderYellow.load(new URLRequest("flashing_amber_3.swf"));

if(event.keyCode == 51 || event.keyCode == 99) // keyboard or keypad "3"
var loaderGreenFast:Loader = new Loader();
loaderGreenFast.load(new URLRequest("flashing_green_fast_3.swf"));

if(event.keyCode == 52 || event.keyCode == 100) // keyboard or keypad "4"
var loaderGreenSlow:Loader = new Loader();
loaderGreenSlow.load(new URLRequest("flashing_green_slow_3.swf"));

if(event.keyCode == 53 || event.keyCode == 101) // keyboard or keypad "5"
var loaderGreenFlashGreen:Loader = new Loader();
loaderGreenFlashGreen.load(new URLRequest("green_with_flashing_green.swf"));

if(event.keyCode == 54 || event.keyCode == 102) // keyboard or keypad "6"
var loaderRedFlashGreen:Loader = new Loader();
loaderRedFlashGreen.load(new URLRequest("red_with_flashing_green.swf"));

if(event.keyCode == 55 || event.keyCode == 103) // keyboard or keypad "7"
var loaderAmberAfterArrow:Loader = new Loader();
loaderAmberAfterArrow.load(new URLRequest("amber_after_arrow.swf"));

if(event.keyCode == 56 || event.keyCode == 104) // keyboard or keypad "8"
var loaderDontWalk:Loader = new Loader();
loaderDontWalk.load(new URLRequest("Crosswalk_Count-Down.swf"));

if(event.keyCode == 57 || event.keyCode == 105) // keyboard or keypad "9"
var loaderLaneGreen:Loader = new Loader();
loaderLaneGreen.load(new URLRequest("lane_control_green.swf"));

if(event.keyCode == 58 || event.keyCode == 96) // keyboard or keypad "0"
var loaderLaneYellow:Loader = new Loader();
loaderLaneYellow.load(new URLRequest("lane_control_flashing_yellow.swf"));

if(event.keyCode == 189 || event.keyCode == 109) // keyboard or keypad "-" (minus)
var loaderLaneRed:Loader = new Loader();
loaderLaneRed.load(new URLRequest("lane_control_red.swf"));


I have a couple of other questions, which my help clarify the depth of my ignorance:

1. As I understand it, I am creating a empty container (a Sprite), and adding it to the display, I am then loading an external SWF into that container. How do I then remove the external SWF? I've tried "removeChild" in various combinations and received compiler errors: the problem seems to be that I don't understand which object I should be attempting to remove.

2. The project of which this is a small part is an eight session classroom presentation - a super PowerPoint, so to speak, but with animations that are impossible with presentation software. Each of the eight sessions is made up of ten or so components. Within each component I have used right- and left-arrow keys to step forward and back, with the down-arrow key to skip to the end. Is there a way to "trap" the same keystrokes within the child SWF, to control it, which would give the end-user a much simpler and more consistent user-inteface?

Thanks in advance... if only for reading this far.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved